本文整理汇总了Python中pymodbus.payload.BinaryPayloadDecoder.decode_string方法的典型用法代码示例。如果您正苦于以下问题:Python BinaryPayloadDecoder.decode_string方法的具体用法?Python BinaryPayloadDecoder.decode_string怎么用?Python BinaryPayloadDecoder.decode_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymodbus.payload.BinaryPayloadDecoder
的用法示例。
在下文中一共展示了BinaryPayloadDecoder.decode_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBigEndianPayloadDecoder
# 需要导入模块: from pymodbus.payload import BinaryPayloadDecoder [as 别名]
# 或者: from pymodbus.payload.BinaryPayloadDecoder import decode_string [as 别名]
def testBigEndianPayloadDecoder(self):
''' Test basic bit message encoding/decoding '''
decoder = BinaryPayloadDecoder(self.big_endian_payload, endian=Endian.Big)
self.assertEqual(1, decoder.decode_8bit_uint())
self.assertEqual(2, decoder.decode_16bit_uint())
self.assertEqual(3, decoder.decode_32bit_uint())
self.assertEqual(4, decoder.decode_64bit_uint())
self.assertEqual(-1, decoder.decode_8bit_int())
self.assertEqual(-2, decoder.decode_16bit_int())
self.assertEqual(-3, decoder.decode_32bit_int())
self.assertEqual(-4, decoder.decode_64bit_int())
self.assertEqual(1.25, decoder.decode_32bit_float())
self.assertEqual(6.25, decoder.decode_64bit_float())
self.assertEqual(b'test', decoder.decode_string(4))
self.assertEqual(self.bitstring, decoder.decode_bits())
示例2: testLittleEndianPayloadDecoder
# 需要导入模块: from pymodbus.payload import BinaryPayloadDecoder [as 别名]
# 或者: from pymodbus.payload.BinaryPayloadDecoder import decode_string [as 别名]
def testLittleEndianPayloadDecoder(self):
""" Test basic bit message encoding/decoding """
decoder = BinaryPayloadDecoder(self.little_endian_payload, endian=Endian.Little)
self.assertEqual(1, decoder.decode_8bit_uint())
self.assertEqual(2, decoder.decode_16bit_uint())
self.assertEqual(3, decoder.decode_32bit_uint())
self.assertEqual(4, decoder.decode_64bit_uint())
self.assertEqual(-1, decoder.decode_8bit_int())
self.assertEqual(-2, decoder.decode_16bit_int())
self.assertEqual(-3, decoder.decode_32bit_int())
self.assertEqual(-4, decoder.decode_64bit_int())
self.assertEqual(1.25, decoder.decode_32bit_float())
self.assertEqual(6.25, decoder.decode_64bit_float())
self.assertEqual("test", decoder.decode_string(4))
self.assertEqual(self.bitstring, decoder.decode_bits())
示例3: testLittleEndianPayloadDecoder
# 需要导入模块: from pymodbus.payload import BinaryPayloadDecoder [as 别名]
# 或者: from pymodbus.payload.BinaryPayloadDecoder import decode_string [as 别名]
def testLittleEndianPayloadDecoder(self):
""" Test basic bit message encoding/decoding """
decoder = BinaryPayloadDecoder(self.little_endian_payload,
byteorder=Endian.Little,
wordorder=Endian.Little)
self.assertEqual(1, decoder.decode_8bit_uint())
self.assertEqual(2, decoder.decode_16bit_uint())
self.assertEqual(3, decoder.decode_32bit_uint())
self.assertEqual(4, decoder.decode_64bit_uint())
self.assertEqual(-1, decoder.decode_8bit_int())
self.assertEqual(-2, decoder.decode_16bit_int())
self.assertEqual(-3, decoder.decode_32bit_int())
self.assertEqual(-4, decoder.decode_64bit_int())
self.assertEqual(1.25, decoder.decode_32bit_float())
self.assertEqual(6.25, decoder.decode_64bit_float())
self.assertEqual(None, decoder.skip_bytes(2))
self.assertEqual('test', decoder.decode_string(4).decode())
self.assertEqual(self.bitstring, decoder.decode_bits())