Compare commits

..

No commits in common. "2f33421956eab73e4bb90484dc75b17324c973f9" and "2a12aac86fe30e06d36b4560ff416d949d73a1b4" have entirely different histories.

3 changed files with 330 additions and 774 deletions

View File

@ -7,7 +7,6 @@ static volatile uint8_t cdc_port_open = 0; /* set when host asserts DTR */
volatile uint8_t cdc_arm_request = 0; /* set by A command */ volatile uint8_t cdc_arm_request = 0; /* set by A command */
volatile uint8_t cdc_disarm_request = 0; /* set by D command */ volatile uint8_t cdc_disarm_request = 0; /* set by D command */
volatile uint8_t cdc_recal_request = 0; /* set by G command — gyro recalibration */ volatile uint8_t cdc_recal_request = 0; /* set by G command — gyro recalibration */
volatile uint32_t cdc_rx_count = 0; /* total CDC packets received from host */
/* /*
* PID tuning command buffer. * PID tuning command buffer.
@ -175,7 +174,6 @@ static int8_t CDC_Receive(uint8_t *buf, uint32_t *len) {
} }
done: done:
cdc_rx_count++;
USBD_CDC_SetRxBuffer(&hUsbDevice, UserRxBuffer); USBD_CDC_SetRxBuffer(&hUsbDevice, UserRxBuffer);
USBD_CDC_ReceivePacket(&hUsbDevice); USBD_CDC_ReceivePacket(&hUsbDevice);
return USBD_OK; return USBD_OK;

View File

@ -24,7 +24,6 @@ extern volatile uint8_t cdc_streaming; /* set by S command in CDC RX */
extern volatile uint8_t cdc_arm_request; /* set by A command */ extern volatile uint8_t cdc_arm_request; /* set by A command */
extern volatile uint8_t cdc_disarm_request; /* set by D command */ extern volatile uint8_t cdc_disarm_request; /* set by D command */
extern volatile uint8_t cdc_recal_request; /* set by G command */ extern volatile uint8_t cdc_recal_request; /* set by G command */
extern volatile uint32_t cdc_rx_count; /* total CDC packets received */
/* /*
* Apply a PID tuning command string from the USB terminal. * Apply a PID tuning command string from the USB terminal.
@ -157,9 +156,8 @@ int main(void) {
*/ */
safety_init(); safety_init();
char buf[320]; char buf[256];
int len; int len;
uint32_t tx_count = 0; /* telemetry frames sent to host */
IMUData imu; IMUData imu;
uint32_t send_tick = 0; uint32_t send_tick = 0;
@ -342,27 +340,17 @@ int main(void) {
} }
} }
if (safety_rc_alive(now)) { if (safety_rc_alive(now)) {
/* RSSI, link quality, and CH1CH4 mapped to µs (10002000) */ /* RSSI in dBm (negative), link quality 0-100% */
n = snprintf(p, rem, ",\"rssi\":%d,\"lq\":%d" n = snprintf(p, rem, ",\"rssi\":%d,\"lq\":%d",
",\"ch1\":%d,\"ch2\":%d,\"ch3\":%d,\"ch4\":%d", (int)crsf_state.rssi_dbm, (int)crsf_state.link_quality);
(int)crsf_state.rssi_dbm, (int)crsf_state.link_quality,
(int)crsf_to_range(crsf_state.channels[0], 1000, 2000),
(int)crsf_to_range(crsf_state.channels[1], 1000, 2000),
(int)crsf_to_range(crsf_state.channels[2], 1000, 2000),
(int)crsf_to_range(crsf_state.channels[3], 1000, 2000));
p += n; rem -= n; p += n; rem -= n;
} }
/* Jetson active flag, USB TX/RX packet counters */ n = snprintf(p, rem, "}\n");
n = snprintf(p, rem, ",\"ja\":%d,\"txc\":%u,\"rxc\":%u}\n",
jetson_cmd_is_active(now) ? 1 : 0,
(unsigned)tx_count,
(unsigned)cdc_rx_count);
len = (int)(p + n - buf); len = (int)(p + n - buf);
} else { } else {
len = snprintf(buf, sizeof(buf), "{\"err\":%d}\n", imu_ret); len = snprintf(buf, sizeof(buf), "{\"err\":%d}\n", imu_ret);
} }
CDC_Transmit((uint8_t *)buf, len); CDC_Transmit((uint8_t *)buf, len);
tx_count++;
} }
status_update(now, (imu_ret == 0), status_update(now, (imu_ret == 0),

File diff suppressed because it is too large Load Diff