37 # include <setupapi.h>
53 # define SCANLOG CMTLOG
82 SCANLOG(
"SP: L3 port-check returns OK\n");
90 SCANLOG(
"SP: L3 port-check returned ERROR, aborting\n");
94 SCANLOG(
"SP: L3 port-check returned TIMEOUT, check next baudrate or abort\n");
128 SP_DEVINFO_DATA DeviceInfoData;
135 {0x4D36E978,0xE325,0x11CE,{0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18}};
138 hDevInfo = SetupDiGetClassDevs(&portGuid, 0, 0, DIGCF_PRESENT | DIGCF_PROFILE);
140 if (hDevInfo == INVALID_HANDLE_VALUE)
144 DeviceInfoData.cbSize =
sizeof(SP_DEVINFO_DATA);
145 for (i=0;!
abortScan && SetupDiEnumDeviceInfo(hDevInfo,i,&DeviceInfoData);++i)
158 if (SetupDiGetDeviceRegistryProperty(hDevInfo,
171 if (!
_strnicmp(
buffer,
"(Standard port types)",strlen(
"(Standard port types)")))
183 HKEY hDeviceKey = SetupDiOpenDevRegKey(hDevInfo, &DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE);
184 if (hDeviceKey != INVALID_HANDLE_VALUE)
187 char pszPortName[256];
190 if ((RegQueryValueExA(hDeviceKey,
"PortName", NULL, &dwType, (LPBYTE) pszPortName, &dwSize) == ERROR_SUCCESS) && (dwType == REG_SZ))
199 int32_t nPort = atoi(&pszPortName[3]);
213 RegCloseKey(hDeviceKey);
218 SetupDiDestroyDeviceInfoList(hDevInfo);
226 if ((ports.
length() > 0) && (ports[0].m_portNr == 1))
230 if (ports[0].m_portNr == 2)
234 if (ports[1].m_portNr == 2)
251 struct dirent *entry;
253 if ((dir = opendir(
"/dev/")) == NULL)
256 while ((entry = readdir(dir)))
257 if (strncmp(
"ttyS", entry->d_name, 4) == 0 || strncmp(
"ttyUSB", entry->d_name, 6) == 0)
272 if (
cmtScanPort(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 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...
int BASE_IMPEXP _strnicmp(const char *str, const char *subStr, size_t count) MRPT_NO_THROWS
An OS-independent version of strnicmp.
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.
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.
char m_portName[32]
The port name.
XsensResultValue
Xsens return values.
@ XRV_CONFIGCHECKFAIL
The in-config check of the device failed.
@ XRV_TIMEOUT
A timeout occurred.
@ XRV_OK
Operation was performed successfully.
@ XRV_TIMEOUTNODATA
Operation aborted because of no data read.