Go to the documentation of this file.
9 #ifndef _CMT1_H_2006_04_12
10 #define _CMT1_H_2006_04_12
12 #ifndef _CMTDEF_H_2006_05_01
26 #define _strnicmp strncasecmp
35 #if defined(_DEBUG) || defined(_LOG_ALWAYS)
36 void CMTLOG(
const char* str, ...);
37 #define CMTEXITLOG(str) \
38 JanitorFunc2<const char*, XsensResultValue> _cmtExitLog( \
39 CMTLOG, str " returns %u", m_lastResult);
42 #define CMTEXITLOG(...)
47 int _wcsnicmp(
const wchar_t* s1,
const wchar_t* s2,
int count);
368 const char* filename,
const bool create,
const bool readOnly);
371 const wchar_t* filename,
const bool create,
const bool readOnly);
423 #endif // _CMT1_H_2006_04_12
XsensResultValue open(const char *filename, const bool create, const bool readOnly)
Open a file.
XsensResultValue getLastResult(void) const
Return the error code of the last operation.
CmtFilePos getWritePos(void) const
Return the current write position.
uint8_t getPortNr(void) const
Retrieve the port number that was last successfully opened.
int32_t m_onBytesReceivedInstance
Custom, user supplied parameter for the OnBytesReceived callback function, passed as the first argume...
#define CMT_DEFAULT_READ_BUFFER_SIZE
The default size of the serial read buffer in bytes.
XsensResultValue close(void)
Close the file.
void * m_onBytesReceivedParam
Custom, user supplied parameter for the OnBytesReceived callback function, passed as the last argumen...
XsensResultValue waitForData(const uint32_t maxLength, uint8_t *data, uint32_t *length=nullptr)
Wait for data to arrive or a timeout to occur.
XsensResultValue getLastResult(void) const
Return the result code of the last operation.
uint32_t m_baudrate
The baudrate that was last set to be used by the port.
XsensResultValue getName(char *filename) const
Retrieve the filename that was last successfully opened.
XsensResultValue writeData(const uint32_t length, const uint8_t *data, uint32_t *written)
Write the data to the serial port.
XsensResultValue create(const char *filename)
Open an empty file.
XsensResultValue setCallbackFunction(CmtCallbackSelector tp, int32_t instance, CmtCallbackFunction func, void *param)
Set the callback function for when bytes have been received.
bool isReadOnly(void) const
Return whether the file is readonly or not.
uint32_t getTimeout(void) const
Return the current timeout value.
CmtFilePos m_fileSize
Contains the size of the file.
XsensResultValue insertData(const CmtFilePos start, const uint32_t length, const void *data)
Insert the given data into the file. The function writes the given data to the file at the current wr...
CmtFilePos m_writePos
The last write position in the file.
#define CMT_DEFAULT_WRITE_BUFFER_SIZE
The default size of the serial write buffer in bytes.
void gotoRead(void)
Change from writing to reading mode.
XsensResultValue setWritePos(const CmtFilePos pos=-1)
Set the new absolute write position.
XsensResultValue find(const void *needle, const uint32_t needleLength, CmtFilePos &pos)
Find a string of bytes in the file.
HANDLE m_handle
The serial port handle.
GLuint GLsizei GLsizei * length
FILE * m_handle
The file handle.
bool m_isOpen
Indicates if the port is open or not.
XsensResultValue setReadPos(const CmtFilePos pos)
Set the new absolute read position.
Cmt1f()
Default constructor, initializes all members to their default values.
void getPortName(char *portname) const
Retrieve the port name that was last successfully opened.
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
XsensResultValue m_lastResult
The last result of an operation.
XsensResultValue closeAndDelete(void)
Close the file and delete it.
uint8_t m_port
The opened COM port nr.
#define CMT_DEFAULT_BAUD_RATE
The default baud rate of the Cmt1s serial communication.
XsensResultValue(__cdecl * CmtCallbackFunction)(int32_t, CmtCallbackSelector, void *, void *)
The low-level serial communication class.
GLsizei GLsizei GLenum GLenum const GLvoid * data
bool m_reading
Indicates whether the last operation was a read or write operation. This value is used to check wheth...
GLuint GLuint GLsizei count
#define CMT_MAX_FILENAME_LENGTH
bool isOpen(void) const
Return whether the file is open or not.
wchar_t m_filename_w[CMT_MAX_FILENAME_LENGTH]
Contains the name of the file that was last successfully opened using unicode.
DCB m_commState
Stored settings about the serial port.
XsensResultValue flushData(void)
Flush all data to be transmitted / received.
XsensResultValue deleteData(const CmtFilePos start, const uint32_t length)
Delete the given data from the file. The function erases the given data from the file at the given wr...
The low-level file communication class.
uint32_t m_endTime
The time at which an operation will end in ms, used by several functions.
bool isOpen(void) const
Return whether the communication port is open or not.
Cmt1s()
Default constructor, initializes all members to their default values.
XsensResultValue appendData(const uint32_t length, const void *data)
Write data to the end of the file.
#define CMT1_DEFAULT_TIMEOUT
The default timeout value for blocking CMT1s operations in ms.
CmtFilePos m_readPos
The last read position in the file.
void gotoWrite(void)
Change from reading to writing mode.
XsensResultValue readData(const uint32_t maxLength, void *data, uint32_t *length)
Read data from the file and put it into the data buffer.
bool m_readOnly
Indicates if the file was opened in read-only mode.
HANDLE getHandle(void) const
Return the handle of the port.
bool m_unicode
Indicates if we're using the unicode filename or the regular filename.
XsensResultValue setTimeout(const uint32_t ms=CMT1_DEFAULT_TIMEOUT)
Set the default timeout value to use in blocking operations.
CmtFilePos getFileSize(void) const
Return the size of the file.
~Cmt1s()
Destructor, de-initializes, frees memory allocated for buffers, etc.
char m_filename[CMT_MAX_FILENAME_LENGTH]
Contains the name of the file that was last successfully opened.
XsensResultValue flushData(void)
Flush all data to be written. This function writes any remaining data immediately and does not return...
uint32_t getBaudrate(void) const
Return the baudrate that is currently being used by the port.
CmtFilePos getReadPos(void) const
Return the current read position.
bool m_isOpen
Indicates if the file is open or not.
XsensResultValue writeData(const uint32_t length, const void *data)
Write data to the file.
XsensResultValue escape(const CmtControlLine mask, const CmtControlLine state)
Manipulate the Serial control lines.
XsensResultValue
Xsens return values.
CmtCallbackFunction m_onBytesReceived
The bytes received function.
XsensResultValue close(void)
Close the serial communication port.
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.
The namespace of all Xsens software since 2006.
unsigned __int32 uint32_t
XsensResultValue m_lastResult
The last result of an operation.
XsensResultValue readData(const uint32_t maxLength, uint8_t *data, uint32_t *length=nullptr)
Read data from the serial port and put it into the data buffer.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |