Skip to content

Commit

Permalink
Updates per PR feedback (WIP).
Browse files Browse the repository at this point in the history
  • Loading branch information
microstrain-sam committed Nov 1, 2024
1 parent 6b1d9ea commit 14403bd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Known Issues and Workarounds {#known_issues}

### suppress_ack parameters are not supported

Some commands accept a parameter named `suppress_ack` which acts to prevent
Some commands accept a parameter named `suppress_ack` which prevents
the standard ack/nack reply from being returned by the device, e.g. the
3DM Poll Data command. Use of this parameter is not directly supported by the MIP SDK
3DM Poll Data command. Use of this parameter is not fully supported by the MIP SDK
and will cause the command to appear to time out after a short delay.

If you wish to use this feature, (i.e. just send the command without waiting for an ACK/NACK),
Expand Down
2 changes: 1 addition & 1 deletion docs/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To (de)serialize a buffer, follow these steps:
1. Create a serializer and initialize it via @ref microstrain_serializer_init_insertion
or @ref microstrain_serializer_init_extraction, depending on whether you're
writing or reading data.
2. Call `microstrain_insert_*` or `microstrain_extract_*` for each parameter. E.g. @ref microstrain_extract_u32.
2. Call `microstrain_insert_*` or `microstrain_extract_*` for each parameter. E.g. [microstrain_extract_u32](@ref mip::C::microstrain_extract_u32].
3. Call @ref microstrain_serializer_is_ok to check if all the data was written/read successfully (i.e. fit in the buffer).
Alternatively, to verify if exactly buffer_size bytes were read/written, use @ref microstrain_serializer_is_complete.
4. Transmit the written buffer or use the deserialized parameters.
Expand Down
16 changes: 8 additions & 8 deletions examples/mip_packet_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void print_packet(const mip::PacketView& packet, const char* name)
);

// Print each byte in the packet, including header and checksum.
for(size_t i=0; i<packet.totalLength(); i++)
for(size_t i=0; i < packet.totalLength(); i++)
{
std::printf("%02X", packet[i]);
}
Expand All @@ -49,7 +49,7 @@ void print_packet(const mip::PacketView& packet, const char* name)
std::printf(" (%02X,%02X): payload=[", field.descriptorSet(), field.fieldDescriptor());

