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))
High-level communication class.
CmtDeviceId getMasterId(void)
XsensResultValue openPort(const char *portName, const uint32_t baudRate=CMT_DEFAULT_BAUD_RATE)
XsensResultValue setTimeoutConfig(const uint32_t timeout=CMT3_DEFAULT_TIMEOUT_CONF)
Set the configuration mode timeout.
XsensResultValue setGotoConfigTries(const uint16_t tries)
Set the number of times the gotoConfig function will attempt a gotoConfig before failing.
void append(const T &item)
Adds an item to the end of the list.
void clear(void)
Clears the list without explicitly deleting anything.
uint32_t length(void) const
Returns the number of items currently in the list.
void remove(const uint32_t index) XSENS_LIST_THROW
Removes an item at the given index in the list.
void sortAscending(void)
Sorts the list in an ascending order, using the T::< operator.
#define CMT_BAUD_RATE_921K6
#define CMT_BAUD_RATE_19K2
#define CMT_BAUD_RATE_230K4
#define CMT_BAUD_RATE_115K2
#define CMT_BAUD_RATE_57K6
#define CMT_BAUD_RATE_9600
#define CMT_BAUD_RATE_460K8
#define CMT_BAUD_RATE_38K4
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
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...
The namespace of all Xsens software since 2006.
bool abortScan
Set to true from another thread to abort any scan currently in progress.
bool cmtScanPort(CmtPortInfo &portInfo, uint32_t baud, uint32_t singleScanTimeout, uint32_t scanTries)
Scan a single COM port for connected Xsens devices.
bool cmtScanPorts(List< CmtPortInfo > &ports, uint32_t baudrate, uint32_t singleScanTimeout, uint32_t scanTries)
Scan COM ports for connected Xsens devices.
unsigned __int16 uint16_t
unsigned __int32 uint32_t
Structure for storing information about a serial port.
uint8_t m_portNr
The port number.
char m_portName[270]
The port name.
uint32_t m_deviceId
The device Id of the detected Xsens device.
uint32_t m_baudrate
The baudrate at which an Xsens device was detected.
XsensResultValue
Xsens return values.
@ XRV_OK
Operation was performed successfully.