MIP_SDK  latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
Classes | Typedefs | Functions
Mip Command Queue

Classes

struct  mip::C::mip_cmd_queue
 Holds a list of pending commands. More...
 

Typedefs

typedef struct mip::C::mip_cmd_queue mip::C::mip_cmd_queue
 Holds a list of pending commands. More...
 

Functions

void mip::C::mip_cmd_queue_init (mip_cmd_queue *queue, mip_timeout base_reply_timeout)
 Initializes a command queue. More...
 
void mip::C::mip_cmd_queue_enqueue (mip_cmd_queue *queue, mip_pending_cmd *cmd)
 Queue a command to wait for replies. More...
 
void mip::C::mip_cmd_queue_dequeue (mip_cmd_queue *queue, mip_pending_cmd *cmd)
 Removes a pending command from the queue. More...
 
void mip::C::mip_cmd_queue_clear (mip_cmd_queue *queue)
 Clears the command queue. More...
 
void mip::C::mip_cmd_queue_update (mip_cmd_queue *queue, mip_timestamp now)
 Call periodically to make sure commands time out if no packets are received. More...
 
void mip::C::mip_cmd_queue_set_base_reply_timeout (mip_cmd_queue *queue, mip_timeout timeout)
 Sets the base reply timeout for all commands. More...
 
mip_timeout mip::C::mip_cmd_queue_base_reply_timeout (const mip_cmd_queue *queue)
 Gets the base reply timeout for all commands. More...
 
void mip::C::mip_cmd_queue_process_packet (mip_cmd_queue *queue, const mip_packet_view *packet, mip_timestamp timestamp)
 Process an incoming packet and check for replies to pending commands. More...
 

Detailed Description

Note
This should be considered an "opaque" structure; its members should be considered an internal implementation detail. Avoid accessing them directly as they are subject to change in future versions of this software.

Typedef Documentation

◆ mip_cmd_queue

Holds a list of pending commands.

Currently only one command may be pending at a time.

Note
This should be considered an "opaque" structure; its members should be considered an internal implementation detail. Avoid accessing them directly as they are subject to change in future versions of this software.

Function Documentation

◆ mip_cmd_queue_base_reply_timeout()

mip_timeout mip::C::mip_cmd_queue_base_reply_timeout ( const mip_cmd_queue queue)

Gets the base reply timeout for all commands.

Returns
The minimum time to wait for a reply to any command.

◆ mip_cmd_queue_clear()

void mip::C::mip_cmd_queue_clear ( mip_cmd_queue queue)

Clears the command queue.

This must be called from the same thread context as the update function.

Parameters
queue

◆ mip_cmd_queue_dequeue()

void mip::C::mip_cmd_queue_dequeue ( mip_cmd_queue queue,
mip_pending_cmd cmd 
)

Removes a pending command from the queue.

◆ mip_cmd_queue_enqueue()

void mip::C::mip_cmd_queue_enqueue ( mip_cmd_queue queue,
mip_pending_cmd cmd 
)

Queue a command to wait for replies.

Parameters
queue
cmdListens for replies to this command.
Warning
The command must not be deallocated or go out of scope while the mip_cmd_status_is_finished returns false.

◆ mip_cmd_queue_init()

void mip::C::mip_cmd_queue_init ( mip_cmd_queue queue,
mip_timeout  base_reply_timeout 
)

Initializes a command queue.

Parameters
queue
base_reply_timeoutThe minimum timeout given to all MIP commands. Additional time may be given to specific commands which take longer. This is intended to be used to accommodate long communication latencies, such as when using a TCP connection.

◆ mip_cmd_queue_process_packet()

void mip::C::mip_cmd_queue_process_packet ( mip_cmd_queue queue,
const mip_packet_view packet,
mip_timestamp  timestamp 
)

Process an incoming packet and check for replies to pending commands.

Call this from the Mip_parser callback, passing the arguments directly.

Parameters
queue
packetThe received MIP packet. Assumed to be valid.
timestampThe time the packet was received

◆ mip_cmd_queue_set_base_reply_timeout()

void mip::C::mip_cmd_queue_set_base_reply_timeout ( mip_cmd_queue queue,
mip_timeout  timeout 
)

Sets the base reply timeout for all commands.

The base reply timeout is the minimum time to wait for a reply. Takes effect for any commands queued after this function call.

Parameters
queue
timeout

◆ mip_cmd_queue_update()

void mip::C::mip_cmd_queue_update ( mip_cmd_queue queue,
mip_timestamp  now 
)

Call periodically to make sure commands time out if no packets are received.

Call this during the device update if no calls to mip_cmd_queue_process_packet are made (e.g. because no packets were received). It is safe to call this in either case.

Parameters
queue
now