// Print field payload bytes.
for(size_t i=0; i<field.payloadLength(); i++)
for(size_t i=0; i < field.payloadLength(); i++)
{
// Note: this indexes the payload, excluding the header, whereas packet[i] indexes the whole packet.
std::printf("%02X", field[i]);
Expand All @@ -65,7 +65,7 @@ void print_packet(const mip::PacketView& packet, const char* name)
// what's happening "under the hood".
void create_packet_from_scratch()
{
puts("\nCreate packet from scratch");
std::puts("\nCreate packet from scratch");

// Create a mip packet with a built-in buffer.
// A PacketBuf is the combination of a PacketView and a buffer.
Expand Down Expand Up @@ -263,7 +263,7 @@ void create_packet_from_scratch()

void create_packet_from_buffer()
{
puts("\nCreate packet from buffer");
std::puts("\nCreate packet from buffer");

const uint8_t buffer[] = {
0x75, 0x65, 0x80, 0x4c, 0x0a, 0xd5, 0x00, 0x00, 0x00, 0x05, 0x5e, 0xe6, 0x7c, 0xc0, 0x0a, 0xd6,
Expand Down Expand Up @@ -311,7 +311,7 @@ void create_packet_from_buffer()
// Is this a sensor data packet?
if(packet1.descriptorSet() == mip::data_sensor::DESCRIPTOR_SET)
{
puts("Sensor Data packet:");
std::puts("Sensor Data packet:");

for(mip::FieldView field : packet1)
{
Expand All @@ -324,7 +324,7 @@ void create_packet_from_buffer()
uint64_t nanoseconds;

if(serializer.extract(nanoseconds))
printf(" Ref Time = %lu\n", nanoseconds);
std::printf(" Ref Time = %lu\n", nanoseconds);

break;
}
Expand All @@ -333,7 +333,7 @@ void create_packet_from_buffer()
mip::data_sensor::ScaledAccel data;

if(serializer.extract(data))
printf(" Scaled Accel = (%f, %f, %f)\n", data.scaled_accel[0], data.scaled_accel[1], data.scaled_accel[2]);
std::printf(" Scaled Accel = (%f, %f, %f)\n", data.scaled_accel[0], data.scaled_accel[1], data.scaled_accel[2]);

break;
}
Expand All @@ -344,7 +344,7 @@ void create_packet_from_buffer()
// This calls the FieldView::extract helper function which handles deserialization directly.
// This is the simplest and preferred method.
if(field.extract(data))
printf(" Scaled Gyro = (%f, %f, %f)\n", data.scaled_gyro[0], data.scaled_gyro[1], data.scaled_gyro[2]);
std::printf(" Scaled Gyro = (%f, %f, %f)\n", data.scaled_gyro[0], data.scaled_gyro[1], data.scaled_gyro[2]);

break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/c/mip/mip_cmdqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ extern "C" {
///@{

////////////////////////////////////////////////////////////////////////////////
///@defgroup MipCommandQueue_c Mip Command Queue
///@defgroup MipCommandHandling_c Mip Command Handling
///
///@brief Functions for handling command responses.
///
///@{


////////////////////////////////////////////////////////////////////////////////
///@defgroup PendingCommand_c mip_pending_cmd functions
///@defgroup PendingCommand_c Mip Pending Command Functions
///
///@{

Expand Down Expand Up @@ -72,7 +72,7 @@ bool mip_pending_cmd_check_timeout(const mip_pending_cmd* cmd, mip_timestamp now

///@}
////////////////////////////////////////////////////////////////////////////////
///@defgroup CommandQueue_c mip_cmd_queue functions
///@defgroup CommandQueue_c Mip Command Queue Functions
///
///@note This should be considered an "opaque" structure; its members should be
/// considered an internal implementation detail. Avoid accessing them directly
Expand Down
6 changes: 3 additions & 3 deletions src/c/mip/mip_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern "C" {


////////////////////////////////////////////////////////////////////////////////
///@defgroup MipDispatch_c Mip Dispatch
///@defgroup MipDispatch_c Mip Data Dispatch System
///
///@brief System for issuing callbacks from MIP packets or fields.
///
Expand Down Expand Up @@ -69,7 +69,7 @@ enum {
};

////////////////////////////////////////////////////////////////////////////////
///@defgroup mip_dispatch_handler mip_dispatch_handler
///@defgroup mip_dispatch_handler Mip Data Dispatch Handler
///
/// This represents a binding between a MIP descriptor pair and a callback
/// function.
Expand Down Expand Up @@ -112,7 +112,7 @@ bool mip_dispatch_handler_is_enabled(mip_dispatch_handler* handler);

///@}
////////////////////////////////////////////////////////////////////////////////
///@defgroup MipDispatchHandler mip_dispatch_handler - Represents a callback
///@defgroup MipDispatcher Mip Data Dispatcher
///
///@{

Expand Down
1 change: 1 addition & 0 deletions src/c/mip/mip_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef struct mip_packet_view
/// Use these functions to create a new packet, add fields, and write the
/// checksum.
///
///@ingroup
///@{

void mip_packet_create(mip_packet_view* packet, uint8_t* buffer, size_t buffer_size, uint8_t descriptor_set);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/mip/mip_packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PacketView : public C::mip_packet_view

///@brief Create a reference to an existing MIP packet.
///@param buffer Buffer containing an existing MIP packet.
///@caution Do not call functions which modify the packet (addField, finalize, reset, etc) unless you know the buffer is not const.
///@warning Do not call functions which modify the packet (addField, finalize, reset, etc) unless you know the buffer is not const.
PacketView(microstrain::Span<const uint8_t> buffer) { C::mip_packet_from_buffer(this, const_cast<uint8_t*>(buffer.data()), buffer.size()); }

//
Expand Down

0 comments on commit 14403bd

Please sign in to comment.