Go to the documentation of this file.
429 assert(count <= max_count);
598 uint8_t descriptor_set, uint8_t cmd_descriptor,
const uint8_t* cmd_data, uint8_t cmd_length,
599 uint8_t response_descriptor, uint8_t* response_buffer, uint8_t* response_length_inout)
611 const uint8_t response_length = response_length_inout ? *response_length_inout : 0;
616 if( response_length_inout )
727 uint8_t descriptor_set, uint8_t field_descriptor,
mip_update_callback _update_callback
Optional function to call during updates.
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.
void mip_interface_set_user_pointer(mip_interface *device, void *pointer)
Sets an optional user data pointer which can be retrieved later.
mip_parser _parser
MIP Parser for incoming MIP packets.
void mip_dispatch_handler_init_packet_handler(mip_dispatch_handler *handler, uint8_t descriptor_set, bool post_callback, mip_dispatch_packet_callback callback, void *user_data)
Initialize the dispatch handler with a packet callback.
mip_recv_callback _recv_callback
Optional function which is called to receive raw bytes from the device.
bool(* mip_update_callback)(struct mip_interface *device, mip_timeout timeout)
enum mip_cmd_result mip_interface_run_command(mip_interface *device, uint8_t descriptor_set, uint8_t cmd_descriptor, const uint8_t *cmd_data, uint8_t cmd_length)
Runs a command using a pre-serialized payload.
unsigned int _max_update_pkts
Max number of MIP packets to parse at once.
void mip_interface_register_extractor(mip_interface *device, mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor extractor, void *field_ptr)
Registers a callback for packets of the specified descriptor set.
uint_least16_t mip_packet_total_length(const mip_packet *packet)
Returns the total length of the packet, in bytes.
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.
void(* mip_dispatch_packet_callback)(void *context, const mip_packet *packet, mip_timestamp timestamp)
Signature for packet-level callbacks.
void mip_cmd_queue_init(mip_cmd_queue *queue, mip_timeout base_reply_timeout)
Initializes a command queue.
#define MIPPARSER_UNLIMITED_PACKETS
Specifies no limit when used as the max_packets argument to mip_parser_parse.
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_send_callback mip_interface_send_function(const mip_interface *device)
Gets the send function pointer.
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.
void mip_dispatch_handler_init_field_handler(mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_field_callback callback, void *user_data)
Initialize the dispatch handler with a field callback.
void mip_dispatcher_dispatch_packet(mip_dispatcher *self, const mip_packet *packet, mip_timestamp timestamp)
Called to dispatch the callbacks for a given packet.
bool(* mip_dispatch_extractor)(const mip_field *field, void *ptr)
Signature for extraction callbacks.
bool(* mip_send_callback)(struct mip_interface *device, const uint8_t *data, size_t length)
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.
void mip_interface_set_update_function(mip_interface *device, mip_update_callback callback)
Sets the update function.
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 **const ptr_out)
Obtain a pointer into which data may be read for processing.
void * mip_interface_user_pointer(const mip_interface *device)
Retrieves the pointer set by mip_interface_set_user_pointer().
@ MIP_STATUS_ERROR
Command could not be executed (error sending/receiving)
mip_cmd_result
Represents the status of a MIP command.
void mip_dispatcher_add_handler(mip_dispatcher *self, mip_dispatch_handler *handler)
Registers a handler in the dispatch system.
void mip_interface_set_send_function(mip_interface *device, mip_send_callback callback)
Sets the send callback function.
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.
mip_send_callback _send_callback
Optional function which is called to send raw bytes to the device.
uint8_t parse_buffer[1024]
mip_cmd_queue _queue
Queue for checking command replies.
bool mip_interface_send_to_device(mip_interface *device, const uint8_t *data, size_t length)
Sends data to the port (i.e.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
uint64_t mip_timestamp
Type used for packet timestamps and timeouts.
Represents a command awaiting a reply from the device.
bool mip_cmd_result_is_finished(enum mip_cmd_result status)
Determines if the command has completed, timed out, been cancelled, or otherwise is no longer waiting...
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.
bool mip_interface_default_update(struct mip_interface *device, mip_timeout wait_time)
Polls the port for new data or command replies.
bool mip_interface_update(struct mip_interface *device, mip_timeout wait_time)
Call to process data from the device.
void mip_interface_set_recv_function(mip_interface *device, mip_recv_callback callback)
Sets the receive callback function.
void * _user_pointer
Optional user-specified data pointer.
uint8_t mip_pending_cmd_response_length(const mip_pending_cmd *cmd)
Returns the length of the response data.
void mip_interface_process_unparsed_packets(mip_interface *device)
Process more packets from the internal buffer.
mip_dispatcher _dispatcher
Dispatcher for data callbacks.
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.
Holds a list of pending commands.
void mip_dispatch_handler_init_extractor(mip_dispatch_handler *handler, uint8_t descriptor_set, uint8_t field_descriptor, mip_dispatch_extractor extractor, void *field_ptr)
Initialize the dispatch handler with an extraction 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)
Handler information for MIP Packet or Field callbacks.
void mip_cmd_queue_update(mip_cmd_queue *queue, mip_timestamp now)
Call periodically to make sure commands time out if no packets are received.
const uint8_t * mip_packet_pointer(const mip_packet *packet)
Returns a pointer to the data buffer containing the packet.
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...
mip_update_callback mip_interface_update_function(const mip_interface *device)
Gets the update function pointer.
mip_timestamp mip_parser_last_packet_timestamp(const mip_parser *parser)
Gets the timestamp of the last parsed 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.
void mip_packet_finalize(mip_packet *packet)
Prepares the packet for transmission by adding the checksum.
void mip_cmd_queue_dequeue(mip_cmd_queue *queue, mip_pending_cmd *cmd)
Removes a pending command from the queue.
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.
enum mip_cmd_result mip_pending_cmd_status(const mip_pending_cmd *cmd)
Returns the status of the pending command.
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.
mip_timestamp mip_timeout
mip_cmd_queue * mip_interface_cmd_queue(mip_interface *device)
Returns the commmand queue for the device.
bool mip_interface_recv_from_device(mip_interface *device, uint8_t *buffer, size_t max_length, mip_timeout wait_time, size_t *length_out, mip_timestamp *timestamp_out)
Checks for data at the port and reads it into buffer.
unsigned int mip_interface_max_packets_per_update(const mip_interface *device)
Returns the maximum number of packets to parser per update call.
Structure representing a MIP Packet.
void(* mip_dispatch_field_callback)(void *context, const mip_field *field, mip_timestamp timestamp)
Signature for field-level callbacks.
State of the interface for communicating with a MIP device.
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
void mip_cmd_queue_process_packet(mip_cmd_queue *queue, const mip_packet *packet, mip_timestamp timestamp)
Process an incoming packet and check for replies to pending commands.
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.
@ MIP_INVALID_FIELD_DESCRIPTOR
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.
mip_parser * mip_interface_parser(mip_interface *device)
Returns the MIP parser for the device.
void mip_dispatcher_init(mip_dispatcher *self)
Initializes the mip_dispatcher object.
void mip_cmd_queue_enqueue(mip_cmd_queue *queue, mip_pending_cmd *cmd)
Queue a command to wait for replies.
void mip_pending_cmd_init_with_response(mip_pending_cmd *cmd, uint8_t descriptor_set, uint8_t field_descriptor, uint8_t response_descriptor, uint8_t *response_buffer, uint8_t response_buffer_size)
Initialize a pending mip commmand with expected response data.
enum mip_cmd_result mip_interface_run_command_with_response(mip_interface *device, uint8_t descriptor_set, uint8_t cmd_descriptor, const uint8_t *cmd_data, uint8_t cmd_length, uint8_t response_descriptor, uint8_t *response_buffer, uint8_t *response_length_inout)
Runs a command using a pre-serialized payload.
mip_recv_callback mip_interface_recv_function(const mip_interface *device)
Gets the receive function pointer.