Open sebuck opened 10 months ago
debugMode
and using getDebugData
on the connection object allows you to get the raw data (read and write) while MSCL still executes MIP parsing on data in.Simple Record to Binary Example This example enables debug mode on the Connection object, opens a file, and writes all data read from the connection to that file, with the option to also include data written to the connection in the binary file. Keep in mind including written data can end up interrupting read data resulting in incomplete data packets when reading back the binary file.
#pragma once
#include "mscl/mscl.h"
using namespace std;
void recordRawBinaryData(mscl::InertialNode& node)
{
// set message format to support channels to ensure all data required for full analysis is included
// if commmented, message format will not be set/overwritten
//node.setFactoryStreamingChannels(mscl::InertialTypes::FactoryStreamingOption::FACTORY_STREAMING_OVERWRITE);
// enable debug mode so MSCL will collect raw byte info
node.connection().debugMode(true);
// setup file information
ofstream binFile;
string filepath = "";
binFile.open(filepath.c_str(), std::ios::out | std::ios::binary);
// listen and record continuously
while (true)
{
// get raw binary data over the connection
mscl::ConnectionDebugDataVec data = node.connection().getDebugData(1000);
// loop through data
for (auto i : data)
{
//cout << endl;
if (i.fromRead())
{
//cout << "Read (" << i.timestamp().str() << ")" << endl;
}
else
{
//cout << "Write (" << i.timestamp().str() << ")" << endl;
// comment out 'continue' to include commands/packets sent to the device in the binary file
// with 'continue' uncommented, only data, command responses, packets fread from the device will be recorded
continue;
}
// loop through each byte of data
for (auto byte : i.data())
{
// write data byte to file
binFile.write((char*)&byte, sizeof(uint8_t));
//cout << setfill('0') << setw(2) << hex << static_cast<unsigned short>(byte);// << " ";
}
//cout << endl;
}
}
// close file
binFile.close();
}
Thank you for your quick response! Yes, I do see how the MIP SDK is more flexible and can support reading (and writing). Unfortunately, we currently can't use the C++ MIP SDK. However, we will eventually need to create tools to read and parse our binary files which should be able to leverage the MIP SDK.
I'm using MSCL and an IntertialNode to read and PARSE my 3DM-GQ7's messages. For future processing, I also need to both write and read the raw binary stream to disk. I'm hoping to continue to leverage MSCL's parsing and to not write my own parser.