mip_interface.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
4 #include <stddef.h>
5 
6 #include "mip_parser.h"
7 #include "mip_cmdqueue.h"
8 #include "mip_dispatch.h"
9 
10 #ifdef __cplusplus
11 namespace mip{
12 namespace C {
13 extern "C" {
14 #endif
15 
32 
33 struct mip_interface;
34 
35 // Documentation is in source file.
36 typedef bool (*mip_send_callback)(struct mip_interface* device, const uint8_t* data, size_t length);
37 typedef bool (*mip_recv_callback)(struct mip_interface* device, uint8_t* buffer, size_t max_length, mip_timeout wait_time, size_t* length_out, mip_timestamp* timestamp_out);
38 typedef bool (*mip_update_callback)(struct mip_interface* device, mip_timeout timeout);
39 
40 
44 typedef struct mip_interface
45 {
49  unsigned int _max_update_pkts;
53  void* _user_pointer;
55 
56 
58  mip_interface* device, uint8_t* parse_buffer, size_t parse_buffer_size,
59  mip_timeout parse_timeout, mip_timeout base_reply_timeout,
61  mip_update_callback update, void* user_pointer
62 );
63 
64 //
65 // Communications
66 //
67 
68 bool mip_interface_send_to_device(mip_interface* device, const uint8_t* data, size_t length);
69 bool mip_interface_recv_from_device(mip_interface* device, uint8_t* buffer, size_t max_length, mip_timeout timeout, size_t* length_out, mip_timestamp* now);
71 
73 size_t mip_interface_receive_bytes(mip_interface* device, const uint8_t* data, size_t length, mip_timestamp timestamp);
75 bool mip_interface_parse_callback(void* device, const mip_packet* packet, mip_timestamp timestamp);
77 
78 //
79 // Commands
80 //
81 
83 enum mip_cmd_result mip_interface_run_command(mip_interface* device, uint8_t descriptor_set, uint8_t field_descriptor, const uint8_t* payload, uint8_t payload_length);
84 enum mip_cmd_result mip_interface_run_command_with_response(mip_interface* device, uint8_t descriptor_set, uint8_t field_descriptor, const uint8_t* payload, uint8_t payload_length, uint8_t response_descriptor, uint8_t* response_data, uint8_t* response_length_inout);
86 
88 
89 //
90 // Data Callbacks
91 //
92 
93 void mip_interface_register_packet_callback(mip_interface* device, mip_dispatch_handler* handler, uint8_t descriptor_set, bool after_fields, mip_dispatch_packet_callback callback, void* user_data);
94 void mip_interface_register_field_callback(mip_interface* device, mip_dispatch_handler* handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_field_callback callback, void* user_data);
95 void mip_interface_register_extractor(mip_interface* device, mip_dispatch_handler* handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor callback, void* field_ptr);
96 
97 //
98 // Accessors
99 //
100 
105 
106 void mip_interface_set_max_packets_per_update(mip_interface* device, unsigned int max_packets);
108 
113 
116 
119 
120 #ifdef __cplusplus
121 } // namespace mip
122 } // namespace C
123 } // extern "C"
124 #endif
mip_interface::_update_callback
mip_update_callback _update_callback
Optional function to call during updates.
Definition: mip_interface.h:52
mip_interface_parse_callback
bool mip_interface_parse_callback(void *device, const mip_packet *packet, mip_timestamp timestamp)
Wrapper around mip_interface_receive_packet for use with mip_parser.
Definition: mip_interface.c:501
mip_interface
struct mip_interface mip_interface
State of the interface for communicating with a MIP device.
mip_interface_set_user_pointer
void mip_interface_set_user_pointer(mip_interface *device, void *pointer)
Sets an optional user data pointer which can be retrieved later.
Definition: mip_interface.c:264
mip
Definition: ping.cpp:12
mip_interface::_parser
mip_parser _parser
MIP Parser for incoming MIP packets.
Definition: mip_interface.h:46
mip_parser.h
mip_interface::_recv_callback
mip_recv_callback _recv_callback
Optional function which is called to receive raw bytes from the device.
Definition: mip_interface.h:51
mip_update_callback
bool(* mip_update_callback)(struct mip_interface *device, mip_timeout timeout)
Definition: mip_interface.h:38
mip_interface_run_command
enum mip_cmd_result mip_interface_run_command(mip_interface *device, uint8_t descriptor_set, uint8_t field_descriptor, const uint8_t *payload, uint8_t payload_length)
Runs a command using a pre-serialized payload.
Definition: mip_interface.c:568
mip_interface::_max_update_pkts
unsigned int _max_update_pkts
Max number of MIP packets to parse at once.
Definition: mip_interface.h:49
mip_interface_register_extractor
void mip_interface_register_extractor(mip_interface *device, mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor callback, void *field_ptr)
Registers a callback for packets of the specified descriptor set.
Definition: mip_interface.c:725
mip_parser
MIP Parser state.
Definition: mip_parser.h:55
mip_dispatch_packet_callback
void(* mip_dispatch_packet_callback)(void *context, const mip_packet *packet, mip_timestamp timestamp)
Signature for packet-level callbacks.
Definition: mip_dispatch.h:38
mip_dispatch.h
mip_interface_send_function
mip_send_callback mip_interface_send_function(const mip_interface *device)
Gets the send function pointer.
Definition: mip_interface.c:192
mip_interface_wait_for_reply
enum mip_cmd_result mip_interface_wait_for_reply(mip_interface *device, mip_pending_cmd *cmd)
Blocks until the pending command completes or times out.
Definition: mip_interface.c:524
mip_dispatch_extractor
bool(* mip_dispatch_extractor)(const mip_field *field, void *ptr)
Signature for extraction callbacks.
Definition: mip_dispatch.h:55
mip_cmdqueue.h
mip_send_callback
bool(* mip_send_callback)(struct mip_interface *device, const uint8_t *data, size_t length)
Definition: mip_interface.h:36
mip_interface_register_field_callback
void mip_interface_register_field_callback(mip_interface *device, mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_field_callback callback, void *user_data)
Registers a callback for packets of the specified descriptor set.
Definition: mip_interface.c:703
mip_interface_set_update_function
void mip_interface_set_update_function(mip_interface *device, mip_update_callback function)
Sets the update function.
Definition: mip_interface.c:240
mip_interface_user_pointer
void * mip_interface_user_pointer(const mip_interface *device)
Retrieves the pointer set by mip_interface_set_user_pointer().
Definition: mip_interface.c:276
mip_cmd_result
mip_cmd_result
Represents the status of a MIP command.
Definition: mip_result.h:25
data
data
mip_interface_set_send_function
void mip_interface_set_send_function(mip_interface *device, mip_send_callback function)
Sets the send callback function.
Definition: mip_interface.c:180
mip_interface::_send_callback
mip_send_callback _send_callback
Optional function which is called to send raw bytes to the device.
Definition: mip_interface.h:50
parse_buffer
uint8_t parse_buffer[1024]
Definition: CV7_example.c:46
mip_interface::_queue
mip_cmd_queue _queue
Queue for checking command replies.
Definition: mip_interface.h:47
mip_interface_send_to_device
bool mip_interface_send_to_device(mip_interface *device, const uint8_t *data, size_t length)
Sends data to the port (i.e.
Definition: mip_interface.c:348
device
mip_interface device
Definition: CV7_example.c:47
mip_timestamp
uint64_t mip_timestamp
Type used for packet timestamps and timeouts.
Definition: mip_types.h:32
mip_pending_cmd
Represents a command awaiting a reply from the device.
Definition: mip_cmdqueue.h:41
mip_interface_register_packet_callback
void mip_interface_register_packet_callback(mip_interface *device, mip_dispatch_handler *handler, uint8_t descriptor_set, bool after_fields, mip_dispatch_packet_callback callback, void *user_data)
Registers a callback for packets of the specified descriptor set.
Definition: mip_interface.c:680
mip_interface_default_update
bool mip_interface_default_update(mip_interface *device, mip_timeout wait_time)
Polls the port for new data or command replies.
Definition: mip_interface.c:415
mip_interface_update
bool mip_interface_update(mip_interface *device, mip_timeout wait_time)
Call to process data from the device.
Definition: mip_interface.c:392
mip_interface_set_recv_function
void mip_interface_set_recv_function(mip_interface *device, mip_recv_callback function)
Sets the receive callback function.
Definition: mip_interface.c:207
mip_interface::_user_pointer
void * _user_pointer
Optional user-specified data pointer.
Definition: mip_interface.h:53
mip_interface_process_unparsed_packets
void mip_interface_process_unparsed_packets(mip_interface *device)
Process more packets from the internal buffer.
Definition: mip_interface.c:471
mip_interface::_dispatcher
mip_dispatcher _dispatcher
Dispatcher for data callbacks.
Definition: mip_interface.h:48
mip_interface_receive_packet
void mip_interface_receive_packet(mip_interface *device, const mip_packet *packet, mip_timestamp timestamp)
Processes a pre-parsed packet for command replies and data.
Definition: mip_interface.c:486
mip_cmd_queue
Holds a list of pending commands.
Definition: mip_cmdqueue.h:93
mip_recv_callback
bool(* mip_recv_callback)(struct mip_interface *device, uint8_t *buffer, size_t max_length, mip_timeout wait_time, size_t *length_out, mip_timestamp *timestamp_out)
Definition: mip_interface.h:37
mip_dispatch_handler
Handler information for MIP Packet or Field callbacks.
Definition: mip_dispatch.h:87
mip_interface_set_max_packets_per_update
void mip_interface_set_max_packets_per_update(mip_interface *device, unsigned int max_packets)
Sets a limit on the number of packets which can be processed in one call to the mip_interface_receive...
Definition: mip_interface.c:305
mip_interface_update_function
mip_update_callback mip_interface_update_function(const mip_interface *device)
Gets the update function pointer.
Definition: mip_interface.c:252
mip_interface_start_command_packet
bool mip_interface_start_command_packet(mip_interface *device, const mip_packet *packet, mip_pending_cmd *cmd)
Queues the command and sends the packet.
Definition: mip_interface.c:653
mip_interface_receive_bytes
size_t mip_interface_receive_bytes(mip_interface *device, const uint8_t *data, size_t length, mip_timestamp timestamp)
Passes data from the device into the parser.
Definition: mip_interface.c:454
mip_timeout
mip_timestamp mip_timeout
Definition: mip_types.h:35
mip_interface_cmd_queue
mip_cmd_queue * mip_interface_cmd_queue(mip_interface *device)
Returns the commmand queue for the device.
Definition: mip_interface.c:322
mip_interface_recv_from_device
bool mip_interface_recv_from_device(mip_interface *device, uint8_t *buffer, size_t max_length, mip_timeout timeout, size_t *length_out, mip_timestamp *now)
Checks for data at the port and reads it into buffer.
Definition: mip_interface.c:367
mip_interface_max_packets_per_update
unsigned int mip_interface_max_packets_per_update(const mip_interface *device)
Returns the maximum number of packets to parser per update call.
Definition: mip_interface.c:285
mip_packet
Structure representing a MIP Packet.
Definition: mip_packet.h:41
mip_dispatch_field_callback
void(* mip_dispatch_field_callback)(void *context, const mip_field *field, mip_timestamp timestamp)
Signature for field-level callbacks.
Definition: mip_dispatch.h:47
mip_interface
State of the interface for communicating with a MIP device.
Definition: mip_interface.h:44
length
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
mip_interface_init
void mip_interface_init(mip_interface *device, uint8_t *parse_buffer, size_t parse_buffer_size, mip_timeout parse_timeout, mip_timeout base_reply_timeout, mip_send_callback send, mip_recv_callback recv, mip_update_callback update, void *user_pointer)
Initialize the mip_interface components.
Definition: mip_interface.c:144
mip_interface_run_command_packet
enum mip_cmd_result mip_interface_run_command_packet(mip_interface *device, const mip_packet *packet, mip_pending_cmd *cmd)
Similar to mip_interface_start_command_packet but waits for the command to complete.
Definition: mip_interface.c:632
mip_interface_parser
mip_parser * mip_interface_parser(mip_interface *device)
Returns the MIP parser for the device.
Definition: mip_interface.c:314
mip_interface_run_command_with_response
enum mip_cmd_result mip_interface_run_command_with_response(mip_interface *device, uint8_t descriptor_set, uint8_t field_descriptor, const uint8_t *payload, uint8_t payload_length, uint8_t response_descriptor, uint8_t *response_data, uint8_t *response_length_inout)
Runs a command using a pre-serialized payload.
Definition: mip_interface.c:597
mip_dispatcher
Holds the state of the MIP dispatch system.
Definition: mip_dispatch.h:121
mip_interface_recv_function
mip_recv_callback mip_interface_recv_function(const mip_interface *device)
Gets the receive function pointer.
Definition: mip_interface.c:219


microstrain_inertial_driver
Author(s): Brian Bingham, Parker Hannifin Corp
autogenerated on Mon Jun 24 2024 02:51:40