Main MRPT website > C++ reference for MRPT 1.5.6
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);
62  XsResultValue readData(XsSize maxLength, void *data, XsSize* length = NULL);
63  XsResultValue waitForData(XsSize maxLength, void *data, XsSize* length = NULL);
64  //lint +e1411
65 
66  void getPortName(XsString& portname) const;
67 
68 private:
71 };
72 
73 #endif // file guard
GLuint GLsizei GLsizei * length
Definition: glew.h:1732
uint8_t usbBus() const
The USB bus number this device is on (libusb/linux only)
UsbInterface()
Default constructor, initializes all members to their default values.
UsbInterfacePrivate * d
Definition: usbinterface.h:70
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
XsResultValue getLastResult(void) const
Return the error code of the last operation.
uint8_t usbAddress() const
The address of the device (libusb/linux only)
bool getRawIo(void)
Retrieves the state of the RAWIO mode of the USB interface.
bool isOpen(void) const
Return whether the USB communication port is open or not.
virtual XsResultValue waitForData(XsSize maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:65
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1284
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.
GLuint GLsizei maxLength
Definition: glew.h:1732
uint32_t getTimeout(void) const
Return the current timeout value.
void getPortName(XsString &portname) const
Retrieve the port name that was last successfully opened.
XsResultValue flushData(void)
Flush all data in the buffers to and from the device.
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
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.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018