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
uint8_t usbAddress() const
The address of the device (libusb/linux only)
UsbInterface()
Default constructor, initializes all members to their default values.
uint32_t getTimeout(void) const
Return the current timeout value.
UsbInterfacePrivate * d
Definition: usbinterface.h:78
bool isOpen(void) const
Return whether the USB communication port is open or not.
A stream interface.
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
unsigned char uint8_t
Definition: rptypes.h:41
void setRawIo(bool enable)
Sets the RAWIO mode of the USB interface.
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:27
bool getRawIo(void)
Retrieves the state of the RAWIO mode of the USB interface.
uint8_t usbBus() const
The USB bus number this device is on (libusb/linux only)
virtual XsResultValue waitForData(XsSize maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:67
XsResultValue setTimeout(uint32_t ms)
Set the default timeout value to use in blocking operations.
XsResultValue closeUsb(void)
Close the USB communication port.
#define XSENS_DISABLE_COPY(className)
Add this macro to the start of a class definition to prevent automatic creation of copy functions...
virtual XsResultValue writeData(const XsByteArray &data, XsSize *written=nullptr)
Write the data to the USB port.
~UsbInterface()
Destructor, de-initializes, frees memory allocated for buffers, etc.
Private object for UsbInterface.
XsResultValue waitForData(XsSize maxLength, void *data, XsSize *length=nullptr)
Wait for data to arrive or a timeout to occur.
XsResultValue getLastResult(void) const
Return the error code of the last operation.
void getPortName(XsString &portname) const
Retrieve the port name that was last successfully opened.
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
XsResultValue flushData(void)
Flush all data in the buffers to and from the device.
GLsizei maxLength
Definition: glext.h:4932
XsResultValue close(void)
Close the USB communication port.
struct XsString XsString
Definition: xsstring.h:34
virtual XsResultValue readData(XsSize maxLength, XsByteArray &data)
Read data from the USB port and put it into the data buffer.
unsigned __int32 uint32_t
Definition: rptypes.h:47
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3546
XsResultValue open(const XsPortInfo &portInfo, uint32_t readBufSize=0, uint32_t writeBufSize=0)
Open a communication channel to the given USB port name.
An IoInterface for dealing specifically with Xsens USB devices.
Definition: usbinterface.h:35



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020