|
xsens_imu
|
The low-level serial communication class. More...
#include <cmt1.h>
Public Member Functions | |
| Cmt1s () | |
| Default constructor, initializes all members to their default values. More... | |
| ~Cmt1s () | |
| Destructor, de-initializes, frees memory allocated for buffers, etc. More... | |
| XsensResultValue | close (void) |
| Close the serial communication port. More... | |
| XsensResultValue | escape (const CmtControlLine mask, const CmtControlLine state) |
| Manipulate the Serial control lines. More... | |
| XsensResultValue | flushData (void) |
| Flush all data to be transmitted / received. More... | |
| uint32_t | getBaudrate (void) const |
| Return the baudrate that is currently being used by the port. More... | |
| HANDLE | getHandle (void) const |
| Return the handle of the port. More... | |
| uint16_t | getPortNr (void) const |
| Retrieve the port number that was last successfully opened. More... | |
| void | getPortName (char *portname) const |
| Retrieve the port name that was last successfully opened. More... | |
| XsensResultValue | getLastResult (void) const |
| Return the error code of the last operation. More... | |
| uint32_t | getTimeout (void) const |
| Return the current timeout value. More... | |
| bool | isOpen (void) const |
| Return whether the communication port is open or not. More... | |
| 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 communcation channel to the given serial port name. More... | |
| XsensResultValue | readData (const uint32_t maxLength, uint8_t *data, uint32_t *length=NULL) |
| Read data from the serial port and put it into the data buffer. More... | |
| XsensResultValue | setCallbackFunction (CmtCallbackType tp, int32_t instance, CmtCallbackFunction func, void *param) |
| Set the callback function for when bytes have been received. More... | |
| XsensResultValue | setTimeout (const uint32_t ms=CMT1_DEFAULT_TIMEOUT) |
| Set the default timeout value to use in blocking operations. More... | |
| XsensResultValue | waitForData (const uint32_t maxLength, uint8_t *data, uint32_t *length=NULL) |
| Wait for data to arrive or a timeout to occur. More... | |
| XsensResultValue | writeData (const uint32_t length, const uint8_t *data, uint32_t *written) |
| Write the data to the serial port. More... | |
Protected Attributes | |
| uint32_t | m_baudrate |
| The baudrate that was last set to be used by the port. More... | |
| uint32_t | m_endTime |
| The time at which an operation will end in ms, used by several functions. More... | |
| bool | m_isOpen |
| Indicates if the port is open or not. More... | |
| XsensResultValue | m_lastResult |
| The last result of an operation. More... | |
| uint16_t | m_port |
| The opened COM port nr. More... | |
| char | m_portname [32] |
| uint32_t | m_timeout |
| termios | m_commState |
| Stored settings about the serial port. More... | |
| int32_t | m_handle |
| The serial port handle. More... | |
The low-level serial communication class.
| xsens::Cmt1s::Cmt1s | ( | ) |
Default constructor, initializes all members to their default values.
| xsens::Cmt1s::~Cmt1s | ( | ) |
Destructor, de-initializes, frees memory allocated for buffers, etc.
| XsensResultValue xsens::Cmt1s::close | ( | void | ) |
Close the serial communication port.
| XsensResultValue xsens::Cmt1s::escape | ( | const CmtControlLine | mask, |
| const CmtControlLine | state | ||
| ) |
Manipulate the Serial control lines.
The function manipulates the serial control lines that are indicated by the mask parameter. Note that only the DTR and RTS lines can be set by win32.
| mask | Indicates which lines are to be manipulated and which should be left alone. |
| state | Contains the new state of the control lines. |
| XsensResultValue xsens::Cmt1s::flushData | ( | void | ) |
Flush all data to be transmitted / received.
This function tries to send and receive any remaining data immediately and does not return until the buffers are empty.
| uint32_t xsens::Cmt1s::getBaudrate | ( | void | ) | const |
Return the baudrate that is currently being used by the port.
| HANDLE xsens::Cmt1s::getHandle | ( | void | ) | const |
Return the handle of the port.
| XsensResultValue xsens::Cmt1s::getLastResult | ( | void | ) | const |
Return the error code of the last operation.
| void xsens::Cmt1s::getPortName | ( | char * | portname | ) | const |
Retrieve the port name that was last successfully opened.
| uint16_t xsens::Cmt1s::getPortNr | ( | void | ) | const |
Retrieve the port number that was last successfully opened.
| uint32_t xsens::Cmt1s::getTimeout | ( | void | ) | const |
Return the current timeout value.
| bool xsens::Cmt1s::isOpen | ( | void | ) | const |
Return whether the communication port is open or not.
| XsensResultValue xsens::Cmt1s::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 communcation channel to the given serial port name.
The port is automatically initialized to the given baudrate. If the baudrate is set to 0, the baud rate is automatically detected. If possible.
| XsensResultValue xsens::Cmt1s::readData | ( | const uint32_t | maxLength, |
| uint8_t * | data, | ||
| uint32_t * | length = NULL |
||
| ) |
Read data from the serial port and put it into the data buffer.
This function reads as much data as possible from the com port (non-blocking) and put as much data as will fit into the data buffer. Any excess data is stored in the m_readBuffer member variable. If there was enough data in m_readBuffer to fulfill the request, the data parameter is first filled and the port is polled afterwards.
| maxLength | The maximum amount of data read. |
| data | Pointer to a buffer that will store the received data. |
| length | The number of bytes placed into data. |
| XsensResultValue xsens::Cmt1s::setCallbackFunction | ( | CmtCallbackType | tp, |
| int32_t | instance, | ||
| CmtCallbackFunction | func, | ||
| void * | param | ||
| ) |
Set the callback function for when bytes have been received.
| XsensResultValue xsens::Cmt1s::setTimeout | ( | const uint32_t | ms = CMT1_DEFAULT_TIMEOUT | ) |
Set the default timeout value to use in blocking operations.
This function sets the value of m_timeout. There is no infinity value. The value 0 means that all blocking operations now become polling (non-blocking) operations. If the value is set to or from 0, the low-level serial port settings may be changed in addition to the m_timeout value.
| XsensResultValue xsens::Cmt1s::waitForData | ( | const uint32_t | maxLength, |
| uint8_t * | data, | ||
| uint32_t * | length = NULL |
||
| ) |
Wait for data to arrive or a timeout to occur.
The function waits until maxLength data is available or until a timeout occurs. The function returns success if data is available or XsensResultValue::TIMEOUT if a timeout occurred. A timeout value of 0 indicates that the default timeout stored in the class should be used.
| XsensResultValue xsens::Cmt1s::writeData | ( | const uint32_t | length, |
| const uint8_t * | data, | ||
| uint32_t * | written | ||
| ) |
Write the data to the serial port.
The function writes the given data to the connected COM port. The default timeout is respected in this operation.
|
protected |
The baudrate that was last set to be used by the port.
|
protected |
Stored settings about the serial port.
|
protected |
The time at which an operation will end in ms, used by several functions.
|
protected |
The serial port handle.
|
protected |
Indicates if the port is open or not.
|
mutableprotected |
The last result of an operation.
|
protected |
The opened COM port nr.
|
protected |
|
protected |
The default timeout value to use during blocking operations. A value of 0 means that all operations become non-blocking.
1.8.6