iointerface.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef IOINTERFACE_H
66 #define IOINTERFACE_H
67 
68 #include "xscontrollerconfig.h"
69 #include <xstypes/xsplatform.h>
70 #include <xstypes/xsmessage.h>
71 #include <xstypes/xstime.h>
72 #include <xstypes/xsfilepos.h>
73 #include <xstypes/xsbytearray.h>
74 #include <xstypes/xsresultvalue.h>
75 #include <xstypes/xsfile.h>
76 
77 #include <stdlib.h>
78 
80 #define XS_DEFAULT_READ_BUFFER_SIZE (XS_MAXMSGLEN*8)
81 #define XS_DEFAULT_WRITE_BUFFER_SIZE XS_MAXMSGLEN
83 
84 struct XsPortInfo;
85 
87 {
88 public:
90  virtual ~IoInterface() {}
91 
95  virtual XsResultValue close(void) = 0;
96 
100  virtual XsResultValue flushData(void) = 0;
101 
105  virtual bool isOpen(void) const = 0;
106 
110  virtual XsResultValue getLastResult(void) const = 0;
111 
118  virtual XsResultValue writeData(const XsByteArray& data, XsFilePos* written = nullptr) = 0;
119 
127  virtual XsResultValue readData(XsFilePos maxLength, XsByteArray& data) = 0;
128 
131  {
137  PO_TwoStopBits = (1 << 3),
139  };
140  // SerialInterface overridable functions
142  virtual XsResultValue setTimeout(uint32_t ms);
143  virtual XsResultValue waitForData(XsFilePos maxLength, XsByteArray& data);
144  virtual void cancelIo(void) const;
145 
146  // IOInterfaceFile overridable functions
147  virtual XsResultValue appendData(const XsByteArray& bdata);
148  virtual XsResultValue closeAndDelete(void);
149  virtual XsResultValue create(const XsString& filename);
150  virtual XsResultValue deleteData(XsFilePos start, XsFilePos length);
151  virtual XsResultValue find(const XsByteArray& needleV, XsFilePos& pos);
152  virtual XsFilePos getFileSize(void) const;
153  virtual XsResultValue getName(XsString& filename) const;
154  virtual XsFilePos getReadPosition(void) const;
155  virtual XsFilePos getWritePosition(void) const;
156  virtual XsResultValue insertData(XsFilePos start, const XsByteArray& data);
157  virtual bool isReadOnly(void) const;
158  virtual XsResultValue open(const XsString& filename, bool createNew, bool readOnly);
160  virtual XsResultValue setWritePosition(XsFilePos pos = -1);
161 
162 protected:
165  {}
166 
168 };
169 #endif
IoInterface::getName
virtual XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
Definition: iointerface.cpp:157
IoInterface::PO_NoFlowControl
@ PO_NoFlowControl
Definition: iointerface.h:132
IoInterface::closeAndDelete
virtual XsResultValue closeAndDelete(void)
Close the file and delete it.
Definition: iointerface.cpp:127
IoInterface::getLastResult
virtual XsResultValue getLastResult(void) const =0
Returns the last result value produced by this interface.
IoInterface::IoInterface
IoInterface()
Constructor.
Definition: iointerface.h:164
IoInterface::flushData
virtual XsResultValue flushData(void)=0
Flush all data in the buffers to and from the device.
IoInterface::setReadPosition
virtual XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
Definition: iointerface.cpp:193
IoInterface::writeData
virtual XsResultValue writeData(const XsByteArray &data, XsFilePos *written=nullptr)=0
Write the data contained in data to the device.
IoInterface::PO_TwoStopBits
@ PO_TwoStopBits
Definition: iointerface.h:137
XsByteArray
A list of uint8_t values.
IoInterface::PO_RtsCtsFlowControl
@ PO_RtsCtsFlowControl
Definition: iointerface.h:133
xsfile.h
IoInterface::readData
virtual XsResultValue readData(XsFilePos maxLength, XsByteArray &data)=0
Read at most maxLength bytes from the device into data.
IoInterface::~IoInterface
virtual ~IoInterface()
Destructor.
Definition: iointerface.h:90
xsplatform.h
IoInterface::isOpen
virtual bool isOpen(void) const =0
Returns true if the object has a connection to a device.
IoInterface::PortOptions
PortOptions
Options for flow control and stopbits which must be used when opening a port.
Definition: iointerface.h:130
XS_DEFAULT_READ_BUFFER_SIZE
#define XS_DEFAULT_READ_BUFFER_SIZE
The default size of the serial read buffer in bytes.
Definition: iointerface.h:80
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
XS_DEFAULT_WRITE_BUFFER_SIZE
#define XS_DEFAULT_WRITE_BUFFER_SIZE
The default size of the serial write buffer in bytes.
Definition: iointerface.h:82
IoInterface::getFileSize
virtual XsFilePos getFileSize(void) const
Return the size of the file.
Definition: iointerface.cpp:152
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
XsPortInfo
Contains a descriptor for opening a communication port to an Xsens device.
Definition: xsportinfo.h:128
IoInterface::create
virtual XsResultValue create(const XsString &filename)
Create an empty file.
Definition: iointerface.cpp:132
IoInterface::getWritePosition
virtual XsFilePos getWritePosition(void) const
Return the current write position.
Definition: iointerface.cpp:168
IoInterface::PO_XsensDefaults
@ PO_XsensDefaults
Definition: iointerface.h:138
IoInterface::close
virtual XsResultValue close(void)=0
Close the connection to the device.
IoInterface::setTimeout
virtual XsResultValue setTimeout(uint32_t ms)
Set the default timeout value to use in blocking operations.
Definition: iointerface.cpp:101
IoInterface::XSENS_DISABLE_COPY
XSENS_DISABLE_COPY(IoInterface)
IoInterface::find
virtual XsResultValue find(const XsByteArray &needleV, XsFilePos &pos)
Find a string of bytes in the file.
Definition: iointerface.cpp:145
IoInterface::PO_DtrDsrFlowControl
@ PO_DtrDsrFlowControl
Definition: iointerface.h:134
IoInterface::deleteData
virtual XsResultValue deleteData(XsFilePos start, XsFilePos length)
Delete the given data from the file.
Definition: iointerface.cpp:138
xsmessage.h
IoInterface
An abstract IO interface.
Definition: iointerface.h:86
IoInterface::setWritePosition
virtual XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
Definition: iointerface.cpp:199
IoInterface::cancelIo
virtual void cancelIo(void) const
Cancel any pending io requests.
Definition: iointerface.cpp:114
xstime.h
IoInterface::waitForData
virtual XsResultValue waitForData(XsFilePos maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:107
IoInterface::PO_OneStopBit
@ PO_OneStopBit
Definition: iointerface.h:136
IoInterface::insertData
virtual XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
Definition: iointerface.cpp:173
xsbytearray.h
xsfilepos.h
xsresultvalue.h
IoInterface::open
virtual XsResultValue open(const XsPortInfo &portInfo, XsFilePos readBufSize=XS_DEFAULT_READ_BUFFER_SIZE, XsFilePos writeBufSize=XS_DEFAULT_WRITE_BUFFER_SIZE, PortOptions options=PO_XsensDefaults)
Open a communication channel to the given port info.
Definition: iointerface.cpp:96
XsFilePos
int64_t XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:102
XsString
A 0-terminated managed string of characters.
IoInterface::appendData
virtual XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
Definition: iointerface.cpp:121
IoInterface::getReadPosition
virtual XsFilePos getReadPosition(void) const
Return the current read position.
Definition: iointerface.cpp:163
IoInterface::PO_XonXoffFlowControl
@ PO_XonXoffFlowControl
Definition: iointerface.h:135
xscontrollerconfig.h
IoInterface::isReadOnly
virtual bool isReadOnly(void) const
Return whether the file is read-only or not.
Definition: iointerface.cpp:180


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20