Main MRPT website > C++ reference for MRPT 1.9.9
xsportinfo.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 XSPORTINFO_H
10 #define XSPORTINFO_H
11 
12 #include "xstypesconfig.h"
13 #include "pstdint.h"
14 #include "xsdeviceid.h"
15 #include "xsbaud.h"
16 #include "xsstring.h"
17 #include <stdio.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #ifndef __cplusplus
24 typedef struct XsPortInfo XsPortInfo;
25 #else
26 struct XsPortInfo;
27 #endif
28 
30 XSTYPES_DLL_API int XsPortInfo_empty(XsPortInfo const* thisPtr);
32 XSTYPES_DLL_API int XsPortInfo_isUsb(XsPortInfo const* thisPtr);
33 XSTYPES_DLL_API int XsPortInfo_usbBus(XsPortInfo const* thisPtr);
36 
37 #ifdef __cplusplus
38 }
39 #endif
40 
41 #if defined(_MSC_VER)
42 #pragma warning(push)
43 #pragma warning(disable : 4996)
44 #endif
45 
46 struct XsPortInfo
47 {
48 #ifdef __cplusplus
49  /*! \brief Default constructor, creates an empty port info object */
51  {
52  m_portName[0] = '\0';
53  }
54 
55  /*! \brief Named constructor, initializes the object to the supplied \a
56  portname and optional \a baudRate
57  \param portname The name of the port, maximum 255 characters
58  \param baudRate The baud rate to configure for the port, for scanning
59  XBR_Invalid may be used to scan all known baud rates
60  */
61  explicit XsPortInfo(
62  const XsString& portname, XsBaudRate baudRate = XBR_Invalid)
63  : m_deviceId(0), m_baudrate(baudRate)
64  {
65  if (portname.size() < 255)
66  strcpy(m_portName, portname.c_str());
67  else
68  m_portName[0] = '\0';
69  }
70 
71 #ifndef XSENS_NO_PORT_NUMBERS
72  /*! \brief Port number constructor, initializes the port to have
73  COM<portNumber> as its name and the optional \a baudRate for a baud rate
74  \param portNr The number of the COM port
75  \param baudRate The baud rate to configure for the port, for scanning
76  XBR_Invalid may be used to scan all known baud rates
77  \note Numbered COM ports are only available on Windows platforms.
78  */
79  explicit XsPortInfo(int portNr, XsBaudRate baudRate = XBR_Invalid)
80  : m_deviceId(0), m_baudrate(baudRate)
81  {
82  sprintf(m_portName, "COM%d", portNr);
83  }
84 #endif
85 
86  /*! \brief \copybrief XsPortInfo_clear */
87  inline void clear() { XsPortInfo_clear(this); }
88  /*! \brief \copybrief XsPortInfo_empty */
89  inline bool empty() const { return XsPortInfo_empty(this) != 0; }
90  /*! \brief greater than operator, used for sorting the list. */
91  inline bool operator>(const XsPortInfo& p) const
92  {
93  return strcmp(m_portName, p.m_portName) > 0;
94  }
95 
96  /*! \brief less than operator, used for sorting the list. */
97  inline bool operator<(const XsPortInfo& p) const
98  {
99  return strcmp(m_portName, p.m_portName) < 0;
100  }
101 
102  /*! \brief equality operator, used for finding items in a list. */
103  inline bool operator==(const XsPortInfo& p) const
104  {
105  return strcmp(m_portName, p.m_portName) == 0;
106  }
107 
108  /*! \brief equality operator, used for finding items in a list. */
109  inline bool operator==(const char* port) const
110  {
111  return strcmp(m_portName, port) == 0;
112  }
113 
114  /*! \copydoc XsPortInfo_portNumber */
115  inline int portNumber() const { return XsPortInfo_portNumber(this); }
116  /*! \brief The port name
117  */
118  inline XsString portName() const { return XsString(m_portName); }
119  /*! \brief Set the port name
120  */
121  inline void setPortName(const XsString& portName_)
122  {
123  strncpy(m_portName, portName_.c_str(), 256);
124  }
125 
126  /*! \brief \copybrief XsPortInfo_isUsb */
127  inline bool isUsb() const { return XsPortInfo_isUsb(this) != 0; }
128  /*! \copydoc XsPortInfo_usbBus */
129  inline int usbBus() const { return XsPortInfo_usbBus(this); }
130  /*! \copydoc XsPortInfo_usbAddress */
131  inline int usbAddress() const { return XsPortInfo_usbAddress(this); }
132  /*! \brief The baudrate
133  */
134  inline XsBaudRate baudrate() const { return m_baudrate; }
135  /*! \brief Set the baudrate
136  */
137  inline void setBaudrate(XsBaudRate baudrate_) { m_baudrate = baudrate_; }
138  /*! \brief The device ID
139  */
140  inline XsDeviceId deviceId() const { return m_deviceId; }
141  /*! \brief Set the device ID
142  */
143  inline void setDeviceId(XsDeviceId deviceId_) { m_deviceId = deviceId_; }
144  private:
145 #endif
146 
147  /** The device Id of main Xsens device detected on the port */
149  /** The port name */
150  char m_portName[256];
151  /** The baudrate at which an Xsens device was detected, may be XBR_Invalid
152  * for pure USB ports */
154 };
155 
156 #if defined(_MSC_VER)
157 #pragma warning(pop)
158 #endif
159 
160 #endif // file guard
XSTYPES_DLL_API int XsPortInfo_usbAddress(XsPortInfo const *thisPtr)
EIGEN_STRONG_INLINE bool empty() const
XSTYPES_DLL_API int XsPortInfo_empty(XsPortInfo const *thisPtr)
char m_portName[256]
The port name.
Definition: xsportinfo.h:150
XSTYPES_DLL_API void XsPortInfo_clear(XsPortInfo *thisPtr)
XSTYPES_DLL_API void XsPortInfo_swap(XsPortInfo *a, struct XsPortInfo *b)
XsBaudRate m_baudrate
The baudrate at which an Xsens device was detected, may be XBR_Invalid for pure USB ports...
Definition: xsportinfo.h:153
Not a valid baud rate.
Definition: xsbaudrate.h:30
XSTYPES_DLL_API int XsPortInfo_isUsb(XsPortInfo const *thisPtr)
GLubyte GLubyte b
Definition: glext.h:6279
bool operator==(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
Definition: TCamera.cpp:201
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:9
XsDeviceId m_deviceId
The device Id of main Xsens device detected on the port.
Definition: xsportinfo.h:148
struct XsPortInfo XsPortInfo
Definition: xsportinfo.h:24
XSTYPES_DLL_API int XsPortInfo_portNumber(XsPortInfo const *thisPtr)
struct XsString XsString
Definition: xsstring.h:34
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
Definition: os.cpp:297
bool operator<(const COccupancyGridMap2D::TPairLikelihoodIndex &e1, const COccupancyGridMap2D::TPairLikelihoodIndex &e2)
XsBaudRate
Communication speed.
Definition: xsbaudrate.h:27
#define deviceId
Definition: CIMUXSens.cpp:40
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLfloat GLfloat p
Definition: glext.h:6305
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:188
XSTYPES_DLL_API int XsPortInfo_usbBus(XsPortInfo const *thisPtr)
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
Definition: os.cpp:189



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019