From 083464b52c835c09a66c06a87246fcd138748a5d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 9 Apr 2022 22:38:28 -0700 Subject: [PATCH] ao-eeprom: Add EasyMotor decode Signed-off-by: Keith Packard --- ao-tools/ao-eeprom/ao-eeprom.c | 50 +++++++++++++++++++++++++++++++++- ao-tools/lib/ao-eeprom-read.h | 32 ++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/ao-tools/ao-eeprom/ao-eeprom.c b/ao-tools/ao-eeprom/ao-eeprom.c index 90055d78..780badbe 100644 --- a/ao-tools/ao-eeprom/ao-eeprom.c +++ b/ao-tools/ao-eeprom/ao-eeprom.c @@ -353,7 +353,6 @@ main (int argc, char **argv) break; case AO_LOG_FORMAT_TELEMEGA_4: len = 32; - break; max_adc= 4095; adc_ref = 3.3; batt_r1 = 5600; @@ -361,6 +360,15 @@ main (int argc, char **argv) sense_r1 = 100e3; sense_r2 = 27e3; break; + case AO_LOG_FORMAT_EASYMOTOR: + len = 16; + max_adc = 32767; + adc_ref = 3.3; + batt_r1 = 5600; + batt_r2 = 10000; + sense_r1 = 5600; + sense_r2 = 10000; + break; } if (arg_len) len = arg_len; @@ -385,6 +393,7 @@ main (int argc, char **argv) struct ao_log_metrum *log_metrum; struct ao_log_gps *log_gps; struct ao_log_firetwo *log_firetwo; + struct ao_log_motor *log_motor; if (!csum && !ao_csum_valid(&eeprom->data[pos], len)) { if (verbose) @@ -674,6 +683,45 @@ main (int argc, char **argv) break; } break; + case AO_LOG_FORMAT_EASYMOTOR: + log_motor = (struct ao_log_motor *) &eeprom->data[pos]; + switch (log_motor->type) { + case AO_LOG_FLIGHT: + printf(" serial %5u flight %5u ground_accel %6d", + eeprom->serial_number, + log_motor->u.flight.flight, + log_motor->u.flight.ground_accel); + printf(" along %6d aross %6d through %6d", + log_motor->u.flight.ground_accel_along, + log_motor->u.flight.ground_accel_across, + log_motor->u.flight.ground_accel_through); + ao_volts("ground pressure", + log_motor->u.flight.ground_motor_pressure, + max_adc, adc_ref, + sense_r1, sense_r2); + break; + case AO_LOG_STATE: + ao_state(log_motor->u.state.state, + log_motor->u.state.reason); + break; + case AO_LOG_SENSOR: + ao_volts("pressure", + log_motor->u.sensor.pressure, + max_adc, adc_ref, + sense_r1, sense_r2); + ao_volts("v_batt", + log_motor->u.sensor.v_batt, + max_adc, + adc_ref, batt_r1, batt_r2); + printf(" accel %6d", + log_motor->u.sensor.accel); + printf(" along %6d aross %6d through %6d", + log_motor->u.sensor.accel_along, + log_motor->u.sensor.accel_across, + log_motor->u.sensor.accel_through); + break; + } + break; case AO_LOG_FORMAT_DETHERM: break; } diff --git a/ao-tools/lib/ao-eeprom-read.h b/ao-tools/lib/ao-eeprom-read.h index e4a9b0cc..aaf6d3d6 100644 --- a/ao-tools/lib/ao-eeprom-read.h +++ b/ao-tools/lib/ao-eeprom-read.h @@ -45,6 +45,7 @@ #define AO_LOG_FORMAT_TELESTATIC 17 /* 32 byte typed telestatic records */ #define AO_LOG_FORMAT_MICROPEAK2 18 /* 2-byte baro values with header */ #define AO_LOG_FORMAT_TELEMEGA_4 19 /* 32 byte typed telemega records with 32 bit gyro cal and Bmx160 */ +#define AO_LOG_FORMAT_EASYMOTOR 20 /* 16 byte typed easymotor records */ #define AO_LOG_FORMAT_NONE 127 /* No log at all */ enum ao_pyro_flag { @@ -465,6 +466,37 @@ struct ao_log_mini { } u; /* 16 */ }; /* 16 */ +struct ao_log_motor { + char type; /* 0 */ + uint8_t csum; /* 1 */ + uint16_t tick; /* 2 */ + union { /* 4 */ + /* AO_LOG_FLIGHT */ + struct { + uint16_t flight; /* 4 */ + int16_t ground_accel; /* 6 */ + int16_t ground_accel_along; /* 8 */ + int16_t ground_accel_across; /* 10 */ + int16_t ground_accel_through; /* 12 */ + int16_t ground_motor_pressure; /* 14 */ + } flight; /* 16 */ + /* AO_LOG_STATE */ + struct { + uint16_t state; /* 4 */ + uint16_t reason; /* 6 */ + } state; + /* AO_LOG_SENSOR */ + struct { + uint16_t pressure; /* 4 */ + uint16_t v_batt; /* 6 */ + int16_t accel; /* 8 */ + int16_t accel_across; /* 10 */ + int16_t accel_along; /* 12 */ + int16_t accel_through; /* 14 */ + } sensor; /* 16 */ + } u; +}; + #define ao_log_pack24(dst,value) do { \ (dst)[0] = (value); \ (dst)[1] = (value) >> 8; \ -- 2.30.2