public IEnumerator ReadSerialLoopWin()
{
while (true) {
if (!enabled) {
//print ("behaviour not enabled, stopping coroutine");
yield break;
}
//print("ReadSerialLoopWin ");
nCoroutineRunning++;
//print ("nCoroutineRunning: " + nCoroutineRunning);
string serialIn = "";
try {
while (true) { // BytesToRead crashes on Windows -> use ReadLine or ReadByte in a Thread or Coroutine
char c = (char)s_serial.ReadByte();
serialIn += c;
//serialIn += s_serial.ReadLine();
}
} catch (System.TimeoutException) {
//print ("System.TimeoutException in serial.ReadLine: " + te.ToString ());
} catch (System.Exception e) {
print ("System.Exception in serial.ReadLine: " + e.ToString ());
}
if (serialIn.Length > 0) {
//Debug.Log("just read some data: " + serialIn);
// Dispatch new data to each instance
foreach (Serial inst in s_instances) {
inst.receivedData (serialIn);
}
}
yield return null;
}
}