Go to the documentation of this file.
65 #ifdef MIP_ENABLE_DIAGNOSTICS
66 uint32_t _diag_bytes_read;
67 uint32_t _diag_bytes_skipped;
68 uint32_t _diag_packet_bytes;
69 uint32_t _diag_valid_packets;
70 uint32_t _diag_invalid_packets;
71 uint32_t _diag_timeouts;
72 #endif // MIP_ENABLE_DIAGNOSTICS
78 #define MIPPARSER_UNLIMITED_PACKETS 0
79 #define MIPPARSER_DEFAULT_TIMEOUT_MS 100
109 #ifdef MIP_ENABLE_DIAGNOSTICS
111 uint32_t mip_parser_diagnostic_bytes_read(
const mip_parser* parser);
112 uint32_t mip_parser_diagnostic_bytes_skipped(
const mip_parser* parser);
113 uint32_t mip_parser_diagnostic_packet_bytes(
const mip_parser* parser);
115 uint32_t mip_parser_diagnostic_valid_packets(
const mip_parser* parser);
116 uint32_t mip_parser_diagnostic_invalid_packets(
const mip_parser* parser);
117 uint32_t mip_parser_diagnostic_timeouts(
const mip_parser* parser);
119 #endif // MIP_ENABLE_DIAGNOSTICS
void mip_parser_set_timeout(mip_parser *parser, mip_timeout timeout)
Changes the timeout of the MIP parser.
void mip_parser_reset(mip_parser *parser)
Resets the MIP parser.
struct mip_parser mip_parser
MIP Parser state.
uint16_t _expected_length
Expected length of the packet currently being parsed. Keeps track of parser state....
void mip_parser_init(mip_parser *parser, uint8_t *buffer, size_t buffer_size, mip_packet_callback callback, void *callback_object, mip_timestamp timeout)
Initializes the MIP parser.
mip_timestamp _timeout
Duration to wait for the rest of the data in a packet.
void mip_parser_set_callback(mip_parser *parser, mip_packet_callback callback, void *callback_object)
mip_parser_set_callback
mip_timeout mip_parser_timeout(const mip_parser *parser)
Returns the packet timeout of the parser.
void mip_parser_process_written(mip_parser *parser, size_t count, mip_timestamp timestamp, unsigned int max_packets)
Notify the parser that data has been written to the pointer previously obtained via mip_parser_get_wr...
size_t mip_parser_get_write_ptr(mip_parser *parser, uint8_t **ptr_out)
Obtain a pointer into which data may be read for processing.
void * mip_parser_callback_object(const mip_parser *parser)
mip_parser_callback
mip_timestamp _start_time
The timestamp when the first byte was observed by the parser.
size_t mip_parser_parse(mip_parser *parser, const uint8_t *input_buffer, size_t input_count, mip_timestamp timestamp, unsigned int max_packets)
Parses packets from the input data buffer.
uint64_t mip_timestamp
Type used for packet timestamps and timeouts.
mip_packet_callback mip_parser_callback(const mip_parser *parser)
mip_parser_callback
mip_packet_callback _callback
Callback called when a valid packet is parsed. Can be NULL.
byte_ring_state _ring
Ring buffer which holds data being parsed. User-specified backing buffer and size.
mip_timestamp mip_parser_last_packet_timestamp(const mip_parser *parser)
Gets the timestamp of the last parsed packet.
mip_timestamp mip_timeout
Structure representing a MIP Packet.
bool(* mip_packet_callback)(void *user, const mip_packet *packet, mip_timestamp timestamp)
Callback function which receives parsed MIP packets.
mip_timeout mip_timeout_from_baudrate(uint32_t baudrate)
Computes an appropriate packet timeout for a given serial baud rate.
bool mip_parser_parse_one_packet_from_ring(mip_parser *parser, mip_packet *packet_out, mip_timestamp timestamp)
Parses a single packet from the internal buffer.
void * _callback_object
User-specified pointer passed to the callback function.