/// <summary> /// Find a board connected to a specific port /// </summary> /// <param name="portName">Port open</param> public virtual IEnumerator DetectUduino(UduinoDevice uduinoDevice) { int tries = 0; do { if (uduinoDevice.getStatus() == BoardStatus.Open) { string reading = uduinoDevice.ReadFromArduino("identity", instant: true); if (reading != null && reading.Split(new char[0])[0] == "uduinoIdentity") { string name = reading.Split(new char[0])[1]; uduinoDevice.name = name; _manager.AddUduinoBoard(name, uduinoDevice); uduinoDevice.UduinoFound(); if (!_manager.ReadOnThread) { _manager.StartCoroutine(_manager.CoroutineRead(name)); // Initiate the Async reading of variables } else { _manager.StartThread(); } uduinoDevice.WriteToArduino("connected"); _manager.InitAllArduinos(); break; } else { Log.Debug("Impossible to get name on <color=#2196F3>[" + uduinoDevice.identity + "]</color>. Retrying."); } } yield return(new WaitForSeconds(0.05f)); //Wait one frame. Todo : use yield return new WaitForSeconds(0.5f); ? // yield return null; //Wait one frame. Todo : use yield return new WaitForSeconds(0.5f); ? } while (uduinoDevice.getStatus() != BoardStatus.Undef && tries++ < _manager.DiscoverTries); if (uduinoDevice.getStatus() != BoardStatus.Found) { Log.Warning("Impossible to get name on <color=#2196F3>[" + uduinoDevice.identity + "]</color>. Closing."); uduinoDevice.Close(); uduinoDevice = null; } }