Main MRPT website > C++ reference for MRPT 1.5.7
iointerface.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #include <xsens/xsthread.h>
10 #include "iointerface.h"
11 #include <errno.h>
12 #ifndef _WIN32
13 # include <unistd.h> // close
14 # include <sys/ioctl.h> // ioctl
15 # include <fcntl.h> // open, O_RDWR
16 # include <string.h> // strcpy
17 # include <sys/param.h>
18 # include <stdarg.h>
19 #else
20 # include <winbase.h>
21 # include <io.h>
22 #endif
23 
24 #ifndef _CRT_SECURE_NO_DEPRECATE
25 # define _CRT_SECURE_NO_DEPRECATE
26 # ifdef _WIN32
27 # pragma warning(disable:4996)
28 # endif
29 #endif
30 
31 //lint -emacro(534, FSEEK, FSEEK_R)
32 //lint -emacro({534}, FSEEK, FSEEK_R)
33 #ifdef _WIN32
34 # define FSEEK(x) _fseeki64(m_handle, x, SEEK_SET)
35 # define FSEEK_R(x) _fseeki64(m_handle, x, SEEK_END)
36 # define FTELL() _ftelli64(m_handle)
37 #else
38 # define FSEEK(x) fseeko(m_handle, x, SEEK_SET)
39 # define FSEEK_R(x) fseeko(m_handle, x, SEEK_END)
40 # define FTELL() ftello(m_handle)
41 #endif
42 
43 /*! \class IoInterface
44  \brief An abstract IO interface
45  \details An %IoInterface provides a generic interface for dealing with an interface device such
46  as a file, a com port or a USB port.
47  \note The class is not thread safe.
48 */
49 
50 // IOInterface functions
51 /*! \copydoc SerialInterface::open(const XsPortInfo&, uint32_t, uint32_t) */
52 XsResultValue IoInterface::open ( const XsPortInfo&, uint32_t readBufSize, uint32_t writeBufSize)
53 {
54  (void) readBufSize;
55  (void) writeBufSize;
56  return XRV_INVALIDOPERATION;
57 }
58 /*! \copydoc SerialInterface::setTimeout(uint32_t) */
60 {
61  (void) ms;
62  return XRV_INVALIDOPERATION;
63 }
64 /*! \copydoc SerialInterface::waitForData(XsSize, XsByteArray&) */
66 {
67  (void) maxLength;
68  (void) data;
69  return XRV_INVALIDOPERATION;
70 }
71 /*! \copydoc SerialInterface::cancelIo(void) const */
72 void IoInterface::cancelIo(void) const
73 {
74 
75 }
76 
77 // IOInterfaceFile functions
78 /*! \copydoc IoInterfaceFile::appendData() */
80 {
81  (void) bdata;
82  return XRV_INVALIDOPERATION;
83 }
84 /*! \copydoc IoInterfaceFile::closeAndDelete() */
86 {
87  return XRV_INVALIDOPERATION;
88 }
89 /*! \copydoc IoInterfaceFile::create(const XsString&) */
91 {
92  (void) filename;
93  return XRV_INVALIDOPERATION;
94 }
95 /*! \copydoc IoInterfaceFile::deleteData(XsFilePos, XsSize) */
97 {
98  (void) start;
99  (void) length;
100  return XRV_INVALIDOPERATION;
101 }
102 /*! \copydoc IoInterfaceFile::find(const XsByteArray&, XsFilePos&) */
104 {
105  (void) needleV;
106  (void) pos;
107  return XRV_INVALIDOPERATION;
108 }
109 /*! \copydoc IoInterfaceFile::getFileSize() const */
111 {
112  return 0;
113 }
114 /*! \copydoc IoInterfaceFile::getName(XsString&) const */
116 {
117  (void) filename;
118  return XRV_INVALIDOPERATION;
119 }
120 /*! \copydoc IoInterfaceFile::getReadPosition() const */
122 {
123  return 0;
124 }
125 /*! \copydoc IoInterfaceFile::getWritePosition() const */
127 {
128  return 0;
129 }
130 /*! \copydoc IoInterfaceFile::insertData(XsFilePos, const XsByteArray&) */
132 {
133  (void) start;
134  (void) data;
135  return XRV_INVALIDOPERATION;
136 }
137 /*! \copydoc IoInterfaceFile::isReadOnly() const */
138 bool IoInterface::isReadOnly(void) const
139 {
140  return true;
141 }
142 /*! \copydoc IoInterfaceFile::open(const XsString&, bool, bool) */
143 XsResultValue IoInterface::open(const XsString& filename, bool createNew, bool readOnly)
144 {
145  (void) filename;
146  (void) createNew;
147  (void) readOnly;
148  return XRV_INVALIDOPERATION;
149 }
150 /*! \copydoc IoInterfaceFile::setReadPosition(XsFilePos) */
152 {
153  (void) pos;
154  return XRV_INVALIDOPERATION;
155 }
156 /*! \copydoc IoInterfaceFile::setWritePosition(XsFilePos) */
158 {
159  (void) pos;
160  return XRV_INVALIDOPERATION;
161 }
virtual void cancelIo(void) const
Cancel any pending io requests.
Definition: iointerface.cpp:72
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
virtual XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
virtual XsResultValue deleteData(XsFilePos start, XsSize length)
Delete the given data from the file.
Definition: iointerface.cpp:96
virtual bool isReadOnly(void) const
Return whether the file is readonly or not.
virtual XsResultValue closeAndDelete(void)
Close the file and delete it.
Definition: iointerface.cpp:85
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:17
virtual XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
Operation is invalid at this point.
Definition: xsens_std.h:67
virtual XsFilePos getReadPosition(void) const
Return the current read position.
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:26
__int64 XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:33
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.
Definition: iointerface.cpp:52
virtual XsResultValue setTimeout(uint32_t ms)
Set the default timeout value to use in blocking operations.
Definition: iointerface.cpp:59
virtual XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
Definition: iointerface.cpp:79
virtual XsResultValue waitForData(XsSize maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:65
virtual XsFilePos getWritePosition(void) const
Return the current write position.
virtual XsResultValue find(const XsByteArray &needleV, XsFilePos &pos)
Find a string of bytes in the file.
virtual XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
GLuint GLsizei GLsizei * length
Definition: glext.h:3900
virtual XsResultValue create(const XsString &filename)
Create an empty file.
Definition: iointerface.cpp:90
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLsizei maxLength
Definition: glext.h:4504
GLuint start
Definition: glext.h:3512
struct XsString XsString
Definition: xsstring.h:34
unsigned __int32 uint32_t
Definition: rptypes.h:49
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3520
virtual XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
virtual XsFilePos getFileSize(void) const
Return the size of the file.



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