Skip to content

Commit

Permalink
elf_sanity.py: Add --list-params
Browse files Browse the repository at this point in the history
This will list parameters with type, in alpabetical order.

```
$ python3 tools/build/elf_sanity.py --list-params cf2.elf
activeMarker.back               PARAM_UINT8
activeMarker.front              PARAM_UINT8
activeMarker.left               PARAM_UINT8
activeMarker.mode               PARAM_UINT8
activeMarker.poll               PARAM_UINT8
activeMarker.right              PARAM_UINT8
cmdrCPPM.angPitch               PARAM_FLOAT
cmdrCPPM.angRoll                PARAM_FLOAT
cmdrCPPM.ratePitch              PARAM_FLOAT
cmdrCPPM.rateRoll               PARAM_FLOAT
cmdrCPPM.rateYaw                PARAM_FLOAT
colAv.bboxMaxX                  PARAM_FLOAT
colAv.bboxMaxY                  PARAM_FLOAT
colAv.bboxMaxZ                  PARAM_FLOAT
colAv.bboxMinX                  PARAM_FLOAT
colAv.bboxMinY                  PARAM_FLOAT
colAv.bboxMinZ                  PARAM_FLOAT
colAv.ellipsoidX                PARAM_FLOAT
colAv.ellipsoidY                PARAM_FLOAT
colAv.ellipsoidZ                PARAM_FLOAT
colAv.enable                    PARAM_UINT8
colAv.horizon                   PARAM_FLOAT
colAv.maxPeerLocAge             PARAM_INT32
colAv.maxSpeed                  PARAM_FLOAT
colAv.sidestepThrsh             PARAM_FLOAT
colAv.vorIters                  PARAM_INT32
colAv.vorTol                    PARAM_FLOAT
commander.enHighLevel           PARAM_UINT8
controller.tiltComp             PARAM_UINT8
cpu.flash                       PARAM_UIN16 | PARAM_RONLY
cpu.id0                         PARAM_UINT32 | PARAM_RONLY
cpu.id1                         PARAM_UINT32 | PARAM_RONLY
cpu.id2                         PARAM_UINT32 | PARAM_RONLY
crtpsrv.echoDelay               PARAM_UIN16
ctrlINDI.act_dyn_p              PARAM_FLOAT
ctrlINDI.act_dyn_q              PARAM_FLOAT
ctrlINDI.act_dyn_r              PARAM_FLOAT
ctrlINDI.bound_ctrl_input       PARAM_FLOAT
ctrlINDI.filt_cutoff            PARAM_FLOAT
ctrlINDI.filt_cutoff_r          PARAM_FLOAT
ctrlINDI.g1_p                   PARAM_FLOAT
ctrlINDI.g1_q                   PARAM_FLOAT
ctrlINDI.g1_r                   PARAM_FLOAT
ctrlINDI.g2                     PARAM_FLOAT
ctrlINDI.outerLoopActive        PARAM_UINT8
ctrlINDI.pitch_kp               PARAM_FLOAT
ctrlINDI.ref_err_p              PARAM_FLOAT
ctrlINDI.ref_err_q              PARAM_FLOAT
ctrlINDI.ref_err_r              PARAM_FLOAT
ctrlINDI.ref_rate_p             PARAM_FLOAT
ctrlINDI.ref_rate_q             PARAM_FLOAT
ctrlINDI.ref_rate_r             PARAM_FLOAT
ctrlINDI.roll_kp                PARAM_FLOAT
ctrlINDI.thrust_threshold       PARAM_FLOAT
ctrlINDI.yaw_kp                 PARAM_FLOAT
ctrlMel.i_range_m_xy            PARAM_FLOAT
ctrlMel.i_range_m_z             PARAM_FLOAT
ctrlMel.i_range_xy              PARAM_FLOAT
ctrlMel.i_range_z               PARAM_FLOAT
ctrlMel.kR_xy                   PARAM_FLOAT
ctrlMel.kR_z                    PARAM_FLOAT
ctrlMel.kd_omega_rp             PARAM_FLOAT
ctrlMel.kd_xy                   PARAM_FLOAT
ctrlMel.kd_z                    PARAM_FLOAT
ctrlMel.ki_m_xy                 PARAM_FLOAT
ctrlMel.ki_m_z                  PARAM_FLOAT
ctrlMel.ki_xy                   PARAM_FLOAT
ctrlMel.ki_z                    PARAM_FLOAT
ctrlMel.kp_xy                   PARAM_FLOAT
ctrlMel.kp_z                    PARAM_FLOAT
ctrlMel.kw_xy                   PARAM_FLOAT
ctrlMel.kw_z                    PARAM_FLOAT
ctrlMel.mass                    PARAM_FLOAT
ctrlMel.massThrust              PARAM_FLOAT
deck.bcAIDeck                   PARAM_UINT8 | PARAM_RONLY
deck.bcBuzzer                   PARAM_UINT8 | PARAM_RONLY
deck.bcCPPM                     PARAM_UINT8 | PARAM_RONLY
deck.bcDWM1000                  PARAM_UINT8 | PARAM_RONLY
deck.bcFlow                     PARAM_UINT8 | PARAM_RONLY
deck.bcFlow2                    PARAM_UINT8 | PARAM_RONLY
deck.bcGTGPS                    PARAM_UINT8 | PARAM_RONLY
deck.bcLedRing                  PARAM_UINT8 | PARAM_RONLY
deck.bcLighthouse4              PARAM_UINT8 | PARAM_RONLY
deck.bcMultiranger              PARAM_UINT8 | PARAM_RONLY
deck.bcOA                       PARAM_UINT8 | PARAM_RONLY
deck.bcUSD                      PARAM_UINT8 | PARAM_RONLY
deck.bcZRanger                  PARAM_UINT8 | PARAM_RONLY
deck.bcZRanger2                 PARAM_UINT8 | PARAM_RONLY
firmware.modified               PARAM_UINT8 | PARAM_RONLY
firmware.revision0              PARAM_UINT32 | PARAM_RONLY
firmware.revision1              PARAM_UIN16 | PARAM_RONLY
flightmode.althold              PARAM_UINT8
flightmode.posSet               PARAM_UINT8
flightmode.poshold              PARAM_UINT8
flightmode.stabModePitch        PARAM_UINT8
flightmode.stabModeRoll         PARAM_UINT8
flightmode.stabModeYaw          PARAM_UINT8
flightmode.yawMode              PARAM_UINT8
flightmode.yawRst               PARAM_UINT8
health.startBatTest             PARAM_UINT8
health.startPropTest            PARAM_UINT8
hlCommander.vland               PARAM_FLOAT
hlCommander.vtoff               PARAM_FLOAT
imu_sensors.BMP388              PARAM_UINT8 | PARAM_RONLY
imu_sensors.HMC5883L            PARAM_UINT8 | PARAM_RONLY
imu_sensors.MS5611              PARAM_UINT8 | PARAM_RONLY
imu_tests.HMC5883L              PARAM_UINT8 | PARAM_RONLY
imu_tests.MPU6500               PARAM_UINT8 | PARAM_RONLY
imu_tests.MS5611                PARAM_UINT8 | PARAM_RONLY
kalman.initialX                 PARAM_FLOAT
kalman.initialY                 PARAM_FLOAT
kalman.initialYaw               PARAM_FLOAT
kalman.initialZ                 PARAM_FLOAT
kalman.mNBaro                   PARAM_FLOAT
kalman.mNGyro_rollpitch         PARAM_FLOAT
kalman.mNGyro_yaw               PARAM_FLOAT
kalman.maxPos                   PARAM_FLOAT
kalman.maxVel                   PARAM_FLOAT
kalman.pNAcc_xy                 PARAM_FLOAT
kalman.pNAcc_z                  PARAM_FLOAT
kalman.pNAtt                    PARAM_FLOAT
kalman.pNPos                    PARAM_FLOAT
kalman.pNVel                    PARAM_FLOAT
kalman.quadIsFlying             PARAM_UINT8
kalman.resetEstimation          PARAM_UINT8
kalman.robustTdoa               PARAM_UINT8
kalman.robustTwr                PARAM_UINT8
lighthouse.bsCalibReset         PARAM_UINT8
lighthouse.method               PARAM_UINT8
lighthouse.sweepStd             PARAM_FLOAT
lighthouse.sweepStd2            PARAM_FLOAT
lighthouse.systemType           PARAM_UINT8
locSrv.enLhAngleStream          PARAM_UINT8
locSrv.enRangeStreamFP32        PARAM_UINT8
locSrv.extPosStdDev             PARAM_FLOAT
locSrv.extQuatStdDev            PARAM_FLOAT
loco.mode                       PARAM_UINT8
memTst.resetW                   PARAM_UINT8
motion.adaptive                 PARAM_UINT8
motion.disable                  PARAM_UINT8
motion.flowStdFixed             PARAM_FLOAT
motorPowerSet.enable            PARAM_UINT8
motorPowerSet.m1                PARAM_UIN16
motorPowerSet.m2                PARAM_UIN16
motorPowerSet.m3                PARAM_UIN16
motorPowerSet.m4                PARAM_UIN16
pid_attitude.pitch_kd           PARAM_FLOAT
pid_attitude.pitch_ki           PARAM_FLOAT
pid_attitude.pitch_kp           PARAM_FLOAT
pid_attitude.roll_kd            PARAM_FLOAT
pid_attitude.roll_ki            PARAM_FLOAT
pid_attitude.roll_kp            PARAM_FLOAT
pid_attitude.yaw_kd             PARAM_FLOAT
pid_attitude.yaw_ki             PARAM_FLOAT
pid_attitude.yaw_kp             PARAM_FLOAT
pid_rate.pitch_kd               PARAM_FLOAT
pid_rate.pitch_ki               PARAM_FLOAT
pid_rate.pitch_kp               PARAM_FLOAT
pid_rate.roll_kd                PARAM_FLOAT
pid_rate.roll_ki                PARAM_FLOAT
pid_rate.roll_kp                PARAM_FLOAT
pid_rate.yaw_kd                 PARAM_FLOAT
pid_rate.yaw_ki                 PARAM_FLOAT
pid_rate.yaw_kp                 PARAM_FLOAT
posCtlPid.rpLimit               PARAM_FLOAT
posCtlPid.thrustBase            PARAM_UIN16
posCtlPid.thrustMin             PARAM_UIN16
posCtlPid.xKd                   PARAM_FLOAT
posCtlPid.xKi                   PARAM_FLOAT
posCtlPid.xKp                   PARAM_FLOAT
posCtlPid.xyVelMax              PARAM_FLOAT
posCtlPid.yKd                   PARAM_FLOAT
posCtlPid.yKi                   PARAM_FLOAT
posCtlPid.yKp                   PARAM_FLOAT
posCtlPid.zKd                   PARAM_FLOAT
posCtlPid.zKi                   PARAM_FLOAT
posCtlPid.zKp                   PARAM_FLOAT
posCtlPid.zVelMax               PARAM_FLOAT
posCtrlIndi.K_dxi_x             PARAM_FLOAT
posCtrlIndi.K_dxi_y             PARAM_FLOAT
posCtrlIndi.K_dxi_z             PARAM_FLOAT
posCtrlIndi.K_xi_x              PARAM_FLOAT
posCtrlIndi.K_xi_y              PARAM_FLOAT
posCtrlIndi.K_xi_z              PARAM_FLOAT
posEstAlt.estAlphaAsl           PARAM_FLOAT
posEstAlt.estAlphaZr            PARAM_FLOAT
posEstAlt.vAccDeadband          PARAM_FLOAT
posEstAlt.velFactor             PARAM_FLOAT
posEstAlt.velZAlpha             PARAM_FLOAT
powerDist.idleThrust            PARAM_UINT32
ring.effect                     PARAM_UINT8
ring.emptyCharge                PARAM_FLOAT
ring.fadeColor                  PARAM_UINT32
ring.fadeTime                   PARAM_FLOAT
ring.fullCharge                 PARAM_FLOAT
ring.glowstep                   PARAM_FLOAT
ring.headlightEnable            PARAM_UINT8
ring.neffect                    PARAM_UINT32 | PARAM_RONLY
ring.solidBlue                  PARAM_UINT8
ring.solidGreen                 PARAM_UINT8
ring.solidRed                   PARAM_UINT8
sensfusion6.baseZacc            PARAM_FLOAT
sensfusion6.ki                  PARAM_FLOAT
sensfusion6.kp                  PARAM_FLOAT
sound.effect                    PARAM_UINT8
sound.freq                      PARAM_UIN16
sound.neffect                   PARAM_UINT32 | PARAM_RONLY
sound.ratio                     PARAM_UINT8
stabilizer.controller           PARAM_UINT8
stabilizer.estimator            PARAM_UINT8
stabilizer.stop                 PARAM_UINT8
system.forceArm                 PARAM_INT8
system.highlight                PARAM_UINT8
system.selftestPassed           PARAM_INT8 | PARAM_RONLY
system.taskDump                 PARAM_UINT8
tdoaEngine.logId                PARAM_UINT8
tdoaEngine.logOthrId            PARAM_UINT8
tdoaEngine.matchAlgo            PARAM_UINT8
usd.canLog                      PARAM_UINT8 | PARAM_RONLY
usd.logging                     PARAM_UINT8
velCtlPid.vxKd                  PARAM_FLOAT
velCtlPid.vxKi                  PARAM_FLOAT
velCtlPid.vxKp                  PARAM_FLOAT
velCtlPid.vyKd                  PARAM_FLOAT
velCtlPid.vyKi                  PARAM_FLOAT
velCtlPid.vyKp                  PARAM_FLOAT
velCtlPid.vzKd                  PARAM_FLOAT
velCtlPid.vzKi                  PARAM_FLOAT
velCtlPid.vzKp                  PARAM_FLOAT
```
  • Loading branch information
