Tools: added decode_devid.py

This commit is contained in:
Andrew Tridgell 2017-04-28 17:05:13 +10:00 committed by Randy Mackay
parent 8ead9d6b19
commit 55ac480e91
1 changed files with 22 additions and 0 deletions

22
Tools/scripts/decode_devid.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
'''
decode a device ID, such as used for COMPASS_DEV_ID, INS_ACC_ID etc
To understand the devtype you should look at the backend headers for
the sensor library, such as libraries/AP_Compass/AP_Compass_Backend.h
'''
import sys
devid=int(sys.argv[1])
bus_type=devid & 0x07
bus=(devid>>3) & 0x1F
address=(devid>>8)&0xFF
devtype=(devid>>16)
print("bus_type:%u bus:%u address:%u devtype:%u(0x%x)" % (
bus_type, bus, address, devtype, devtype))