Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the source code of this file.
Data Structures | |
struct | rtcm3_msg_callbacks_node |
RTCM3 callback node. More... | |
struct | msg_state_t |
Macros | |
#define | READ_RESERVED 1 |
#define | READ_LENGTH 2 |
#define | READ_MESSAGE 3 |
#define | READ_CHECKSUM 4 |
#define | RTCM3_PREAMBLE 0xD3 |
#define | RTCM3_MSG_1005 0x69 |
#define | RTCM3_MSG_4072 0x72 |
#define | RTCM3_MSG_1077 0xB1 |
#define | RTCM3_MSG_1087 0xBB |
#define | RTCM3_MSG_1230 0xE6 |
#define | UNINIT 0 |
#define | GOT_SYNC1 1 |
#define | GOT_SYNC2 2 |
#define | GOT_CLASS 3 |
#define | GOT_ID 4 |
#define | GOT_LEN1 5 |
#define | GOT_LEN2 6 |
#define | GOT_PAYLOAD 7 |
#define | GOT_CHECKSUM1 8 |
#define | UBX_PREAMBLE1 0xB5 |
#define | UBX_PREAMBLE2 0x62 |
#define | UBX_NAV_SVIN 0x3B |
#define | GPS_UBX_MAX_PAYLOAD 255 |
#define | GPS_UBX_ERR_NONE 0 |
#define | GPS_UBX_ERR_OVERRUN 1 |
#define | GPS_UBX_ERR_MSG_TOO_LONG 2 |
#define | GPS_UBX_ERR_CHECKSUM 3 |
#define | GPS_UBX_ERR_UNEXPECTED 4 |
#define | GPS_UBX_ERR_OUT_OF_SYNC 5 |
#define | NO_CLASS 0 |
#define | RTCM_CLASS 1 |
#define | UBX_CLASS 2 |
#define | UBX_NAV_SVIN_VERSION(_ubx_payload) (uint8_t)(*((uint8_t*)_ubx_payload+0)) |
#define | UBX_NAV_SVIN_RES1(_ubx_payload) (uint8_t)(*((uint8_t*)_ubx_payload+1)) |
#define | UBX_NAV_SVIN_RES2(_ubx_payload) (uint16_t)(*((uint8_t*)_ubx_payload+2)|*((uint8_t*)_ubx_payload+1+2)<<8) |
#define | UBX_NAV_SVIN_ITOW(_ubx_payload) (uint32_t)(*((uint8_t*)_ubx_payload+4)|*((uint8_t*)_ubx_payload+1+4)<<8|((uint32_t)*((uint8_t*)_ubx_payload+2+4))<<16|((uint32_t)*((uint8_t*)_ubx_payload+3+4))<<24) |
#define | UBX_NAV_SVIN_dur(_ubx_payload) (uint32_t)(*((uint8_t*)_ubx_payload+8)|*((uint8_t*)_ubx_payload+1+8)<<8|((uint32_t)*((uint8_t*)_ubx_payload+2+8))<<16|((uint32_t)*((uint8_t*)_ubx_payload+3+8))<<24) |
#define | UBX_NAV_SVIN_meanX(_ubx_payload) (int32_t)(*((uint8_t*)_ubx_payload+12)|*((uint8_t*)_ubx_payload+1+12)<<8|((int32_t)*((uint8_t*)_ubx_payload+2+12))<<16|((int32_t)*((uint8_t*)_ubx_payload+3+12))<<24) |
#define | UBX_NAV_SVIN_meanY(_ubx_payload) (int32_t)(*((uint8_t*)_ubx_payload+16)|*((uint8_t*)_ubx_payload+1+16)<<8|((int32_t)*((uint8_t*)_ubx_payload+2+16))<<16|((int32_t)*((uint8_t*)_ubx_payload+3+16))<<24) |
#define | UBX_NAV_SVIN_meanZ(_ubx_payload) (int32_t)(*((uint8_t*)_ubx_payload+20)|*((uint8_t*)_ubx_payload+1+20)<<8|((int32_t)*((uint8_t*)_ubx_payload+2+20))<<16|((int32_t)*((uint8_t*)_ubx_payload+3+20))<<24) |
#define | UBX_NAV_SVIN_meanXHP(_ubx_payload) (int8_t)(*((uint8_t*)_ubx_payload+24)) |
#define | UBX_NAV_SVIN_meanYHP(_ubx_payload) (int8_t)(*((uint8_t*)_ubx_payload+25)) |
#define | UBX_NAV_SVIN_meanZHP(_ubx_payload) (int8_t)(*((uint8_t*)_ubx_payload+26)) |
#define | UBX_NAV_SVIN_RES3(_ubx_payload) (uint8_t)(*((uint8_t*)_ubx_payload+27)) |
#define | UBX_NAV_SVIN_meanACC(_ubx_payload) (uint32_t)(*((uint8_t*)_ubx_payload+28)|*((uint8_t*)_ubx_payload+1+28)<<8|((uint32_t)*((uint8_t*)_ubx_payload+2+28))<<16|((uint32_t)*((uint8_t*)_ubx_payload+3+28))<<24) |
#define | UBX_NAV_SVIN_OBS(_ubx_payload) (uint32_t)(*((uint8_t*)_ubx_payload+32)|*((uint8_t*)_ubx_payload+1+32)<<8|((uint32_t)*((uint8_t*)_ubx_payload+2+32))<<16|((uint32_t)*((uint8_t*)_ubx_payload+3+32))<<24) |
#define | UBX_NAV_SVIN_Valid(_ubx_payload) (uint8_t)(*((uint8_t*)_ubx_payload+36)) |
#define | UBX_NAV_SVIN_Active(_ubx_payload) (uint8_t)(*((uint8_t*)_ubx_payload+37)) |
#define | UBX_NAV_SVIN_RES4(_ubx_payload) (uint16_t)(*((uint8_t*)_ubx_payload+38)|*((uint8_t*)_ubx_payload+1+38)<<8) |
#define | RTCM_OK 0 |
Return value indicating success. More... | |
#define | RTCM_OK_CALLBACK_EXECUTED 1 |
Return value indicating message decoded and callback executed by rtcm3_process. More... | |
#define | RTCM_OK_CALLBACK_UNDEFINED 2 |
Return value indicating message decoded with no associated callback in rtcm3_process. More... | |
#define | RTCM_CALLBACK_ERROR -1 |
Return value indicating an error with the callback (function defined). More... | |
#define | RTCM_CRC_ERROR -2 |
Return value indicating a CRC error. More... | |
#define | RTCM_SEND_ERROR -3 |
Return value indicating an error occured whilst sending an RTCM3 message. More... | |
#define | RTCM_NULL_ERROR -4 |
Return value indicating an error occured because an argument was NULL. More... | |
Typedefs | |
typedef void(* | rtcm3_msg_callback_t) (u8 len, u8 msg[]) |
RTCM3 callback function prototype definition. More... | |
typedef struct rtcm3_msg_callbacks_node | rtcm3_msg_callbacks_node_t |
RTCM3 callback node. More... | |
Functions | |
s8 | rtcm3_register_callback (msg_state_t *s, u16 msg_type, rtcm3_msg_callback_t cb, rtcm3_msg_callbacks_node_t *node) |
Register a callback for a message type. More... | |
void | rtcm3_clear_callbacks (msg_state_t *s) |
Clear all registered callbacks. More... | |
rtcm3_msg_callbacks_node_t * | rtcm3_find_callback (msg_state_t *s, u16 msg_type) |
Find the callback function associated with a message type. More... | |
void | msg_state_init (msg_state_t *s) |
Initialize an msg_state_t struct before use. More... | |
s8 | rtcm3_process (msg_state_t *s, unsigned char buff) |
Read and process RTCM3 messages. More... | |
s8 | ubx_process (msg_state_t *s, unsigned char buff) |
unsigned int | RTCMgetbitu (unsigned char *, int, int) |
int | RTCMgetbits (unsigned char *, int, int) |
static double | RTCMgetbits_38 (unsigned char *, int) |
Variables | |
int | rd_msg_len = 0 |
int | rd_msg_len1 = 0 |
int | byteIndex = 0 |
int | checksumCounter = 0 |
int | rawIndex = 0 |
struct rtcm3_msg_callbacks_node |
RTCM3 callback node.
Forms a linked list of callbacks.
Data Fields | ||
---|---|---|
rtcm3_msg_callback_t | cb | Pointer to callback function. |
u16 | msg_type | Message ID associated with callback. |
struct rtcm3_msg_callbacks_node * | next | Pointer to next node in list. |
struct msg_state_t |
#define RTCM_CALLBACK_ERROR -1 |
#define RTCM_CRC_ERROR -2 |
#define RTCM_NULL_ERROR -4 |
#define RTCM_OK_CALLBACK_EXECUTED 1 |
#define RTCM_OK_CALLBACK_UNDEFINED 2 |
#define RTCM_SEND_ERROR -3 |
typedef struct rtcm3_msg_callbacks_node rtcm3_msg_callbacks_node_t |
RTCM3 callback node.
Forms a linked list of callbacks.
void msg_state_init | ( | msg_state_t * | s | ) |
Initialize an msg_state_t struct before use.
This resets the entire state, including all callbacks. Remember to use this function to initialize the state before calling rtcm3_process() for the first time.
s | State structure |
Definition at line 254 of file rtcm3.h.
References NO_CLASS, rtcm3_clear_callbacks(), s, and UNINIT.
void rtcm3_clear_callbacks | ( | msg_state_t * | s | ) |
Clear all registered callbacks.
This is probably only useful for testing but who knows!
Definition at line 210 of file rtcm3.h.
References s.
Referenced by msg_state_init().
rtcm3_msg_callbacks_node_t * rtcm3_find_callback | ( | msg_state_t * | s, |
u16 | msg_type | ||
) |
Find the callback function associated with a message type.
Searches through the list of registered callbacks to find the callback associated with the passed message type.
msg_type | Message type to find callback for |
NULL
if callback not found for that message type. Definition at line 224 of file rtcm3.h.
Referenced by rtcm3_process(), rtcm3_register_callback(), and ubx_process().
s8 rtcm3_process | ( | msg_state_t * | s, |
unsigned char | buff | ||
) |
Read and process RTCM3 messages.
Reads bytes from an input source using the provided read
function, decodes the RTCM3.
When an RTCM3 message is successfully received then the list of callbacks is searched for a callback corresponding to the received message type. If a callback is found then it is called with the ID of the sender, the message length and the message payload data buffer as arguments.
read
with n > 0 (aka it will attempt to always read something)The supplied read
function must have the prototype:
where n
is the number of bytes requested and buff
is the buffer into which to write the received data, and context
is the arbitrary pointer set by rtcm3_state_set_io_context
. The function should return the number of bytes successfully written into buff
which may be between 0 and n
inclusive, but must never be greater than n
.
Note that rtcm3_process
may not read all available bytes from the read
function so the caller should loop until all bytes available from the input source have been consumed.
s | State structure |
read | Function pointer to a function that reads n bytes from the input source into buff and returns the number of bytes successfully read. |
RTCM_OK
(0) if successful but no complete message yet, RTCM_OK_CALLBACK_EXECUTED
(1) if message decoded and callback executed, RTCM_OK_CALLBACK_UNDEFINED
(2) if message decoded with no associated callback, and RTCM_CRC_ERROR
(-2) if a CRC error has occurred. Thus can check for >0 to ensure good processing. Definition at line 308 of file rtcm3.h.
References buff, byteIndex, rtcm3_msg_callbacks_node::cb, checksumCounter, NO_CLASS, rawIndex, rd_msg_len, rd_msg_len1, READ_CHECKSUM, READ_LENGTH, READ_MESSAGE, READ_RESERVED, rtcm3_find_callback(), RTCM3_MSG_1005, RTCM3_MSG_1077, RTCM3_MSG_1087, RTCM3_MSG_1230, RTCM3_MSG_4072, RTCM3_PREAMBLE, RTCM_CLASS, RTCM_OK, RTCM_OK_CALLBACK_EXECUTED, RTCM_OK_CALLBACK_UNDEFINED, RTCMgetbitu(), s, and UNINIT.
s8 rtcm3_register_callback | ( | msg_state_t * | s, |
u16 | msg_type, | ||
rtcm3_msg_callback_t | cb, | ||
rtcm3_msg_callbacks_node_t * | node | ||
) |
Register a callback for a message type.
Register a callback that is called when a message with type msg_type is received.
msg_type | Message type associated with callback |
cb | Pointer to message callback function |
context | Pointer to context for callback function |
node | Statically allocated rtcm3_msg_callbacks_node_t struct |
RTCM_OK
(0) if successful, RTCM_CALLBACK_ERROR
if callback was already registered for that message type. Definition at line 159 of file rtcm3.h.
References rtcm3_msg_callbacks_node::cb, rtcm3_msg_callbacks_node::msg_type, rtcm3_msg_callbacks_node::next, p, rtcm3_find_callback(), RTCM_CALLBACK_ERROR, RTCM_NULL_ERROR, RTCM_OK, and s.
int RTCMgetbits | ( | unsigned char * | buff, |
int | pos, | ||
int | lenb | ||
) |
Definition at line 503 of file rtcm3.h.
References buff, and RTCMgetbitu().
Referenced by RTCMgetbits_38().
|
static |
Definition at line 510 of file rtcm3.h.
References buff, RTCMgetbits(), and RTCMgetbitu().
unsigned int RTCMgetbitu | ( | unsigned char * | buff, |
int | pos, | ||
int | lenb | ||
) |
Definition at line 495 of file rtcm3.h.
References buff.
Referenced by rtcm3_process(), RTCMgetbits(), and RTCMgetbits_38().
s8 ubx_process | ( | msg_state_t * | s, |
unsigned char | buff | ||
) |
Definition at line 403 of file rtcm3.h.
References buff, rtcm3_msg_callbacks_node::cb, GOT_CHECKSUM1, GOT_CLASS, GOT_ID, GOT_LEN1, GOT_LEN2, GOT_PAYLOAD, GOT_SYNC1, GOT_SYNC2, GPS_UBX_ERR_CHECKSUM, GPS_UBX_ERR_MSG_TOO_LONG, GPS_UBX_ERR_OUT_OF_SYNC, GPS_UBX_ERR_UNEXPECTED, GPS_UBX_MAX_PAYLOAD, NO_CLASS, rtcm3_find_callback(), RTCM_OK, RTCM_OK_CALLBACK_EXECUTED, RTCM_OK_CALLBACK_UNDEFINED, s, UBX_CLASS, UBX_PREAMBLE1, UBX_PREAMBLE2, and UNINIT.
int byteIndex = 0 |
Definition at line 144 of file rtcm3.h.
Referenced by rtcm3_process().
int checksumCounter = 0 |
Definition at line 145 of file rtcm3.h.
Referenced by rtcm3_process().
int rawIndex = 0 |
Definition at line 146 of file rtcm3.h.
Referenced by rtcm3_process().
int rd_msg_len = 0 |
Definition at line 142 of file rtcm3.h.
Referenced by rtcm3_process().
int rd_msg_len1 = 0 |
Definition at line 143 of file rtcm3.h.
Referenced by rtcm3_process().