Skip to content
Discussion options

You must be logged in to vote

Uh oh, I figured out how to set it dynamically. I added a calculateRtuFrameSize method to my CustomModbusRequest:

@classmethod def calculateRtuFrameSize(cls, data: bytes) -> int: """Calculate the size of a PDU.""" modbus_header_size = 2 # address (1) + function code (1) modbus_crc_size = 2 # CRC (2) modbus_overhead_size = modbus_header_size + modbus_crc_size if len(data) < modbus_header_size + HEADER_SIZE: return 8 try: # read packet_size from the header (skipping Modbus address & function code) (packet_size,) = struct.unpack_from("<H", data, modbus_header_size) # reject absurd sizes if packet_size < HEADER_SIZE or packet…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@lovetheguitar
Comment options

@janiversen
Comment options

@lovetheguitar
Comment options

@lovetheguitar
Comment options

Answer selected by janiversen
@lovetheguitar
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants