rss2i.py: Add a new debug command
There were two new API commands introduced with 92fc2aa6: 0x18: Return device status
and 0x19: Report error information
. A preview of the API doc can be downloaded here. This allows us to add a new debug
command for the RSS2I command line tool that is worthy its name. Note however, that is is necessary to get #12 (closed) done in order for the command name to be available.
Suppose a setup with two devices 3
and 10
. Device 10
is connected via USB. The debug
command should be invoked like e.g.
rss2i -a debug -d 10, 3
and should output something like
rss2i: debug: dev 10: Number of errors: 3
rss2i: debug: dev 10: Main loop cycles: 161
rss2i: debug: dev 10: Raw battery value: 869
rss2i: debug: dev 10: Battery level / %: 100
rss2i: debug: dev 10: Free memory / %: 67
rss2i: debug: dev 10: Occured error cases:
[0x09 0x0001/0x0002] There are two or more measurement results within the same frame and the same cycle.
[0x0d 0x0002/0x0003] Received an unknown instruction via USB.
rss2i: Device 10 --over-the-air--> device 3
rss2i: debug: dev 3: Number of errors: 0
rss2i: debug: dev 3: Main loop cycles: 152
rss2i: debug: dev 3: Raw battery value: 862
rss2i: debug: dev 3: Battery level / %: 100
rss2i: debug: dev 3: Free memory / %: 66
rss2i: debug: dev 3: No errors occured.
where [0x0d 0x0002/0x0003] Received an unknown...
contains the ID of the error case, its specific ID sid
, its global ID gid
and the corresponding error message in that order. For reference:
import rss2ipy
res = device.query([0x19, 3], 255);
if not res[0]:
print("Number of errors: " + str(res[1] + 256 * res[2]));
for ec in range(0, 63):
specificID = res[3 + 4 * ec + 0] + res[3 + 4 * ec + 1];
globalID = res[3 + 4 * ec + 2] + res[3 + 4 * ec + 3];
if localID:
print(" [0x{:02x} 0x{:04x}/0x{:04x}] ".format(ec,
specificID,
globalID)
+ rss2ipy.debug_message(ec));
Note, that the amount of free memory should be displayed, as it is for the (new, #12 (closed)) log
command.
Alos note, that there are blank lines around the error message (if any).