31 std::chrono::milliseconds timeout)
52 askSampleCommand =
"$VNBOM,1*45\n";
55 askSampleCommand =
"$VNBOM,1*749D\n";
58 askSampleCommand =
"$VNBOM,1*XX\n";
76 LOG_ERR(
logger,
"Unable to disable async messages from vn100");
82 LOG_ERR(
logger,
"Unable to config the user vn100 serial port");
93 if (!setBinaryOutput())
103 LOG_ERR(
logger,
"Unable to set the vn100 user selected CRC");
109 LOG_ERR(
logger,
"Unable to disable async messages from vn100");
134 sampleOutcome = getBinaryOutput<BinaryData>(binData, askSampleCommand);
142 sizeof(binData)) == 0);
144 if (sampleOutcome && !validChecksum)
148 sampleOutcome = sampleOutcome && validChecksum;
152 buildBinaryData(binData, data, timestamp);
162void VN100Serial::buildBinaryData(
const BinaryData& binData,
164 const uint64_t sampleTimestamp)
200bool VN100Serial::setBinaryOutput()
212 const char* setBinarySampleCommand =
"";
216 setBinarySampleCommand =
"$VNWRG,75,0,16,01,0530*44\n";
219 setBinarySampleCommand =
"$VNWRG,75,0,16,01,0530*9CFA\n";
222 setBinarySampleCommand =
"$VNWRG,75,0,16,01,0530*XX\n";
231 "sendStringCommand() failed, cannot set binary output");
238 "recvStringCommand() failed, cannot set binary output");
#define LOG_WARN(logger,...)
#define LOG_ERR(logger,...)
Driver for STM32F4 low level USART/UART peripheral.
void clearQueue()
Clears the rxQueue.
bool init() override
Initialize the sensor.
bool selfTest() override
Check if the sensor is working.
VN100Serial(USART &usart, int baudrate, CRCOptions crc, std::chrono::milliseconds timeout)
Constructor.
VN100SerialData sampleImpl() override
Sample action implementation.
uint8_t checkErrorVN(const char *message)
Check if the message received from the sensor contains an error.
uint16_t calculateChecksum16(const uint8_t *message, int length)
Calculate the 16bit array on the given array.
bool setCrc(bool waitResponse=true)
Sets the user selected crc method.
static const uint8_t recvStringMaxDimension
Maximum size of the receiving string.
bool verifyModelNumber(const char *expectedModelNumber)
Verify the model number of the sensor.
bool disableAsyncMessages(bool waitResponse)
Disables the async messages that the sensor is default configured to send at 40Hz on startup.
std::array< char, recvStringMaxDimension > recvString
Buffer used to store the string received from the sensor.
bool recvStringCommand(char *command, int maxLength)
Receives a command from the sensor but swaps the first with a \0 to close the message.
bool configUserSerialPort()
Configures the user defined serial communication.
void configDefaultSerialPort()
Configures the default serial communication.
bool sendStringCommand(std::string command)
Sends the command to the sensor with the correct checksum added so '*' symbol is not needed at the en...
USART & usart
Serial interface that is needed to communicate with the sensor via ASCII codes.
uint64_t getTimestamp()
Returns the current timer value in microseconds.
This file includes all the types the logdecoder script will decode.
SensorErrors
Generic error codes that a sensor can generate.
uint64_t accelerationTimestamp
uint64_t angularSpeedTimestamp
uint64_t magneticFieldTimestamp
uint64_t pressureTimestamp
uint64_t quaternionTimestamp
uint64_t temperatureTimestamp