MIP_SDK  v3.0.0-425-g6df21bd
MicroStrain Communications Library for embedded systems
Functions
mip_logging.c File Reference
#include "mip_logging.h"
#include <microstrain/strings.h>
#include <mip/mip_offsets.h>

Functions

bool mip_format_packet_bytes (char *buffer, size_t buffer_size, size_t *index, const mip_packet_view *packet)
 Format MIP packet bytes to a string. More...
 
bool mip_format_packet (char *buffer, size_t buffer_size, size_t *index, const mip_packet_view *packet)
 Format a MIP packet to a human-readable string. More...
 
bool mip_format_field (char *buffer, size_t buffer_size, size_t *index, const mip_field_view *field)
 Format a MIP field to a human-readable string. More...
 
void mip_log_packet (const mip_packet_view *packet, microstrain_log_level level)
 Print a MIP packet to the microstrain logging system. More...
 
void mip_log_field (const mip_field_view *field, microstrain_log_level level)
 Print a MIP field to the microstrain logging system. More...
 
void mip_log_packet_verbose (const mip_packet_view *packet, microstrain_log_level level)
 Prints the details of a MIP packet to the microstrain logging system. More...
 

Function Documentation

◆ mip_format_field()

bool mip_format_field ( char *  buffer,
size_t  buffer_size,
size_t *  index,
const mip_field_view *  field 
)

Format a MIP field to a human-readable string.

The string will identify the field descriptor and payload bytes.

Parameters
bufferPointer to character buffer where string data will be stored. If this is NULL, this function will only compute the required buffer size (set buffer_size = 0 in this case).
buffer_sizeNumber of characters the buffer can hold, including the NULL terminator. Must be 0 if buffer is NULL.
[in,out]indexPosition in buffer where string data will be written. It will be updated with the new index and will point to the new NULL terminator position. If insufficient space is available in buffer, index will still be updated even if it exceeds buffer_size.
fieldField to be printed. There are no restrictions on the field view other than it being initialized; even a view where mip_field_is_valid returns false is allowed.
Returns
True if successful.
False in case of insufficient buffer space.

◆ mip_format_packet()

bool mip_format_packet ( char *  buffer,
size_t  buffer_size,
size_t *  index,
const mip_packet_view *  packet 
)

Format a MIP packet to a human-readable string.

The string will identify the packet descriptor set and the field descriptor and payload for each field in the packet.

Parameters
bufferPointer to character buffer where string data will be stored. If this is NULL, this function will only compute the required buffer size (set buffer_size = 0 in this case).
buffer_sizeNumber of characters the buffer can hold, including the NULL terminator. Must be 0 if buffer is NULL.
[in,out]indexPosition in buffer where string data will be written. It will be updated with the new index and will point to the new NULL terminator position. If insufficient space is available in buffer, index will still be updated even if it exceeds buffer_size.
packetPacket to be printed. There are no restrictions on the packet view other than it being initialized; even a view where mip_packet_is_sane returns false is allowed.
Returns
True if successful.
False in case of insufficient buffer space.

◆ mip_format_packet_bytes()

bool mip_format_packet_bytes ( char *  buffer,
size_t  buffer_size,
size_t *  index,
const mip_packet_view *  packet 
)

Format MIP packet bytes to a string.

The bytes will be grouped by header, field, and checksum. For example, a reset comm speed command would print like this: 75650104 04090501 f2bb

Parameters
bufferPointer to character buffer where string data will be stored. If this is NULL, this function will only compute the required buffer size (set buffer_size = 0 in this case).
buffer_sizeNumber of characters the buffer can hold, including the NULL terminator. Must be 0 if buffer is NULL.
[in,out]indexPosition in buffer where string data will be written. It will be updated with the new index and will point to the new NULL terminator position. If insufficient space is available in buffer, index will still be updated even if it exceeds buffer_size.
packetPacket to be printed. There are no restrictions on the packet view other than it being initialized; even a view where mip_packet_is_sane returns false is allowed.
Returns
True if successful.
False in case of insufficient buffer space.

◆ mip_log_field()

void mip_log_field ( const mip_field_view *  field,
microstrain_log_level  level 
)

Print a MIP field to the microstrain logging system.

See also
mip::C::mip_format_field
Parameters
fieldField to be printed. There are no restrictions on the field view other than it being initialized; even a view where mip_field_is_valid returns false is allowed.
levelLogging level passed to the microstrain log callback. If the current log level is less than this value, nothing is printed.

◆ mip_log_packet()

void mip_log_packet ( const mip_packet_view *  packet,
microstrain_log_level  level 
)

Print a MIP packet to the microstrain logging system.

See also
mip::C::mip_format_packet
Parameters
packetPacket to be printed. There are no restrictions on the packet view other than it being initialized; even a view where mip_packet_is_sane returns false is allowed.
levelLogging level passed to the microstrain log callback. If the current log level is less than this value, nothing is printed.

◆ mip_log_packet_verbose()

void mip_log_packet_verbose ( const mip_packet_view *  packet,
microstrain_log_level  level 
)

Prints the details of a MIP packet to the microstrain logging system.

Parameters
packetPacket to be printed. There are no restrictions on the packet view other than it being initialized; even a view where mip_packet_is_sane returns false is allowed.
levelLogging level passed to the microstrain log callback. If the current log level is less than this value, nothing is printed.