Go Down

Topic: Request: helpers for cooperative multitasking (Serial, EEPROM) (Read 879 times) previous topic - next topic


I just started using the Arduino and have read a lot of documentation and forum posts. What I really like in the Arduino 1.0 is the change in the sending routines of Serial using a queue. In my project I do not use interrupts to prevent any loss of data from Serial. What I have come up is a minimalistic way of cooperative multitasking (by dividing bigger task into small chunks which are processed sequentially) between serial IO and the task the cpu really should work on. Still the serial interface has to be reliable in my case without disturbing other tasks too much.

What I think is missing in the HardwareSerial implementation is a method to check if the output queue is empty - signaling that the last send operation is finished. This would prevent unwanted blocking calls to Serial.print() or Serial.write(). Same thought should be applied to other libraries like EEPROM. Here I do not use the EEPROM class but rely on the functions from avr/eeprom.h because they allow me to check before doing a call which could block (and they are up to 40% faster). All blocking calls are bad for cooperative multitasking.

Btw. could you please correct "http://arduino.cc/en/Reference/SerialEvent" to not contain Serial.buffer() and Serial.bufferUntil(). Although the idea sounds interesting they are not implemented yet.

Go Up