private static bool scanMeasuringDevices() { var retries = 0; _xda = new MyXda(); while (retries < scanRetries) { _xda.scanPorts(); if (_xda._DetectedDevices.Any()) { logger.Log($"{_xda._DetectedDevices.Count()} Devics Detected after {retries} retries."); logger.Log($"IDs: { string.Join(", ", _xda._DetectedDevices.Select(d => d.deviceId().toInt().ToString())) }"); return(true); } retries++; } return(false); }
private void ScanForStations() { List <MasterInfo> _stations = new List <MasterInfo>(); _xda.scanPorts(); if (_xda._DetectedDevices.Count > 0) { foreach (XsPortInfo portInfo in _xda._DetectedDevices) { if (portInfo.deviceId().isWirelessMaster() || portInfo.deviceId().isAwindaStation()) { UnityEngine.Debug.Log("found wireless connector"); _xda.openPort(portInfo); MasterInfo ai = new MasterInfo(portInfo.deviceId()); ai.ComPort = portInfo.portName(); ai.BaudRate = portInfo.baudrate(); _stations.Add(ai); break; } } if (_stations.Count > 0) { UnityEngine.Debug.Log("Found station: " + _stations[0].ToString() + " ... creating master device."); _masterDevice = _xda.getDevice(_stations[0].DeviceId); if (!_masterDevice.gotoConfig()) { throw new UnityException("could not enter configuration mode of created master device"); } UnityEngine.Debug.Log("master device created successfully, ready to enable radio"); } else { throw new UnityException("no station could be found, make sure drivers are installed correctly"); } } }