MIP SDK  0.0.1
MicroStrain Communications Library for embedded systems
Functions
User callback functions [C/CPP]

Functions

bool mip::C::mip_interface_user_recv_from_device (mip_interface *device, uint8_t *buffer, size_t max_length, size_t *out_length, timestamp_type *timestamp_out)
 Receives new data from the device. Called repeatedly by mip_interface_update() while waiting for command responses. More...
 
bool mip::C::mip_interface_user_send_to_device (mip_interface *device, const uint8_t *data, size_t length)
 

Detailed Description

Function Documentation

◆ mip_interface_user_recv_from_device()

bool mip::C::mip_interface_user_recv_from_device ( mip_interface device,
uint8_t *  buffer,
size_t  max_length,
size_t *  out_length,
timestamp_type timestamp_out 
)

Receives new data from the device. Called repeatedly by mip_interface_update() while waiting for command responses.

Parameters
deviceThe mip interface object
bufferBuffer to fill with data. Should be allocated before calling this function
max_lengthMax number of bytes that can be read into the buffer.
out_lengthNumber of bytes actually read into the buffer.
timestamp_outTimestamp of the data was received.
Returns
true if operation should continue, or false if the device cannot be updated (e.g. if the serial port is not open).
Note
Except in case of error (i.e. returning false), the timestamp must be set even if no data is received. This is required to allow commands to time out.
On systems where it makes sense, this is a good place to call sleep or enter a low-power state until data arrives at the port. Typically this function will wait a few milliseconds before returning.
Warning
Do not block indefinitely as this will stall the system beyond the normal command timeout. Use a sensible timeout (i.e. 1/10th of the base reply timeout) or only sleep for a minimal amount of time.

◆ mip_interface_user_send_to_device()

bool mip::C::mip_interface_user_send_to_device ( mip_interface device,
const uint8_t *  data,
size_t  length 
)

Note
This is a good place to put logging code for debugging device communications at the byte level.
There are cases where the data will not be a MIP packet.