Beispiel #1
0
 def test_mkmarker_nested(self):
     buf = MsgBuffer()
     with buf.add_opaque_deferred(2):
         buf.add_uint16(0x1122)
         buf.add_uint32(0xaabbccdd)
         buf.add_uint8(0xff)
         with buf.add_opaque_deferred(3):
             buf.add_uint16(0xaaaa)
             buf.add_uint16(0xbbbb)
             buf.add_uint16(0xcccc)
             buf.add_uint8(0x55)
     self.assertEqual(
         buf.data,
         bytes.fromhex("0011 1122 aabbccdd ff 000007  aaaa bbbb cccc 55"))
Beispiel #2
0
 def test_mkopaque_annotated(self):
     buf = MsgBuffer()
     with buf.new_marker("MainPayload"), buf.add_opaque_deferred(2):
         with buf.new_marker("AnimalCounts"), buf.add_opaque_deferred(2):
             with buf.new_marker("CowCount"):
                 buf.add_uint16(9000)
             with buf.new_marker("SheepCount"):
                 buf.add_uint16(4321)
             with buf.new_marker("ChickenCount"):
                 buf.add_uint32(12345678)
         with buf.new_marker("VehicleCounts"), buf.add_opaque_deferred(2):
             with buf.new_marker("CarCount"):
                 buf.add_uint24(133)
             with buf.new_marker("TrainCount"):
                 buf.add_uint24(92)