From 55ac480e91787669d098a3a1a1055ded560c2724 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 Apr 2017 17:05:13 +1000 Subject: [PATCH] Tools: added decode_devid.py --- Tools/scripts/decode_devid.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 Tools/scripts/decode_devid.py diff --git a/Tools/scripts/decode_devid.py b/Tools/scripts/decode_devid.py new file mode 100755 index 0000000000..8fd0dc87fd --- /dev/null +++ b/Tools/scripts/decode_devid.py @@ -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)) + + +