Main MRPT website > C++ reference for MRPT 1.9.9
usbinterface.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, 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 #ifndef USBINTERFACE_H
10 #define USBINTERFACE_H
11 
12 #include <xsens/xstime.h>
13 
14 #include <stdlib.h>
15 #include <stdio.h>
16 #ifdef _WIN32
17 #include <windows.h>
18 //# include <sys/types.h>
19 #else
20 #include <termios.h>
21 // these are not required by level 1, but to keep the higher levels
22 // platform-independent they are put here
23 #include <string.h>
24 #include <stddef.h>
25 #define _strnicmp strncasecmp
26 #endif
27 
28 #include "streaminterface.h"
29 #include <stdio.h>
30 
31 struct XsPortInfo;
32 
34 
36 {
37  public:
38  UsbInterface();
39  ~UsbInterface();
40 
42  const XsPortInfo& portInfo, uint32_t readBufSize = 0,
43  uint32_t writeBufSize = 0);
44  XsResultValue close(void);
45  XsResultValue closeUsb(void);
47 
48  bool isOpen(void) const;
49  uint8_t usbBus() const;
50  uint8_t usbAddress() const;
51 
52  XsResultValue getLastResult(void) const;
53 
55  uint32_t getTimeout(void) const;
56 
57  void setRawIo(bool enable);
58  bool getRawIo(void);
59 
60  virtual XsResultValue writeData(
61  const XsByteArray& data, XsSize* written = nullptr);
64 
65  // lint -e1411 inherited definitions are also available (see above)
67  XsSize length, const void* data, XsSize* written = nullptr);
69  XsSize maxLength, void* data, XsSize* length = nullptr);
71  XsSize maxLength, void* data, XsSize* length = nullptr);
72  // lint +e1411
73 
74  void getPortName(XsString& portname) const;
75 
76  private:
79 };
80 
81 #endif // file guard
UsbInterface::UsbInterface
UsbInterface()
Default constructor, initializes all members to their default values.
Definition: usbinterface.cpp:406
XsString
struct XsString XsString
Definition: xsstring.h:34
maxLength
GLsizei maxLength
Definition: glext.h:4932
UsbInterface::getTimeout
uint32_t getTimeout(void) const
Return the current timeout value.
Definition: usbinterface.cpp:580
UsbInterface::d
UsbInterfacePrivate * d
Definition: usbinterface.h:78
XsPortInfo
Definition: xsportinfo.h:46
XsByteArray
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
UsbInterface::open
XsResultValue open(const XsPortInfo &portInfo, uint32_t readBufSize=0, uint32_t writeBufSize=0)
Open a communication channel to the given USB port name.
Definition: usbinterface.cpp:584
UsbInterface::isOpen
bool isOpen(void) const
Return whether the USB communication port is open or not.
Definition: usbinterface.cpp:582
UsbInterfacePrivate
Private object for UsbInterface.
Definition: usbinterface.cpp:35
UsbInterface::setRawIo
void setRawIo(bool enable)
Sets the RAWIO mode of the USB interface.
Definition: usbinterface.cpp:992
UsbInterface::usbAddress
uint8_t usbAddress() const
The address of the device (libusb/linux only)
Definition: usbinterface.cpp:1172
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
length
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:27
streaminterface.h
UsbInterface::getRawIo
bool getRawIo(void)
Retrieves the state of the RAWIO mode of the USB interface.
Definition: usbinterface.cpp:1012
UsbInterface::setTimeout
XsResultValue setTimeout(uint32_t ms)
Set the default timeout value to use in blocking operations.
Definition: usbinterface.cpp:961
UsbInterface::closeUsb
XsResultValue closeUsb(void)
Close the USB communication port.
Definition: usbinterface.cpp:464
UsbInterface::getLastResult
XsResultValue getLastResult(void) const
Return the error code of the last operation.
Definition: usbinterface.cpp:574
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3547
StreamInterface
A stream interface.
Definition: streaminterface.h:21
UsbInterface
An IoInterface for dealing specifically with Xsens USB devices.
Definition: usbinterface.h:35
UsbInterface::writeData
virtual XsResultValue writeData(const XsByteArray &data, XsSize *written=nullptr)
Write the data to the USB port.
Definition: usbinterface.cpp:1081
UsbInterface::usbBus
uint8_t usbBus() const
The USB bus number this device is on (libusb/linux only)
Definition: usbinterface.cpp:1156
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
XSENS_DISABLE_COPY
#define XSENS_DISABLE_COPY(className)
Add this macro to the start of a class definition to prevent automatic creation of copy functions.
Definition: xcommunicationconfig.h:149
UsbInterface::readData
virtual XsResultValue readData(XsSize maxLength, XsByteArray &data)
Read data from the USB port and put it into the data buffer.
Definition: usbinterface.cpp:871
UsbInterface::getPortName
void getPortName(XsString &portname) const
Retrieve the port name that was last successfully opened.
Definition: usbinterface.cpp:1188
UsbInterface::flushData
XsResultValue flushData(void)
Flush all data in the buffers to and from the device.
Definition: usbinterface.cpp:538
xstime.h
UsbInterface::~UsbInterface
~UsbInterface()
Destructor, de-initializes, frees memory allocated for buffers, etc.
Definition: usbinterface.cpp:437
UsbInterface::close
XsResultValue close(void)
Close the USB communication port.
Definition: usbinterface.cpp:457
UsbInterface::waitForData
XsResultValue waitForData(XsSize maxLength, void *data, XsSize *length=nullptr)
Wait for data to arrive or a timeout to occur.
Definition: usbinterface.cpp:1042
IoInterface::waitForData
virtual XsResultValue waitForData(XsSize maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:67
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST