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