Go to the documentation of this file.
53 #define SCANLOG CMTLOG
84 SCANLOG(
"SP: L3 port-check returns OK\n");
93 SCANLOG(
"SP: L3 port-check returned ERROR, aborting\n");
98 "SP: L3 port-check returned TIMEOUT, check next baudrate or "
101 if (baud != 0)
return false;
141 SP_DEVINFO_DATA DeviceInfoData;
147 GUID portGuid = {0x4D36E978,
150 {0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18}};
154 SetupDiGetClassDevs(&portGuid, 0, 0, DIGCF_PRESENT | DIGCF_PROFILE);
156 if (hDevInfo == INVALID_HANDLE_VALUE)
return false;
159 DeviceInfoData.cbSize =
sizeof(SP_DEVINFO_DATA);
161 !
abortScan && SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); ++i)
174 if (SetupDiGetDeviceRegistryProperty(
175 hDevInfo, &DeviceInfoData, SPDRP_MFG, &DataT, (PBYTE)
buffer,
184 buffer,
"(Standard port types)",
185 strlen(
"(Standard port types)")))
201 HKEY hDeviceKey = SetupDiOpenDevRegKey(
202 hDevInfo, &DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV,
204 if (hDeviceKey != INVALID_HANDLE_VALUE)
207 char pszPortName[256];
210 if ((RegQueryValueExA(
211 hDeviceKey,
"PortName",
nullptr, &dwType,
212 (LPBYTE)pszPortName, &dwSize) == ERROR_SUCCESS) &&
220 if (
_strnicmp(pszPortName,
"COM", 3))
continue;
221 int32_t nPort = atoi(&pszPortName[3]);
235 RegCloseKey(hDeviceKey);
240 SetupDiDestroyDeviceInfoList(hDevInfo);
246 bool add1 =
true, add2 =
true;
247 if ((ports.
length() > 0) && (ports[0].m_portNr == 1)) add1 =
false;
250 if (ports[0].m_portNr == 2)
252 else if (ports.
length() > 1)
253 if (ports[1].m_portNr == 2) add2 =
false;
269 struct dirent* entry;
271 if ((dir = opendir(
"/dev/")) ==
nullptr)
return false;
273 while ((entry = readdir(dir)))
274 if (strncmp(
"ttyS", entry->d_name, 4) == 0 ||
275 strncmp(
"ttyUSB", entry->d_name, 6) == 0)
291 ports[
p], ports[
p].m_baudrate, singleScanTimeout, scanTries))
Structure for storing information about a serial port.
bool cmtScanPort(CmtPortInfo &portInfo, uint32_t baud, uint32_t singleScanTimeout, uint32_t scanTries)
Scan a single COM port for connected Xsens devices.
void sortAscending(void)
Sorts the list in an ascending order, using the T::< operator.
#define CMT_BAUD_RATE_921K6
unsigned __int16 uint16_t
void append(const T &item)
Adds an item to the end of the list.
@ XRV_OK
Operation was performed successfully.
#define CMT_BAUD_RATE_19K2
char m_portName[270]
The port name.
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...
XsensResultValue setGotoConfigTries(const uint16_t tries)
Set the number of times the gotoConfig function will attempt a gotoConfig before failing.
#define CMT_BAUD_RATE_9600
#define CMT_BAUD_RATE_38K4
High-level communication class.
void remove(const uint32_t index) XSENS_LIST_THROW
Removes an item at the given index in the list.
bool abortScan
Set to true from another thread to abort any scan currently in progress.
uint8_t m_portNr
The port number.
#define CMT_BAUD_RATE_460K8
#define CMT_BAUD_RATE_57K6
#define CMT_BAUD_RATE_115K2
bool cmtScanPorts(List< CmtPortInfo > &ports, uint32_t baudrate, uint32_t singleScanTimeout, uint32_t scanTries)
Scan COM ports for connected Xsens devices.
uint32_t m_baudrate
The baudrate at which an Xsens device was detected.
XsensResultValue openPort(const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE)
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
XsensResultValue setTimeoutConfig(const uint32_t timeout=CMT3_DEFAULT_TIMEOUT_CONF)
Set the configuration mode timeout.
#define CMT_BAUD_RATE_230K4
XsensResultValue
Xsens return values.
void clear(void)
Clears the list without explicitly deleting anything.
CmtDeviceId getMasterId(void)
uint32_t length(void) const
Returns the number of items currently in the list.
The namespace of all Xsens software since 2006.
unsigned __int32 uint32_t
uint32_t m_deviceId
The device Id of the detected Xsens device.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |