diff --git a/pymodbus/transaction.py b/pymodbus/transaction.py index 4118ba826..9bfc4d779 100644 --- a/pymodbus/transaction.py +++ b/pymodbus/transaction.py @@ -742,6 +742,7 @@ def buildPacket(self, message): message.unit_id, message.function_code) + data packet += struct.pack(">H", computeCRC(packet)) + packet = '%s%s%s' % (self.__start, packet, self.__end) return packet def _preflight(self, data): @@ -755,7 +756,7 @@ def _preflight(self, data): ''' def _filter(a): if a in ['}', '{']: return a * 2 - else: return a, data + else: return a return ''.join(map(_filter, data)) #---------------------------------------------------------------------------# diff --git a/test/test_transaction.py b/test/test_transaction.py index a0ac8c7ad..2df2736f6 100644 --- a/test/test_transaction.py +++ b/test/test_transaction.py @@ -340,7 +340,7 @@ def testBinaryFramerPacket(self): message = ModbusRequest() message.unit_id = 0xff message.function_code = 0x01 - expected = '\xff\x01\x81\x80' + expected = '\x7b\xff\x01\x81\x80\x7d' actual = self._binary.buildPacket(message) self.assertEqual(expected, actual) ModbusRequest.encode = old_encode