MRPT  1.9.9
iointerface.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #include "iointerface.h"
10 #include <xsens/xsthread.h>
11 #include <cerrno>
12 #ifndef _WIN32
13 #include <fcntl.h> // open, O_RDWR
14 #include <sys/ioctl.h> // ioctl
15 #include <sys/param.h>
16 #include <unistd.h> // close
17 #include <cstdarg>
18 #include <cstring> // strcpy
19 #else
20 #include <io.h>
21 #include <winbase.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
46  interface device such
47  as a file, a com port or a USB port.
48  \note The class is not thread safe.
49 */
50 
51 // IOInterface functions
52 /*! \copydoc SerialInterface::open(const XsPortInfo&, uint32_t, uint32_t) */
54  const XsPortInfo&, uint32_t readBufSize, uint32_t writeBufSize)
55 {
56  (void)readBufSize;
57  (void)writeBufSize;
58  return XRV_INVALIDOPERATION;
59 }
60 /*! \copydoc SerialInterface::setTimeout(uint32_t) */
62 {
63  (void)ms;
64  return XRV_INVALIDOPERATION;
65 }
66 /*! \copydoc SerialInterface::waitForData(XsSize, XsByteArray&) */
68 {
69  (void)maxLength;
70  (void)data;
71  return XRV_INVALIDOPERATION;
72 }
73 /*! \copydoc SerialInterface::cancelIo(void) const */
74 void IoInterface::cancelIo(void) const {}
75 // IOInterfaceFile functions
76 /*! \copydoc IoInterfaceFile::appendData() */
78 {
79  (void)bdata;
80  return XRV_INVALIDOPERATION;
81 }
82 /*! \copydoc IoInterfaceFile::closeAndDelete() */
84 /*! \copydoc IoInterfaceFile::create(const XsString&) */
86 {
87  (void)filename;
88  return XRV_INVALIDOPERATION;
89 }
90 /*! \copydoc IoInterfaceFile::deleteData(XsFilePos, XsSize) */
92 {
93  (void)start;
94  (void)length;
95  return XRV_INVALIDOPERATION;
96 }
97 /*! \copydoc IoInterfaceFile::find(const XsByteArray&, XsFilePos&) */
99 {
100  (void)needleV;
101  (void)pos;
102  return XRV_INVALIDOPERATION;
103 }
104 /*! \copydoc IoInterfaceFile::getFileSize() const */
105 XsFilePos IoInterface::getFileSize(void) const { return 0; }
106 /*! \copydoc IoInterfaceFile::getName(XsString&) const */
108 {
109  (void)filename;
110  return XRV_INVALIDOPERATION;
111 }
112 /*! \copydoc IoInterfaceFile::getReadPosition() const */
113 XsFilePos IoInterface::getReadPosition(void) const { return 0; }
114 /*! \copydoc IoInterfaceFile::getWritePosition() const */
115 XsFilePos IoInterface::getWritePosition(void) const { return 0; }
116 /*! \copydoc IoInterfaceFile::insertData(XsFilePos, const XsByteArray&) */
118 {
119  (void)start;
120  (void)data;
121  return XRV_INVALIDOPERATION;
122 }
123 /*! \copydoc IoInterfaceFile::isReadOnly() const */
124 bool IoInterface::isReadOnly(void) const { return true; }
125 /*! \copydoc IoInterfaceFile::open(const XsString&, bool, bool) */
127  const XsString& filename, bool createNew, bool readOnly)
128 {
129  (void)filename;
130  (void)createNew;
131  (void)readOnly;
132  return XRV_INVALIDOPERATION;
133 }
134 /*! \copydoc IoInterfaceFile::setReadPosition(XsFilePos) */
136 {
137  (void)pos;
138  return XRV_INVALIDOPERATION;
139 }
140 /*! \copydoc IoInterfaceFile::setWritePosition(XsFilePos) */
142 {
143  (void)pos;
144  return XRV_INVALIDOPERATION;
145 }
virtual void cancelIo(void) const
Cancel any pending io requests.
Definition: iointerface.cpp:74
struct XsByteArray XsByteArray
Definition: xsbytearray.h:26
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:91
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:83
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
virtual XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
virtual XsFilePos getReadPosition(void) const
Return the current read position.
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:28
__int64 XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:34
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:53
virtual XsResultValue setTimeout(uint32_t ms)
Set the default timeout value to use in blocking operations.
Definition: iointerface.cpp:61
virtual XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
Definition: iointerface.cpp:77
virtual XsResultValue waitForData(XsSize maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:67
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.
Definition: iointerface.cpp:98
virtual XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
GLuint GLsizei GLsizei * length
Definition: glext.h:4079
virtual XsResultValue create(const XsString &filename)
Create an empty file.
Definition: iointerface.cpp:85
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLsizei maxLength
Definition: glext.h:4991
GLuint start
Definition: glext.h:3532
struct XsString XsString
Definition: xsstring.h:35
unsigned __int32 uint32_t
Definition: rptypes.h:50
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3550
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.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019