Hello,
In many projects, I often need to get some dialogue between computer and teensy and I have never find the better code to achieve this task. There are many ways to do this and on PJRC website Paul explain that too many (Serial.available()) can lead in overrun situations.
So I'd like to have some advices about some optimized ways to handle serial commands without taking too much resources from the main loop. For example, I currently have some code that act like this :
Is this the right thing to do ?
Thank,
Manu
In many projects, I often need to get some dialogue between computer and teensy and I have never find the better code to achieve this task. There are many ways to do this and on PJRC website Paul explain that too many (Serial.available()) can lead in overrun situations.
So I'd like to have some advices about some optimized ways to handle serial commands without taking too much resources from the main loop. For example, I currently have some code that act like this :
Code:
void setup() {
Serial.begin (115200);
...
}
void loop() {
if (Serial.available() || Mode_Conf == true) // Configuration Mode
{
ModeConfiguration(); // Go in a function that threat serial
}
else { // Normal Mode
// Do the work....
}
}
Is this the right thing to do ?
Thank,
Manu