|
|
|
@ -23,177 +23,6 @@
@@ -23,177 +23,6 @@
|
|
|
|
|
extern const AP_HAL::HAL& hal; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
read and print a log entry using the format strings from the given structure |
|
|
|
|
*/ |
|
|
|
|
void DataFlash_Backend::_print_log_entry(uint8_t msg_type, |
|
|
|
|
print_mode_fn print_mode, |
|
|
|
|
AP_HAL::BetterStream *port) |
|
|
|
|
{ |
|
|
|
|
uint8_t i; |
|
|
|
|
for (i=0; i<num_types(); i++) { |
|
|
|
|
if (msg_type == structure(i)->msg_type) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (i == num_types()) { |
|
|
|
|
port->printf("UNKN, %u\n", (unsigned)msg_type); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const struct LogStructure *log_structure = structure(i); |
|
|
|
|
uint8_t msg_len = log_structure->msg_len - 3; |
|
|
|
|
uint8_t pkt[msg_len]; |
|
|
|
|
if (!ReadBlock(pkt, msg_len)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
port->printf("%s, ", log_structure->name); |
|
|
|
|
for (uint8_t ofs=0, fmt_ofs=0; ofs<msg_len; fmt_ofs++) { |
|
|
|
|
char fmt = log_structure->format[fmt_ofs]; |
|
|
|
|
switch (fmt) { |
|
|
|
|
case 'b': { |
|
|
|
|
port->printf("%d", (int)pkt[ofs]); |
|
|
|
|
ofs += 1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'B': { |
|
|
|
|
port->printf("%u", (unsigned)pkt[ofs]); |
|
|
|
|
ofs += 1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'h': { |
|
|
|
|
int16_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%d", (int)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'H': { |
|
|
|
|
uint16_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%u", (unsigned)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'i': { |
|
|
|
|
int32_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%ld", (long)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'I': { |
|
|
|
|
uint32_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%lu", (unsigned long)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'q': { |
|
|
|
|
int64_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%lld", (long long)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'Q': { |
|
|
|
|
uint64_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%llu", (unsigned long long)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'f': { |
|
|
|
|
float v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%f", (double)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'd': { |
|
|
|
|
double v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
// note that %f here *really* means a single-precision
|
|
|
|
|
// float, so we lose precision printing this double out
|
|
|
|
|
// dtoa_engine needed....
|
|
|
|
|
port->printf("%f", (double)v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'c': { |
|
|
|
|
int16_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%.2f", (double)(0.01f*v)); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'C': { |
|
|
|
|
uint16_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%.2f", (double)(0.01f*v)); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'e': { |
|
|
|
|
int32_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%.2f", (double)(0.01f*v)); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'E': { |
|
|
|
|
uint32_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
port->printf("%.2f", (double)(0.01f*v)); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'L': { |
|
|
|
|
int32_t v; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
print_latlon(port, v); |
|
|
|
|
ofs += sizeof(v); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'n': { |
|
|
|
|
char v[5]; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
v[sizeof(v)-1] = 0; |
|
|
|
|
port->printf("%s", v); |
|
|
|
|
ofs += sizeof(v)-1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'N': { |
|
|
|
|
char v[17]; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
v[sizeof(v)-1] = 0; |
|
|
|
|
port->printf("%s", v); |
|
|
|
|
ofs += sizeof(v)-1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'Z': { |
|
|
|
|
char v[65]; |
|
|
|
|
memcpy(&v, &pkt[ofs], sizeof(v)); |
|
|
|
|
v[sizeof(v)-1] = 0; |
|
|
|
|
port->printf("%s", v); |
|
|
|
|
ofs += sizeof(v)-1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 'M': { |
|
|
|
|
print_mode(port, pkt[ofs]); |
|
|
|
|
ofs += 1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
ofs = msg_len; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (ofs < msg_len) { |
|
|
|
|
port->printf(", "); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
port->printf("\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
write a structure format to the log - should be in frontend |
|
|
|
|
*/ |
|
|
|
|