From da66ecf1f22e99e3eec5ad32209d5dcfb8edef35 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 25 Sep 2021 15:21:43 +1000 Subject: [PATCH] AP_GPS: move SBP logging structures into AP_GPS --- libraries/AP_GPS/LogStructure.h | 7 ++- libraries/AP_GPS/LogStructure_SBP.h | 79 +++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 libraries/AP_GPS/LogStructure_SBP.h diff --git a/libraries/AP_GPS/LogStructure.h b/libraries/AP_GPS/LogStructure.h index 8d8fb0f44a..9dedef16b4 100644 --- a/libraries/AP_GPS/LogStructure.h +++ b/libraries/AP_GPS/LogStructure.h @@ -1,6 +1,7 @@ #pragma once #include +#include "LogStructure_SBP.h" #define LOG_IDS_FROM_GPS \ LOG_GPS_MSG, \ @@ -9,7 +10,8 @@ LOG_GPS_RAWH_MSG, \ LOG_GPS_RAWS_MSG, \ LOG_GPS_UBX1_MSG, \ - LOG_GPS_UBX2_MSG + LOG_GPS_UBX2_MSG, \ + LOG_IDS_FROM_GPS_SBP // @LoggerMessage: GPS @@ -208,4 +210,5 @@ struct PACKED log_GPS_RAWS { { LOG_GPS_RAWH_MSG, sizeof(log_GPS_RAWH), \ "GRXH", "QdHbBB", "TimeUS,rcvTime,week,leapS,numMeas,recStat", "s-----", "F-----" , true }, \ { LOG_GPS_RAWS_MSG, sizeof(log_GPS_RAWS), \ - "GRXS", "QddfBBBHBBBBB", "TimeUS,prMes,cpMes,doMes,gnss,sv,freq,lock,cno,prD,cpD,doD,trk", "s------------", "F------------" , true }, + "GRXS", "QddfBBBHBBBBB", "TimeUS,prMes,cpMes,doMes,gnss,sv,freq,lock,cno,prD,cpD,doD,trk", "s------------", "F------------" , true }, \ + LOG_STRUCTURE_FROM_GPS_SBP, diff --git a/libraries/AP_GPS/LogStructure_SBP.h b/libraries/AP_GPS/LogStructure_SBP.h new file mode 100644 index 0000000000..1de9cf3449 --- /dev/null +++ b/libraries/AP_GPS/LogStructure_SBP.h @@ -0,0 +1,79 @@ +#pragma once + +#include + +#define LOG_IDS_FROM_GPS_SBP \ + LOG_MSG_SBPHEALTH, \ + LOG_MSG_SBPRAWH, \ + LOG_MSG_SBPRAWM, \ + LOG_MSG_SBPEVENT + +// @LoggerMessage: SBPH +// @Description: Swift Health Data +// @Field: TimeUS: Time since system startup +// @Field: CrcError: Number of packet CRC errors on serial connection +// @Field: LastInject: Timestamp of last raw data injection to GPS +// @Field: IARhyp: Current number of integer ambiguity hypotheses + +struct PACKED log_SbpHealth { + LOG_PACKET_HEADER; + uint64_t time_us; + uint32_t crc_error_counter; + uint32_t last_injected_data_ms; + uint32_t last_iar_num_hypotheses; +}; + +// @LoggerMessage: SBRH +// @Description: Swift Raw Message Data +// @Field: TimeUS: Time since system startup +// @Field: msg_flag: Swift message type +// @Field: 1: Sender ID +// @Field: 2: index; always 1 +// @Field: 3: pages; number of pages received +// @Field: 4: msg length; number of bytes received +// @Field: 5: unused; always zero +// @Field: 6: data received from device + +struct PACKED log_SbpRAWH { + LOG_PACKET_HEADER; + uint64_t time_us; + uint16_t msg_type; + uint16_t sender_id; + uint8_t index; + uint8_t pages; + uint8_t msg_len; + uint8_t res; + uint8_t data[48]; +}; + +struct PACKED log_SbpRAWM { + LOG_PACKET_HEADER; + uint64_t time_us; + uint16_t msg_type; + uint16_t sender_id; + uint8_t index; + uint8_t pages; + uint8_t msg_len; + uint8_t res; + uint8_t data[104]; +}; + +struct PACKED log_SbpEvent { + LOG_PACKET_HEADER; + uint64_t time_us; + uint16_t wn; + uint32_t tow; + int32_t ns_residual; + uint8_t level; + uint8_t quality; +}; + +#define LOG_STRUCTURE_FROM_GPS_SBP \ + { LOG_MSG_SBPHEALTH, sizeof(log_SbpHealth), \ + "SBPH", "QIII", "TimeUS,CrcError,LastInject,IARhyp", "s---", "F---" , true }, \ + { LOG_MSG_SBPRAWH, sizeof(log_SbpRAWH), \ + "SBRH", "QQQQQQQQ", "TimeUS,msg_flag,1,2,3,4,5,6", "s--b----", "F--0----" , true }, \ + { LOG_MSG_SBPRAWM, sizeof(log_SbpRAWM), \ + "SBRM", "QQQQQQQQQQQQQQQ", "TimeUS,msg_flag,1,2,3,4,5,6,7,8,9,10,11,12,13", "s??????????????", "F??????????????" , true }, \ + { LOG_MSG_SBPEVENT, sizeof(log_SbpEvent), \ + "SBRE", "QHIiBB", "TimeUS,GWk,GMS,ns_residual,level,quality", "s?????", "F?????" }