I am using a Python library for ANT+ wireless communication with sensors. Communication is done by pairing with an ID, which is a number 4-5 digits long. It was all working fine until one of the devices I tested had an ID of "00625".
Tracking the code, the source of the issue is the struct pack/unpack function used to encode and decode the bytes for the ANT+ protocol message.
>>> from struct import *
>>> pack(b'<H', 11977)
'\xc9.'
>>> unpack(b'<H', '\xc9.')
(11977,)
>>> pack(b'<H', 625)
'q\x02'
>>> unpack(b'<H', 'q\x02')
(625,)
>>> pack(b'<H', 00625)
'\x95\x01'
>>> unpack(b'<H', '\x95\x01')
(405,)
So, when I pack the ANT ID's 11977 or 625 and then unpack them, I get exactly what I packed.
However, when I pack ANT ID 00625 and then unpack it, I get 405 back. Not sure how I can go about dealing with this, so that I can pack 00625 correctly.