Main MRPT website > C++ reference for MRPT 1.5.6
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-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 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 #ifdef __cplusplus
48  /*! \brief Default constructor, creates an empty port info object */
49  XsPortInfo()
50  : m_deviceId(0)
52  {
53  m_portName[0] = '\0';
54  }
55 
56  /*! \brief Named constructor, initializes the object to the supplied \a 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 XBR_Invalid may be used to scan all known baud rates
59  */
60  explicit XsPortInfo(const XsString& portname, XsBaudRate baudRate = XBR_Invalid)
61  : m_deviceId(0)
62  , m_baudrate(baudRate)
63  {
64  if (portname.size() < 255)
65  strcpy(m_portName, portname.c_str());
66  else
67  m_portName[0] = '\0';
68  }
69 
70 #ifndef XSENS_NO_PORT_NUMBERS
71  /*! \brief Port number constructor, initializes the port to have COM<portNumber> as its name and the optional \a baudRate for a baud rate
72  \param portNr The number of the COM port
73  \param baudRate The baud rate to configure for the port, for scanning XBR_Invalid may be used to scan all known baud rates
74  \note Numbered COM ports are only available on Windows platforms.
75  */
76  explicit XsPortInfo(int portNr, XsBaudRate baudRate = XBR_Invalid)
77  : m_deviceId(0)
78  , m_baudrate(baudRate)
79  {
80  sprintf(m_portName, "COM%d", portNr);
81  }
82 #endif
83 
84  /*! \brief \copybrief XsPortInfo_clear */
85  inline void clear()
86  {
87  XsPortInfo_clear(this);
88  }
89 
90  /*! \brief \copybrief XsPortInfo_empty */
91  inline bool empty() const
92  {
93  return XsPortInfo_empty(this) != 0;
94  }
95 
96  /*! \brief greater than operator, used for sorting the list. */
97  inline bool operator > (const XsPortInfo& p) const { return strcmp(m_portName, p.m_portName) > 0; }
98 
99  /*! \brief less than operator, used for sorting the list. */
100  inline bool operator < (const XsPortInfo& p) const { return strcmp(m_portName, p.m_portName) < 0; }
101 
102  /*! \brief equality operator, used for finding items in a list. */
103  inline bool operator == (const XsPortInfo& p) const { return strcmp(m_portName, p.m_portName) == 0; }
104 
105  /*! \brief equality operator, used for finding items in a list. */
106  inline bool operator == (const char *port) const { return strcmp(m_portName, port) == 0; }
107 
108  /*! \copydoc XsPortInfo_portNumber */
109  inline int portNumber() const
110  {
111  return XsPortInfo_portNumber(this);
112  }
113 
114  /*! \brief The port name
115  */
116  inline XsString portName() const
117  {
118  return XsString(m_portName);
119  }
120 
121  /*! \brief Set the port name
122  */
123  inline void setPortName(const XsString& portName_)
124  {
125  strncpy(m_portName, portName_.c_str(), 256);
126  }
127 
128  /*! \brief \copybrief XsPortInfo_isUsb */
129  inline bool isUsb() const
130  {
131  return XsPortInfo_isUsb(this) != 0;
132  }
133 
134  /*! \copydoc XsPortInfo_usbBus */
135  inline int usbBus() const
136  {
137  return XsPortInfo_usbBus(this);
138  }
139 
140  /*! \copydoc XsPortInfo_usbAddress */
141  inline int usbAddress() const
142  {
143  return XsPortInfo_usbAddress(this);
144  }
145 
146  /*! \brief The baudrate
147  */
148  inline XsBaudRate baudrate() const
149  {
150  return m_baudrate;
151  }
152 
153  /*! \brief Set the baudrate
154  */
155  inline void setBaudrate(XsBaudRate baudrate_)
156  {
157  m_baudrate = baudrate_;
158  }
159 
160  /*! \brief The device ID
161  */
162  inline XsDeviceId deviceId() const
163  {
164  return m_deviceId;
165  }
166 
167  /*! \brief Set the device ID
168  */
169  inline void setDeviceId(XsDeviceId deviceId_)
170  {
171  m_deviceId = deviceId_;
172  }
173 
174 private:
175 #endif
176 
177  XsDeviceId m_deviceId; //!< The device Id of main Xsens device detected on the port
178  char m_portName[256]; //!< The port name
179  XsBaudRate m_baudrate; //!< The baudrate at which an Xsens device was detected, may be XBR_Invalid for pure USB ports
180 };
181 
182 #if defined(_MSC_VER)
183 #pragma warning(pop)
184 #endif
185 
186 #endif // file guard
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:5406
XSTYPES_DLL_API int XsPortInfo_usbAddress(XsPortInfo const *thisPtr)
bool operator==(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
XSTYPES_DLL_API int XsPortInfo_empty(XsPortInfo const *thisPtr)
char m_portName[256]
The port name.
Definition: xsportinfo.h:178
XSTYPES_DLL_API void XsPortInfo_clear(XsPortInfo *thisPtr)
XSTYPES_DLL_API void XsPortInfo_swap(XsPortInfo *a, struct XsPortInfo *b)
char BASE_IMPEXP * strcpy(char *dest, size_t destSize, const char *source) MRPT_NO_THROWS
An OS-independent version of strcpy.
Definition: os.cpp:296
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
XsBaudRate m_baudrate
The baudrate at which an Xsens device was detected, may be XBR_Invalid for pure USB ports...
Definition: xsportinfo.h:179
Not a valid baud rate.
Definition: xsbaudrate.h:28
EIGEN_STRONG_INLINE bool empty() const
XSTYPES_DLL_API int XsPortInfo_isUsb(XsPortInfo const *thisPtr)
bool operator>(const CArray< T, N > &x, const CArray< T, N > &y)
Definition: CArray.h:289
GLfloat GLfloat p
Definition: glew.h:10113
#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:177
struct XsPortInfo XsPortInfo
Definition: xsportinfo.h:24
XSTYPES_DLL_API int XsPortInfo_portNumber(XsPortInfo const *thisPtr)
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS 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:191
bool operator<(const CPoint< DERIVEDCLASS > &a, const CPoint< DERIVEDCLASS > &b)
Used by STL algorithms.
Definition: CPoint.h:116
GLdouble GLdouble GLdouble b
Definition: glew.h:5092
struct XsString XsString
Definition: xsstring.h:34
XsBaudRate
Communication speed.
Definition: xsbaudrate.h:27
#define deviceId
Definition: CIMUXSens.cpp:41
XSTYPES_DLL_API int XsPortInfo_usbBus(XsPortInfo const *thisPtr)



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