A stream interface.
This class provides an interface for dealing with streaming I/O devices, such as a COM port or a USB port.
Definition at line 20 of file streaminterface.h.
#include <xSens_MT4/xcommunication/include/xsens/streaminterface.h>
Public Member Functions | |
~StreamInterface () | |
Destroy the stream interface. More... | |
virtual XsResultValue | setTimeout (uint32_t ms)=0 |
Set the read/write timeout to ms A timeout of 0 means non-blocking operation of writeData() and readData(). More... | |
virtual uint32_t | getTimeout (void) const =0 |
The timeout used for read/write operations. More... | |
virtual XsResultValue | close (void)=0 |
Close the connection to the device. More... | |
virtual XsResultValue | flushData (void)=0 |
Flush all data in the buffers to and from the device. More... | |
virtual bool | isOpen (void) const =0 |
Returns true if the object has a connection to a device. More... | |
virtual XsResultValue | getLastResult (void) const =0 |
Returns the last result value produced by this interface. More... | |
virtual XsResultValue | writeData (const XsByteArray &data, XsSize *written=NULL)=0 |
Write the data contained in data to the device. More... | |
virtual XsResultValue | readData (XsSize maxLength, XsByteArray &data)=0 |
Read at most maxLength bytes from the device into data. More... | |
virtual XsResultValue | open (const XsPortInfo &portInfo, uint32_t readBufSize=XS_DEFAULT_READ_BUFFER_SIZE, uint32_t writeBufSize=XS_DEFAULT_WRITE_BUFFER_SIZE) |
Open a communication channel to the given port info. More... | |
virtual XsResultValue | open (const XsString &filename, bool createNew, bool readOnly) |
Open a file. More... | |
virtual XsResultValue | waitForData (XsSize maxLength, XsByteArray &data) |
Wait for data to arrive or a timeout to occur. More... | |
virtual void | cancelIo (void) const |
Cancel any pending io requests. More... | |
virtual XsResultValue | appendData (const XsByteArray &bdata) |
Write data to the end of the file. More... | |
virtual XsResultValue | closeAndDelete (void) |
Close the file and delete it. More... | |
virtual XsResultValue | create (const XsString &filename) |
Create an empty file. More... | |
virtual XsResultValue | deleteData (XsFilePos start, XsSize length) |
Delete the given data from the file. More... | |
virtual XsResultValue | find (const XsByteArray &needleV, XsFilePos &pos) |
Find a string of bytes in the file. More... | |
virtual XsFilePos | getFileSize (void) const |
Return the size of the file. More... | |
virtual XsResultValue | getName (XsString &filename) const |
Retrieve the filename that was last successfully opened. More... | |
virtual XsFilePos | getReadPosition (void) const |
Return the current read position. More... | |
virtual XsFilePos | getWritePosition (void) const |
Return the current write position. More... | |
virtual XsResultValue | insertData (XsFilePos start, const XsByteArray &data) |
Insert the given data into the file. More... | |
virtual bool | isReadOnly (void) const |
Return whether the file is readonly or not. More... | |
virtual XsResultValue | setReadPosition (XsFilePos pos) |
Set the new absolute read position. More... | |
virtual XsResultValue | setWritePosition (XsFilePos pos=-1) |
Set the new absolute write position. More... | |
Protected Member Functions | |
StreamInterface () | |
Create a stream interface. More... | |
|
inline |
Destroy the stream interface.
Definition at line 25 of file streaminterface.h.
|
inlineprotected |
Create a stream interface.
Definition at line 40 of file streaminterface.h.
|
virtualinherited |
Write data to the end of the file.
The function writes the given data to the file at the end. The current write position is also moved to the end of the file.
bdata | The byte data to append to the file |
Reimplemented in IoInterfaceFile.
Definition at line 79 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
Cancel any pending io requests.
Reimplemented in SerialInterface.
Definition at line 72 of file iointerface.cpp.
|
pure virtualinherited |
Close the connection to the device.
Implemented in SerialInterface, IoInterfaceFile, and UsbInterface.
|
virtualinherited |
Close the file and delete it.
Reimplemented in IoInterfaceFile.
Definition at line 85 of file iointerface.cpp.
References XRV_INVALIDOPERATION.
|
virtualinherited |
Create an empty file.
filename | The desired (path+)name of the file |
Reimplemented in IoInterfaceFile.
Definition at line 90 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
virtualinherited |
Delete the given data from the file.
The function erases the given data from the file at the given write position. This operation may take a while to complete, but is faster than insertData.
The write position is not changed and the read position is checked for validity upon function exit.
start | The offset of the first byte to delete |
length | The total number of bytes to delete |
Reimplemented in IoInterfaceFile.
Definition at line 96 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
virtualinherited |
Find a string of bytes in the file.
The function searches from the current read position until the given needle
is found. If the needle is not found, XsResultValue::NOT_FOUND is returned. The function will update the seek position to the first character of the found needle.
needleV | The byte string to find. |
pos | The position where needleV was found. This will point to the first character of the found needleV. |
Reimplemented in IoInterfaceFile.
Definition at line 103 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
pure virtualinherited |
Flush all data in the buffers to and from the device.
Implemented in SerialInterface, IoInterfaceFile, and UsbInterface.
Return the size of the file.
Reimplemented in IoInterfaceFile.
Definition at line 110 of file iointerface.cpp.
|
pure virtualinherited |
Returns the last result value produced by this interface.
Implemented in SerialInterface, IoInterfaceFile, and UsbInterface.
|
virtualinherited |
Retrieve the filename that was last successfully opened.
filename | The XsString which will contain the filename. |
Reimplemented in IoInterfaceFile.
Definition at line 115 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
Return the current read position.
Reimplemented in IoInterfaceFile.
Definition at line 121 of file iointerface.cpp.
The timeout used for read/write operations.
Implemented in SerialInterface, and UsbInterface.
Return the current write position.
Reimplemented in IoInterfaceFile.
Definition at line 126 of file iointerface.cpp.
|
virtualinherited |
Insert the given data into the file.
The function writes the given data to the file at the current write position. This operation may take a while to complete.
The write position is placed at the end of the inserted data.
start | The offset in the file to write the first byte |
data | The data to insert in the file |
Reimplemented in IoInterfaceFile.
Definition at line 131 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
pure virtualinherited |
Returns true if the object has a connection to a device.
Implemented in SerialInterface, IoInterfaceFile, and UsbInterface.
|
virtualinherited |
Return whether the file is readonly or not.
Reimplemented in IoInterfaceFile.
Definition at line 138 of file iointerface.cpp.
|
virtualinherited |
Open a communication channel to the given port info.
If the baudrate in portInfo is set to XBR_Invalid, the baud rate is automatically detected if possible.
portInfo | The details of the port that should be opened. Depending on the type of interface, parts of this parameter may be ignored. |
readBufSize | The size of the read buffer in bytes (if appliccable to the device) |
writeBufSize | The size of the write buffer in bytes (if appliccable to the device) |
Reimplemented in SerialInterface, and UsbInterface.
Definition at line 52 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
virtualinherited |
Open a file.
filename | The name of the file to open |
createNew | When true, the file will be created if it doesn't exist yet |
readOnly | When true, the file will be marked as read only for IoInterfaceFile, preventing accidental writes to the file. |
Reimplemented in IoInterfaceFile.
Definition at line 143 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
pure virtualinherited |
Read at most maxLength bytes from the device into data.
maxLength | The maximum number of bytes to read. Depending on the device type and timeout settings, the function may return with less than this number of bytes read. |
data | A buffer that will contain the read data. |
Implemented in SerialInterface, IoInterfaceFile, and UsbInterface.
|
virtualinherited |
Set the new absolute read position.
The read position is checked against the filesize first.
pos | The new read position |
Reimplemented in IoInterfaceFile.
Definition at line 151 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
pure virtual |
Set the read/write timeout to ms A timeout of 0 means non-blocking operation of writeData() and readData().
Reimplemented from IoInterface.
Implemented in SerialInterface, and UsbInterface.
|
virtualinherited |
Set the new absolute write position.
The write position is checked against the filesize first.
pos | The new write position |
Reimplemented in IoInterfaceFile.
Definition at line 157 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
virtualinherited |
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 XsResultValue::TIMEOUT if a timeout occurred. A timeout value of 0 indicates that the default timeout stored in the class should be used.
maxLength | The maximum number of bytes to read before returning |
data | The buffer to put the read data in. |
Reimplemented in SerialInterface.
Definition at line 65 of file iointerface.cpp.
References void(), and XRV_INVALIDOPERATION.
|
pure virtualinherited |
Write the data contained in data to the device.
data | The data to write to the device. |
written | An optional XsSize value that will receive the number of bytes that were actually written. |
Implemented in SerialInterface, IoInterfaceFile, and UsbInterface.
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |