Main MRPT website > C++ reference for MRPT 1.5.7
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-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 #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 platform-independent they are put here
22 # include <string.h>
23 # include <stddef.h>
24 #define _strnicmp strncasecmp
25 #endif
26 
27 #include "streaminterface.h"
28 #include <stdio.h>
29 
30 struct XsPortInfo;
31 
33 
34 class UsbInterface : public StreamInterface {
35 public:
36  UsbInterface();
37  ~UsbInterface();
38 
39  XsResultValue open(const XsPortInfo &portInfo, uint32_t readBufSize = 0, uint32_t writeBufSize = 0);
40  XsResultValue close(void);
41  XsResultValue closeUsb(void);
42  XsResultValue flushData (void);
43 
44  bool isOpen (void) const;
45  uint8_t usbBus() const;
46  uint8_t usbAddress() const;
47 
48  XsResultValue getLastResult(void) const;
49 
51  uint32_t getTimeout (void) const;
52 
53  void setRawIo(bool enable);
54  bool getRawIo(void);
55 
56  virtual XsResultValue writeData(const XsByteArray& data, XsSize* written = NULL);
59 
60  //lint -e1411 inherited definitions are also available (see above)
61  XsResultValue writeData(XsSize length, const void *data, XsSize* written = NULL);
64  //lint +e1411
65 
66  void getPortName(XsString& portname) const;
67 
68 private:
71 };
72 
73 #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:70
bool isOpen(void) const
Return whether the USB communication port is open or not.
A stream interface.
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
XsResultValue waitForData(XsSize maxLength, void *data, XsSize *length=NULL)
Wait for data to arrive or a timeout to occur.
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:17
unsigned char uint8_t
Definition: rptypes.h:43
void setRawIo(bool enable)
Sets the RAWIO mode of the USB interface.
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:26
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:65
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=NULL)
Write the data to the USB port.
~UsbInterface()
Destructor, de-initializes, frees memory allocated for buffers, etc.
Private object for UsbInterface.
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:3900
XsResultValue flushData(void)
Flush all data in the buffers to and from the device.
GLsizei maxLength
Definition: glext.h:4504
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:49
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3520
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:34



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