*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
#define AO_TELEMETRY_SENSOR_TELEMETRUM 0x01
#define AO_TELEMETRY_SENSOR_TELEMINI 0x02
#define AO_TELEMETRY_SENSOR_TELENANO 0x03
-#define AO_TELEMETRY_SENSOR_MEGAMETRUM 0x08
struct ao_telemetry_sensor {
uint16_t serial; /* 0 */
/* 32 */
};
+#define AO_TELEMETRY_MEGA_SENSOR 0x08
+
+struct ao_telemetry_mega_sensor {
+ uint16_t serial; /* 0 */
+ uint16_t tick; /* 2 */
+ uint8_t type; /* 4 */
+
+ uint8_t orient; /* 5 angle from vertical */
+ int16_t accel; /* 6 Z axis */
+
+ int32_t pres; /* 8 Pa * 10 */
+ int16_t temp; /* 12 °C * 100 */
+
+ int16_t accel_x; /* 14 */
+ int16_t accel_y; /* 16 */
+ int16_t accel_z; /* 18 */
+
+ int16_t gyro_x; /* 20 */
+ int16_t gyro_y; /* 22 */
+ int16_t gyro_z; /* 24 */
+
+ int16_t mag_x; /* 26 */
+ int16_t mag_y; /* 28 */
+ int16_t mag_z; /* 30 */
+ /* 32 */
+};
+
+#define AO_TELEMETRY_MEGA_DATA 0x09
+
+struct ao_telemetry_mega_data {
+ uint16_t serial; /* 0 */
+ uint16_t tick; /* 2 */
+ uint8_t type; /* 4 */
+
+ uint8_t state; /* 5 flight state */
+
+ int16_t v_batt; /* 6 battery voltage */
+ int16_t v_pyro; /* 8 pyro battery voltage */
+ int8_t sense[6]; /* 10 continuity sense */
+
+ int32_t ground_pres; /* 16 average pres on pad */
+ int16_t ground_accel; /* 20 average accel on pad */
+ int16_t accel_plus_g; /* 22 accel calibration at +1g */
+ int16_t accel_minus_g; /* 24 accel calibration at -1g */
+
+ int16_t acceleration; /* 26 m/s² * 16 */
+ int16_t speed; /* 28 m/s * 16 */
+ int16_t height; /* 30 m */
+ /* 32 */
+};
+
+#define AO_TELEMETRY_METRUM_SENSOR 0x0A
+
+struct ao_telemetry_metrum_sensor {
+ uint16_t serial; /* 0 */
+ uint16_t tick; /* 2 */
+ uint8_t type; /* 4 */
+
+ uint8_t state; /* 5 flight state */
+ int16_t accel; /* 6 Z axis */
+
+ int32_t pres; /* 8 Pa * 10 */
+ int16_t temp; /* 12 °C * 100 */
+
+ int16_t acceleration; /* 14 m/s² * 16 */
+ int16_t speed; /* 16 m/s * 16 */
+ int16_t height; /* 18 m */
+
+ int16_t v_batt; /* 20 battery voltage */
+ int16_t sense_a; /* 22 apogee continuity sense */
+ int16_t sense_m; /* 24 main continuity sense */
+
+ uint8_t pad[6]; /* 26 */
+ /* 32 */
+};
+
+#define AO_TELEMETRY_METRUM_DATA 0x0B
+
+struct ao_telemetry_metrum_data {
+ uint16_t serial; /* 0 */
+ uint16_t tick; /* 2 */
+ uint8_t type; /* 4 */
+
+ int32_t ground_pres; /* 8 average pres on pad */
+ int16_t ground_accel; /* 12 average accel on pad */
+ int16_t accel_plus_g; /* 14 accel calibration at +1g */
+ int16_t accel_minus_g; /* 16 accel calibration at -1g */
+
+ uint8_t pad[14]; /* 18 */
+ /* 32 */
+};
+
+#define AO_TELEMETRY_MINI 0x10
+
+struct ao_telemetry_mini {
+ uint16_t serial; /* 0 */
+ uint16_t tick; /* 2 */
+ uint8_t type; /* 4 */
+
+ uint8_t state; /* 5 flight state */
+ int16_t v_batt; /* 6 battery voltage */
+ int16_t sense_a; /* 8 apogee continuity */
+ int16_t sense_m; /* 10 main continuity */
+
+ int32_t pres; /* 12 Pa * 10 */
+ int16_t temp; /* 16 °C * 100 */
+
+ int16_t acceleration; /* 18 m/s² * 16 */
+ int16_t speed; /* 20 m/s * 16 */
+ int16_t height; /* 22 m */
+
+ int32_t ground_pres; /* 24 average pres on pad */
+
+ int32_t pad28; /* 28 */
+ /* 32 */
+};
+
/* #define AO_SEND_ALL_BARO */
#define AO_TELEMETRY_BARO 0x80
struct ao_telemetry_location location;
struct ao_telemetry_satellite satellite;
struct ao_telemetry_companion companion;
+ struct ao_telemetry_mega_sensor mega_sensor;
+ struct ao_telemetry_mega_data mega_data;
+ struct ao_telemetry_metrum_sensor metrum_sensor;
+ struct ao_telemetry_metrum_data metrum_data;
+ struct ao_telemetry_mini mini;
struct ao_telemetry_baro baro;
};
+#define CC_TELEMETRY_HEADER "TELEM"
+
+/* "TELEM " 1 byte length 32 data bytes 1 rssi 1 status 1 checksum 1 null */
+
+#define CC_TELEMETRY_BUFSIZE (6 + (1 + 32 + 3) * 2 + 1)
+
int
cc_telemetry_parse(const char *input_line, union ao_telemetry_all *telemetry);
+uint8_t
+cc_telemetry_cksum(const union ao_telemetry_all *telemetry);
+
+void
+cc_telemetry_unparse(const union ao_telemetry_all *telemetry, char output_line[CC_TELEMETRY_BUFSIZE]);
+
#endif