jonasdn committed Apr 29, 2021
1 parent cbb68d2 commit 9399192
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions tools/build/elf_sanity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import struct
import sys

Expand All @@ -9,6 +10,27 @@
PARAM_GROUP = 0x1 << 7
PARAM_START = 0x1

parameters = {}


param_type_to_str_dict = {
0x0 | 0x0 << 2 | 0x1 << 3: 'PARAM_UINT8',
0x0 | 0x0 << 2 | 0x0 << 3: 'PARAM_INT8',
0x1 | 0x0 << 2 | 0x1 << 3: 'PARAM_UIN16',
0x1 | 0x0 << 2 | 0x0 << 3: 'PARAM_INT16',
0x2 | 0x0 << 2 | 0x1 << 3: 'PARAM_UINT32',
0x2 | 0x0 << 2 | 0x0 << 3: 'PARAM_INT32',
0x2 | 0x1 << 2 | 0x0 << 3: 'PARAM_FLOAT'
}


def param_type_to_str(t: int) -> str:
read_only = str()
if t & (1 << 6): # PARAM_RONLY set
read_only = ' | PARAM_RONLY'

return '{:12}{}'.format(param_type_to_str_dict[t & ~(1 << 6)], read_only)


def process_file(filename):
with open(filename, 'rb') as f:
Expand Down Expand Up @@ -44,8 +66,6 @@ def check_params(stream):
offset = get_offset_of_symbol(elf, '_param_start')
stop_offset = get_offset_of_symbol(elf, '_param_stop')

parameters = {}

while offset < stop_offset:
elf.stream.seek(offset)
#
Expand Down Expand Up @@ -80,7 +100,7 @@ def check_params(stream):
print('duplicate parameter detected: %s' % name)
sys.exit(1)
else:
parameters[name] = name
parameters[name] = t

if len(name) > PARAM_NAME_MAXLEN:
print('name of param to long (%s > %d)' %
Expand All @@ -91,7 +111,14 @@ def check_params(stream):


if __name__ == '__main__':
if len(sys.argv) > 1:
process_file(sys.argv[1])
parser = argparse.ArgumentParser()
parser.add_argument('--list-params', action='store_true')
parser.add_argument('filename', nargs=argparse.REMAINDER)
args = parser.parse_args()

if args.filename:
process_file(args.filename[0])
for key in sorted(parameters.keys()):
print('{:25}\t{}'.format(key, param_type_to_str(parameters[key])))
else:
sys.exit(1)

0 comments on commit 9399192

Please sign in to comment.