mip_packet.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "mip_types.h"
4 
5 #ifdef __cplusplus
6 namespace mip{
7 namespace C {
8 extern "C" {
9 #endif
10 
11 
15 
30 
31 
41 typedef struct mip_packet
42 {
43  uint8_t* _buffer;
44  uint_least16_t _buffer_length;
45 } mip_packet;
46 
47 
57 
58 void mip_packet_create(mip_packet* packet, uint8_t* buffer, size_t buffer_size, uint8_t descriptor_set);
59 
60 bool mip_packet_add_field(mip_packet* packet, uint8_t field_descriptor, const uint8_t* payload, uint8_t payload_length);
61 int mip_packet_alloc_field(mip_packet* packet, uint8_t field_descriptor, uint8_t payload_length, uint8_t** payload_ptr_out);
62 int mip_packet_realloc_last_field(mip_packet* packet, uint8_t* payload_ptr, uint8_t new_payload_length);
63 int mip_packet_cancel_last_field(mip_packet* packet, uint8_t* payload_ptr);
64 
65 void mip_packet_finalize(mip_packet* packet);
66 
67 void mip_packet_reset(mip_packet* packet, uint8_t descriptor_set);
68 
82 
83 void mip_packet_from_buffer(mip_packet* packet, uint8_t* buffer, size_t length);
84 
85 uint8_t mip_packet_descriptor_set(const mip_packet* packet);
86 uint_least16_t mip_packet_total_length(const mip_packet* packet);
87 uint8_t mip_packet_payload_length(const mip_packet* packet);
88 uint8_t* mip_packet_buffer(mip_packet* packet);
89 const uint8_t* mip_packet_pointer(const mip_packet* packet);
90 const uint8_t* mip_packet_payload(const mip_packet* packet);
91 uint16_t mip_packet_checksum_value(const mip_packet* packet);
92 uint16_t mip_packet_compute_checksum(const mip_packet* packet);
93 
94 
95 bool mip_packet_is_sane(const mip_packet* packet);
96 bool mip_packet_is_valid(const mip_packet* packet);
97 bool mip_packet_is_empty(const mip_packet* packet);
98 
99 uint_least16_t mip_packet_buffer_size(const mip_packet* packet);
100 int mip_packet_remaining_space(const mip_packet* packet);
101 
102 bool mip_packet_is_data(const mip_packet* packet);
103 
108 
109 #ifdef __cplusplus
110 } // namespace mip
111 } // namespace C
112 } // extern "C"
113 #endif
mip_packet::_buffer_length
uint_least16_t _buffer_length
Length of the buffer (NOT the packet length!).
Definition: mip_packet.h:44
mip
Definition: ping.cpp:12
mip_packet::_buffer
uint8_t * _buffer
Pointer to the packet data.
Definition: mip_packet.h:43
mip_packet_total_length
uint_least16_t mip_packet_total_length(const mip_packet *packet)
Returns the total length of the packet, in bytes.
Definition: mip_packet.c:105
mip_packet_create
void mip_packet_create(mip_packet *packet, uint8_t *buffer, size_t buffer_size, uint8_t descriptor_set)
Create a brand-new MIP packet in the given buffer.
Definition: mip_packet.c:62
mip_packet_alloc_field
int mip_packet_alloc_field(mip_packet *packet, uint8_t field_descriptor, uint8_t payload_length, uint8_t **payload_ptr_out)
Allocate a MIP field within the packet and return the payload pointer.
Definition: mip_packet.c:331
mip_packet_is_valid
bool mip_packet_is_valid(const mip_packet *packet)
Returns true if the packet is valid.
Definition: mip_packet.c:192
mip_types.h
mip_packet_cancel_last_field
int mip_packet_cancel_last_field(mip_packet *packet, uint8_t *payload_ptr)
Removes the last field from the packet after having allocated it.
Definition: mip_packet.c:414
mip_packet_buffer
uint8_t * mip_packet_buffer(mip_packet *packet)
Returns a writable pointer to the data buffer.
Definition: mip_packet.c:113
mip_packet_payload_length
uint8_t mip_packet_payload_length(const mip_packet *packet)
Returns the length of the payload (MIP fields).
Definition: mip_packet.c:95
mip_packet_compute_checksum
uint16_t mip_packet_compute_checksum(const mip_packet *packet)
Computes the checksum of the MIP packet.
Definition: mip_packet.c:152
mip_packet_payload
const uint8_t * mip_packet_payload(const mip_packet *packet)
Returns a pointer to the packet's payload (the first field).
Definition: mip_packet.c:129
mip_packet
struct mip_packet mip_packet
Structure representing a MIP Packet.
mip_packet_reset
void mip_packet_reset(mip_packet *packet, uint8_t descriptor_set)
Reinitialize the packet with the given descriptor set.
Definition: mip_packet.c:461
mip_packet_is_empty
bool mip_packet_is_empty(const mip_packet *packet)
Returns true if the mip packet contains no payload.
Definition: mip_packet.c:210
mip_packet_pointer
const uint8_t * mip_packet_pointer(const mip_packet *packet)
Returns a pointer to the data buffer containing the packet.
Definition: mip_packet.c:121
mip_packet_finalize
void mip_packet_finalize(mip_packet *packet)
Prepares the packet for transmission by adding the checksum.
Definition: mip_packet.c:443
mip_packet_add_field
bool mip_packet_add_field(mip_packet *packet, uint8_t field_descriptor, const uint8_t *payload, uint8_t payload_length)
Adds a pre-constructed MIP field to the packet.
Definition: mip_packet.c:289
mip_packet_descriptor_set
uint8_t mip_packet_descriptor_set(const mip_packet *packet)
Returns the MIP descriptor set for this packet.
Definition: mip_packet.c:87
mip_packet_realloc_last_field
int mip_packet_realloc_last_field(mip_packet *packet, uint8_t *payload_ptr, uint8_t new_payload_length)
Changes the size of the last field in the packet.
Definition: mip_packet.c:378
mip_packet_checksum_value
uint16_t mip_packet_checksum_value(const mip_packet *packet)
Returns the value of the checksum as written in the packet.
Definition: mip_packet.c:140
mip_packet_is_data
bool mip_packet_is_data(const mip_packet *packet)
Returns true if the packet is from a data descriptor set.
Definition: mip_packet.c:251
mip_packet
Structure representing a MIP Packet.
Definition: mip_packet.h:41
mip_packet_remaining_space
int mip_packet_remaining_space(const mip_packet *packet)
Returns the remaining space available for more payload data.
Definition: mip_packet.c:238
mip_packet_buffer_size
uint_least16_t mip_packet_buffer_size(const mip_packet *packet)
Returns the size of the buffer backing the MIP packet.
Definition: mip_packet.c:224
mip_packet_is_sane
bool mip_packet_is_sane(const mip_packet *packet)
Returns true if the packet buffer is not NULL and is at least the minimum size (MIP_PACKET_LENGTH_MIN...
Definition: mip_packet.c:179
mip_packet_from_buffer
void mip_packet_from_buffer(mip_packet *packet, uint8_t *buffer, size_t length)
Initializes a MIP packet from an existing buffer.
Definition: mip_packet.c:36


microstrain_inertial_driver
Author(s): Brian Bingham, Parker Hannifin Corp
autogenerated on Fri May 24 2024 06:48:21