Skip to content

Commit

Permalink
ASCII+TLS integrated.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Mar 5, 2024
1 parent 6b50249 commit 4b8ab6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pymodbus/framer/ascii_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ def buildPacket(self, message):
packet.extend(b2a_hex(encoded))
packet.extend(f"{checksum:02x}".encode())
packet.extend(self._end)
return bytes(packet).upper()
packet = bytes(packet).upper()

data = message.function_code.to_bytes(1,'big') + encoded
packet_new = self.message_handler.encode(data, message.slave_id, message.transaction_id)
assert packet == packet_new, "ASCII FRAMER BuildPacket failed!"
return packet


# __END__
4 changes: 4 additions & 0 deletions pymodbus/framer/tls_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def buildPacket(self, message):
data = message.encode()
packet = struct.pack(TLS_FRAME_HEADER, message.function_code)
packet += data

data_new = message.function_code.to_bytes(1,'big') + data
packet_new = self.message_encoder.encode(data_new, message.slave_id, message.transaction_id)
assert packet == packet_new, "TLS FRAMER BuildPacket failed!"
return packet


Expand Down

0 comments on commit 4b8ab6f

Please sign in to comment.