api function to query receiver info
This commit is contained in:
parent
04471ec660
commit
bc9f39873e
|
@ -33,6 +33,31 @@ open = _base.open
|
||||||
close = _base.close
|
close = _base.close
|
||||||
|
|
||||||
|
|
||||||
|
def get_receiver_info(handle):
|
||||||
|
serial = None
|
||||||
|
reply = _base.request(handle, 0xff, b'\x83\xB5', b'\x03')
|
||||||
|
if reply and reply[0:1] == b'\x03':
|
||||||
|
serial = _hexlify(reply[1:5])
|
||||||
|
|
||||||
|
firmware = '??.??'
|
||||||
|
reply = _base.request(handle, 0xff, b'\x81\xF1', b'\x01')
|
||||||
|
if reply and reply[0:1] == b'\x01':
|
||||||
|
fw_version = _hexlify(reply[1:3])
|
||||||
|
firmware = fw_version[0:2] + '.' + fw_version[2:4]
|
||||||
|
|
||||||
|
reply = _base.request(handle, 0xff, b'\x81\xF1', b'\x02')
|
||||||
|
if reply and reply[0:1] == b'\x02':
|
||||||
|
firmware += '.B' + _hexlify(reply[1:3])
|
||||||
|
|
||||||
|
bootloader = None
|
||||||
|
reply = _base.request(handle, 0xff, b'\x81\xF1', b'\x04')
|
||||||
|
if reply and reply[0:1] == b'\x04':
|
||||||
|
bl_version = _hexlify(reply[1:3])
|
||||||
|
bootloader = bl_version[0:2] + '.' + bl_version[2:4]
|
||||||
|
|
||||||
|
return (serial, firmware, bootloader)
|
||||||
|
|
||||||
|
|
||||||
def request(handle, devnumber, feature, function=b'\x00', params=b'', features=None):
|
def request(handle, devnumber, feature, function=b'\x00', params=b'', features=None):
|
||||||
"""Makes a feature call to the device, and returns the reply data.
|
"""Makes a feature call to the device, and returns the reply data.
|
||||||
|
|
||||||
|
|
|
@ -6,33 +6,18 @@ logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
|
||||||
from .unifying_receiver import (api, base)
|
from .unifying_receiver import api
|
||||||
from .unifying_receiver.constants import *
|
from .unifying_receiver.constants import *
|
||||||
|
|
||||||
|
|
||||||
def print_receiver(receiver):
|
def print_receiver(receiver):
|
||||||
print ("Unifying Receiver")
|
print ("Unifying Receiver")
|
||||||
|
|
||||||
reply = base.request(receiver, 0xff, b'\x83\xB5', b'\x03')
|
serial, firmware, bootloader = api.get_receiver_info(receiver)
|
||||||
if reply and reply[0:1] == b'\x03':
|
|
||||||
print (" Serial: %s" % hexlify(reply[1:5]))
|
|
||||||
|
|
||||||
reply = base.request(receiver, 0xff, b'\x81\xF1', b'\x01')
|
print (" Serial: %s" % serial)
|
||||||
if reply and reply[0:1] == b'\x01':
|
|
||||||
fw_version = hexlify(reply[1:3])
|
|
||||||
firmware = fw_version[0:2] + '.' + fw_version[2:4]
|
|
||||||
else:
|
|
||||||
firmware = '??.??'
|
|
||||||
|
|
||||||
reply = base.request(receiver, 0xff, b'\x81\xF1', b'\x02')
|
|
||||||
if reply and reply[0:1] == b'\x02':
|
|
||||||
firmware += '.B' + hexlify(reply[1:3])
|
|
||||||
print (" Firmware version: %s" % firmware)
|
print (" Firmware version: %s" % firmware)
|
||||||
|
print (" Bootloader: %s" % bootloader)
|
||||||
reply = base.request(receiver, 0xff, b'\x81\xF1', b'\x04')
|
|
||||||
if reply and reply[0:1] == b'\x04':
|
|
||||||
bl_version = hexlify(reply[1:3])
|
|
||||||
print (" Bootloader: %s.%s" % (bl_version[0:2], bl_version[2:4]))
|
|
||||||
|
|
||||||
print ("--------")
|
print ("--------")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue