Tools: allow to decode devid in hex
This commit is contained in:
parent
34fb98b1e0
commit
e85b37ffc4
@ -9,6 +9,13 @@ the sensor library, such as libraries/AP_Compass/AP_Compass_Backend.h
|
||||
import sys
|
||||
import optparse
|
||||
|
||||
def num(s):
|
||||
try:
|
||||
return int(s)
|
||||
except ValueError:
|
||||
return int(s, 16)
|
||||
|
||||
|
||||
parser = optparse.OptionParser("decode_devid.py")
|
||||
parser.add_option("-C", "--compass", action='store_true', help='decode compass IDs')
|
||||
parser.add_option("-I", "--imu", action='store_true', help='decode IMU IDs')
|
||||
@ -19,7 +26,7 @@ if len(args) == 0:
|
||||
print("Please supply a device ID")
|
||||
sys.exit(1)
|
||||
|
||||
devid=int(args[0])
|
||||
devid=num(args[0])
|
||||
|
||||
bus_type=devid & 0x07
|
||||
bus=(devid>>3) & 0x1F
|
||||
|
Loading…
Reference in New Issue
Block a user