Mid-level serial communication class. More...
#include <Robots/SeaBeeIII/IMUDataServer/cmt2.h>
Public Member Functions | |
Cmt2s () | |
Default constructor, initialize all members to their default values. | |
~Cmt2s () | |
Destructor, de-initialize, free memory allocated for buffers, etc. | |
XsensResultValue | close (void) |
Close the serial communication port. | |
uint32_t | getBaudrate (void) |
Return the baudrate that is currently being used by the port. | |
Cmt1s * | getCmt1s (void) |
Return a reference to the embedded Cmt1s object. | |
XsensResultValue | getLastResult (void) const |
Return the error code of the last operation. | |
XsensResultValue | getPortNr (uint16_t &port) const |
Retrieve the port that the object is connected to. | |
XsensResultValue | getPortNr (int32_t &port) const |
XsensResultValue | getPortName (char *portname) const |
uint32_t | getTimeout (void) const |
Return the current timeout value in ms. | |
bool | isOpen (void) const |
Return whether the communication port is open or not. | |
XsensResultValue | open (const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE, uint32_t readBufSize=CMT_DEFAULT_READ_BUFFER_SIZE, uint32_t writeBufSize=CMT_DEFAULT_WRITE_BUFFER_SIZE) |
Open a communication channel to the given serial port name. | |
XsensResultValue | readMessage (Message *rcv) |
Read a message from the COM port. | |
XsensResultValue | setCallbackFunction (CmtCallbackType tp, int32_t instance, CmtCallbackFunction func, void *param) |
Set the callback function for when a message has been received or sent. | |
XsensResultValue | setTimeout (const uint32_t ms=CMT2_DEFAULT_TIMEOUT) |
Set the default timeout value to use in blocking operations. | |
XsensResultValue | waitForMessage (Message *rcv, const uint8_t msgId, uint32_t timeoutOverride, bool acceptErrorMessage) |
Wait for a message to arrive. | |
XsensResultValue | writeMessage (Message *msg) |
Send a message over the COM port. | |
Protected Attributes | |
uint32_t | m_baudrate |
The baudrate that was last set to be used by the port. | |
Cmt1s | m_cmt1s |
The CMT level 1 object that this class operates on. | |
XsensResultValue | m_lastResult |
The last result of an operation. | |
uint8_t | m_readBuffer [CMT_DEFAULT_READ_BUFFER_SIZE] |
Buffer for reading data until a valid message is read. Should be rarely used. | |
uint16_t | m_readBufferCount |
The number of valid bytes in the readBuffer. | |
uint32_t | m_timeout |
Timeout in ms for blocking operations. | |
uint32_t | m_toEnd |
The timestamp at which to end an operation. |
Mid-level serial communication class.
The class uses CMT level 1, but does not inherit from it. If software needs to access the level 1 component, it needs to be done through the getCmt1s() function.
Definition at line 48 of file cmt2.h.
xsens::Cmt2s::Cmt2s | ( | ) |
Default constructor, initialize all members to their default values.
Definition at line 102 of file cmt2.cpp.
References CMT2_DEFAULT_TIMEOUT, CMT_DEFAULT_BAUD_RATE, m_baudrate, m_lastResult, m_readBufferCount, m_timeout, and m_toEnd.
xsens::Cmt2s::~Cmt2s | ( | ) |
XsensResultValue xsens::Cmt2s::close | ( | void | ) |
Close the serial communication port.
Definition at line 120 of file cmt2.cpp.
References xsens::Cmt1s::close(), xsens::Cmt1s::getPortNr(), m_cmt1s, m_lastResult, and m_toEnd.
Referenced by xsens::Cmt3::closePort(), and xsens::Cmt3::~Cmt3().
uint32_t xsens::Cmt2s::getBaudrate | ( | void | ) | [inline] |
Return the baudrate that is currently being used by the port.
Definition at line 101 of file cmt2.h.
References xsens::Cmt1s::getBaudrate(), m_baudrate, and m_cmt1s.
Cmt1s* xsens::Cmt2s::getCmt1s | ( | void | ) | [inline] |
Return a reference to the embedded Cmt1s object.
Any manipulation of the object should be done through Cmt2s. Cmt2s integrity is not guaranteed if the Cmt1s object is manipulated directly.
Definition at line 107 of file cmt2.h.
References m_cmt1s.
Referenced by xsens::Cmt3::gotoConfig(), xsens::Cmt3::gotoMeasurement(), and xsens::Cmt3::initBus().
XsensResultValue xsens::Cmt2s::getLastResult | ( | void | ) | const [inline] |
Return the error code of the last operation.
Definition at line 109 of file cmt2.h.
References m_lastResult.
Referenced by xsens::Cmt3::gotoConfig().
XsensResultValue xsens::Cmt2s::getPortNr | ( | uint16_t & | port | ) | const |
Retrieve the port that the object is connected to.
Definition at line 145 of file cmt2.cpp.
References xsens::Cmt1s::getPortNr(), m_cmt1s, and m_lastResult.
Referenced by xsens::Cmt3::getPortNr(), and xsens::Cmt3::setBaudrate().
uint32_t xsens::Cmt2s::getTimeout | ( | void | ) | const [inline] |
bool xsens::Cmt2s::isOpen | ( | void | ) | const [inline] |
Return whether the communication port is open or not.
Definition at line 117 of file cmt2.h.
References xsens::Cmt1s::isOpen(), and m_cmt1s.
Referenced by xsens::Cmt3::createLogFile(), xsens::Cmt3::getBaudrate(), xsens::Cmt3::getConfiguration(), xsens::Cmt3::getDeviceCount(), xsens::Cmt3::getEMtsData(), xsens::Cmt3::getMtCount(), xsens::Cmt3::isPortOpen(), xsens::Cmt3::openLogFile(), xsens::Cmt3::refreshCache(), and xsens::Cmt3::setDataSource().
XsensResultValue xsens::Cmt2s::open | ( | const char * | portName, | |
const uint32_t | baudRate = CMT_DEFAULT_BAUD_RATE , |
|||
uint32_t | readBufSize = CMT_DEFAULT_READ_BUFFER_SIZE , |
|||
uint32_t | writeBufSize = CMT_DEFAULT_WRITE_BUFFER_SIZE | |||
) |
Open a communication channel to the given serial port name.
Definition at line 165 of file cmt2.cpp.
References m_baudrate, m_cmt1s, m_lastResult, m_toEnd, and xsens::Cmt1s::open().
XsensResultValue xsens::Cmt2s::readMessage | ( | Message * | rcv | ) |
Read a message from the COM port.
The function reads data from the embedded Cmt1s object. The data is then converted into a Message object. If an error occurred, a NULL pointer is returned and the error code can be retrieved with getLastError().
Definition at line 191 of file cmt2.cpp.
References CMT_CALLBACK_ONMESSAGERECEIVED, xsens::Message::getMessageStart(), xsens::Cmt1s::getPortNr(), xsens::Message::loadFromString(), m_cmt1s, m_lastResult, m_readBuffer, m_readBufferCount, and xsens::Cmt1s::readData().
Referenced by xsens::Cmt3::readDataPacket().
XsensResultValue xsens::Cmt2s::setCallbackFunction | ( | CmtCallbackType | tp, | |
int32_t | instance, | |||
CmtCallbackFunction | func, | |||
void * | param | |||
) |
Set the callback function for when a message has been received or sent.
Definition at line 318 of file cmt2.cpp.
References CMT_CALLBACK_ONMESSAGERECEIVED, CMT_CALLBACK_ONMESSAGESENT, and m_lastResult.
XsensResultValue xsens::Cmt2s::setTimeout | ( | const uint32_t | ms = CMT2_DEFAULT_TIMEOUT |
) |
Set the default timeout value to use in blocking operations.
This function sets the level 2 timeout value. The L1 value is set to half the given timeout value.
Definition at line 340 of file cmt2.cpp.
References m_cmt1s, m_lastResult, m_timeout, m_toEnd, and xsens::Cmt1s::setTimeout().
Referenced by xsens::Cmt3::gotoConfig(), xsens::Cmt3::gotoMeasurement(), xsens::Cmt3::setTimeoutConfig(), and xsens::Cmt3::setTimeoutMeasurement().
XsensResultValue xsens::Cmt2s::waitForMessage | ( | Message * | rcv, | |
const uint8_t | msgId, | |||
uint32_t | timeoutOverride, | |||
bool | acceptErrorMessage | |||
) |
Wait for a message to arrive.
The function waits for a message to arrive or until a timeout occurs. If the msgId parameter is set to a value other than 0, the function will wait until a message has arrived with that particular msgId.
Definition at line 352 of file cmt2.cpp.
References xsens::Message::clear(), CMT_CALLBACK_ONMESSAGERECEIVED, xsens::findValidMessage(), xsens::Message::getMessageId(), xsens::Cmt1s::getPortNr(), xsens::getTimeOfDay(), xsens::Message::loadFromString(), m_cmt1s, m_lastResult, m_readBuffer, m_readBufferCount, m_timeout, m_toEnd, and xsens::Cmt1s::readData().
Referenced by xsens::Cmt3::getEMtsData(), xsens::Cmt3::getSyncInMode(), xsens::Cmt3::getSyncInOffset(), xsens::Cmt3::getSyncInSettings(), xsens::Cmt3::getSyncInSkipFactor(), xsens::Cmt3::getSyncOutMode(), xsens::Cmt3::getSyncOutOffset(), xsens::Cmt3::getSyncOutPulseWidth(), xsens::Cmt3::getSyncOutSettings(), xsens::Cmt3::getSyncOutSkipFactor(), xsens::Cmt3::gotoConfig(), xsens::Cmt3::gotoMeasurement(), xsens::Cmt3::refreshCache(), xsens::Cmt3::reset(), xsens::Cmt3::setBaudrate(), xsens::Cmt3::setDeviceMode2(), xsens::Cmt3::setGpsLeverArm(), xsens::Cmt3::setLatLonAlt(), xsens::Cmt3::setObjectAlignmentMatrix(), xsens::Cmt3::setSyncInMode(), xsens::Cmt3::setSyncInOffset(), xsens::Cmt3::setSyncInSettings(), xsens::Cmt3::setSyncInSkipFactor(), xsens::Cmt3::setSyncOutMode(), xsens::Cmt3::setSyncOutOffset(), xsens::Cmt3::setSyncOutPulseWidth(), xsens::Cmt3::setSyncOutSettings(), xsens::Cmt3::setSyncOutSkipFactor(), xsens::Cmt3::storeXkfState(), and xsens::Cmt3::waitForDataMessage().
XsensResultValue xsens::Cmt2s::writeMessage | ( | Message * | msg | ) |
Send a message over the COM port.
The function attempts to write the message over the connected COM port.
msg | The message to send. |
Definition at line 532 of file cmt2.cpp.
References CMT_CALLBACK_ONMESSAGESENT, xsens::Message::getMessageStart(), xsens::Cmt1s::getPortNr(), xsens::Message::getTotalMessageSize(), m_cmt1s, m_lastResult, and xsens::Cmt1s::writeData().
Referenced by xsens::Cmt3::getEMtsData(), xsens::Cmt3::getSyncInMode(), xsens::Cmt3::getSyncInOffset(), xsens::Cmt3::getSyncInSettings(), xsens::Cmt3::getSyncInSkipFactor(), xsens::Cmt3::getSyncOutMode(), xsens::Cmt3::getSyncOutOffset(), xsens::Cmt3::getSyncOutPulseWidth(), xsens::Cmt3::getSyncOutSettings(), xsens::Cmt3::getSyncOutSkipFactor(), xsens::Cmt3::gotoConfig(), xsens::Cmt3::gotoMeasurement(), xsens::Cmt3::refreshCache(), xsens::Cmt3::reset(), xsens::Cmt3::setBaudrate(), xsens::Cmt3::setDeviceMode2(), xsens::Cmt3::setGpsLeverArm(), xsens::Cmt3::setLatLonAlt(), xsens::Cmt3::setObjectAlignmentMatrix(), xsens::Cmt3::setSyncInMode(), xsens::Cmt3::setSyncInOffset(), xsens::Cmt3::setSyncInSettings(), xsens::Cmt3::setSyncInSkipFactor(), xsens::Cmt3::setSyncOutMode(), xsens::Cmt3::setSyncOutOffset(), xsens::Cmt3::setSyncOutPulseWidth(), xsens::Cmt3::setSyncOutSettings(), xsens::Cmt3::setSyncOutSkipFactor(), xsens::Cmt3::setXmPowerOff(), and xsens::Cmt3::storeXkfState().
uint32_t xsens::Cmt2s::m_baudrate [protected] |
The baudrate that was last set to be used by the port.
Definition at line 77 of file cmt2.h.
Referenced by Cmt2s(), getBaudrate(), and open().
Cmt1s xsens::Cmt2s::m_cmt1s [protected] |
The CMT level 1 object that this class operates on.
Definition at line 79 of file cmt2.h.
Referenced by close(), getBaudrate(), getCmt1s(), getPortNr(), isOpen(), open(), readMessage(), setTimeout(), waitForMessage(), and writeMessage().
XsensResultValue xsens::Cmt2s::m_lastResult [mutable, protected] |
The last result of an operation.
Definition at line 81 of file cmt2.h.
Referenced by close(), Cmt2s(), getLastResult(), getPortNr(), open(), readMessage(), setCallbackFunction(), setTimeout(), waitForMessage(), and writeMessage().
uint8_t xsens::Cmt2s::m_readBuffer[CMT_DEFAULT_READ_BUFFER_SIZE] [protected] |
Buffer for reading data until a valid message is read. Should be rarely used.
Definition at line 83 of file cmt2.h.
Referenced by readMessage(), and waitForMessage().
uint16_t xsens::Cmt2s::m_readBufferCount [protected] |
The number of valid bytes in the readBuffer.
Definition at line 85 of file cmt2.h.
Referenced by Cmt2s(), readMessage(), and waitForMessage().
uint32_t xsens::Cmt2s::m_timeout [protected] |
Timeout in ms for blocking operations.
Definition at line 87 of file cmt2.h.
Referenced by Cmt2s(), getTimeout(), setTimeout(), and waitForMessage().
uint32_t xsens::Cmt2s::m_toEnd [protected] |
The timestamp at which to end an operation.
Definition at line 89 of file cmt2.h.
Referenced by close(), Cmt2s(), open(), setTimeout(), and waitForMessage().