Ejemplo n.º 1
0
    def test_ufloat(self):
        values = (123.2, 100.12)
        format = '66'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        values = (12.2, 10.12)
        format = '66'
        self.assertEqual(unpack(format, pack(format, *values)), values)
Ejemplo n.º 2
0
    def test_lfloat(self):
        values = (12.123, 1.321)
        format = '88'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        values = (9.1, 3.1)
        format = '88'
        self.assertEqual(unpack(format, pack(format, *values)), values)
Ejemplo n.º 3
0
    def test_lfloat(self):
        values = (12.123, 1.321)
        format = '88'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        values = (9.1, 3.1)
        format = '88'
        self.assertEqual(unpack(format, pack(format, *values)), values)
Ejemplo n.º 4
0
    def test_ufloat(self):
        values = (123.2, 100.12)
        format = '66'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        values = (12.2, 10.12)
        format = '66'
        self.assertEqual(unpack(format, pack(format, *values)), values)
Ejemplo n.º 5
0
    def test_format(self):
        values = (1, 6, 3, 199)
        format = '1111'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        values = (-43, 12, 3991)
        format = '211'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        macaddr = 'AABBCCDDEEFF'
        values = (macaddr, 3212, -99912, 32943)
        format = '3154'
        self.assertEqual(unpack(format, pack(format, *values)), values)
Ejemplo n.º 6
0
    def test_format(self):
        values = (1, 6, 3, 199)
        format = '1111'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        values = (-43, 12, 3991)
        format = '211'
        self.assertEqual(unpack(format, pack(format, *values)), values)

        macaddr = 'AABBCCDDEEFF'
        values = (macaddr, 3212, -99912, 32943)
        format = '3154'
        self.assertEqual(unpack(format, pack(format, *values)), values)
Ejemplo n.º 7
0
    def show_unpacked_values(self, sensor, valid, data):
        if sensor in sensorspec:
            name, fmt, fields = sensorspec[sensor]

            print("    Sensor Name:", name)
            print("    Sensor Values:")

            values = unpack(fmt, data)

            for field, value in zip(fields, values):
                print("    - {}: {}".format(field, value))
        else:
            print("    Sensor Name: ?")
            print("    Sensor Values: ?")
Ejemplo n.º 8
0
 def subpacket_received(self, sensor, valid, data):
     if sensor == 0x00:
         print('airsense id:', unpack('3', data)[0])
     elif sensor == 0x20:
         print('chemsense id:', unpack('3', data)[0])