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



Page generated by Doxygen 1.9.1 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at mar 26 may 2026 13:12:03 CEST