#include "ao.h"
#include "ao_telem.h"
+#include "ao_flight.h"
#if !HAS_MONITOR
#error Must define HAS_MONITOR to 1
#endif
#ifndef HAS_MONITOR_PUT
-#define HAS_MONIOTOR_PUT 1
+#define HAS_MONITOR_PUT 1
#endif
#ifndef AO_MONITOR_LED
size = ao_monitoring;
break;
}
- if (!ao_radio_recv(&ao_monitor_ring[ao_monitor_head], size + 2))
+ if (!ao_radio_recv(&ao_monitor_ring[ao_monitor_head], size + 2, 0))
continue;
ao_monitor_head = ao_monitor_ring_next(ao_monitor_head);
ao_wakeup(DATA_TO_XDATA(&ao_monitor_head));
#if HAS_MONITOR_PUT
+static const char xdigit[16] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+};
+
+#define hex(c) do { putchar(xdigit[(c) >> 4]); putchar(xdigit[(c)&0xf]); } while (0)
+
void
ao_monitor_put(void)
{
ao_sleep(DATA_TO_XDATA(&ao_external_monitoring));
while (ao_monitor_tail == ao_monitor_head && ao_external_monitoring)
ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+ if (!ao_external_monitoring)
+ continue;
m = &ao_monitor_ring[ao_monitor_tail];
ao_monitor_tail = ao_monitor_ring_next(ao_monitor_tail);
switch (ao_monitoring) {
case AO_MONITORING_ORIG:
state = recv_orig.telemetry_orig.flight_state;
- /* Typical RSSI offset for 38.4kBaud at 433 MHz is 74 */
- rssi = (int16_t) (recv_orig.rssi >> 1) - 74;
+ rssi = (int16_t) AO_RSSI_FROM_RADIO(recv_orig.rssi);
ao_xmemcpy(callsign, recv_orig.telemetry_orig.callsign, AO_MAX_CALLSIGN);
if (state > ao_flight_invalid)
state = ao_flight_invalid;
break;
#endif /* LEGACY_MONITOR */
default:
- printf ("TELEM %02x", ao_monitoring + 2);
+#if AO_PROFILE
+ {
+ extern uint32_t ao_rx_start_tick, ao_rx_packet_tick, ao_rx_done_tick, ao_rx_last_done_tick;
+ extern uint32_t ao_fec_decode_start, ao_fec_decode_end;
+
+ printf ("between packet: %d\n", ao_rx_start_tick - ao_rx_last_done_tick);
+ printf ("receive start delay: %d\n", ao_rx_packet_tick - ao_rx_start_tick);
+ printf ("decode time: %d\n", ao_fec_decode_end - ao_fec_decode_start);
+ printf ("rx cleanup: %d\n", ao_rx_done_tick - ao_fec_decode_end);
+ }
+#endif
+ printf("TELEM ");
+ hex((uint8_t) (ao_monitoring + 2));
sum = 0x5a;
for (state = 0; state < ao_monitoring + 2; state++) {
byte = recv_raw.packet[state];
sum += byte;
- printf("%02x", byte);
+ hex(byte);
}
- printf("%02x\n", sum);
+ hex(sum);
+ putchar ('\n');
#if HAS_RSSI
if (recv_raw.packet[ao_monitoring + 1] & PKT_APPEND_STATUS_1_CRC_OK) {
- rssi = ((int16_t) recv_raw.packet[ao_monitoring] >> 1) - 74;
+ rssi = AO_RSSI_FROM_RADIO(recv_raw.packet[ao_monitoring]);
ao_rssi_set(rssi);
}
#endif