Go to file
robert rozee 95bb83ef96 make serial.available, peek, read atomic
when SERIAL_RX_BUFFER_SIZE is defined as greater than 256, the current HardwareSerial.cpp code almost works correctly. but not quite. the function serial.available may return an incorrect number of characters waiting (though when treated purely as a boolean it seems not to fault).serial.peek has a similar issue detecting if a character is waiting, while serial.read may also leave _rx_buffer_tail corrupt to an interrupt occurring mid-update (this corruption may cause the ISR to be mistaken about how much free is available in the Rx buffer).

the proposed changes to these three functions add cli/sti pairings around the critical pieces of code. i have tested and verified the change made to serial.available as correcting the problem, while the change to serial.peek follows the exact same pattern. the changes to serial.read have been confirmed as not breaking the function, but i have not been in a position to test the failure of the original (non-atomic) version to make comparisons.

multiple testing was conducted at 115,200 baud and 500,000 baud using data streams of 1,000,000 characters sent over a 2 minute interval. any error causing loss of character would have resulted in a catastrophic (ie, very obvious) failure.

cheers,
rob   :-)

-> Squash and rebase of https://github.com/arduino/Arduino/pull/3848
2017-11-13 17:04:29 +01:00
bootloaders Adding Arduino.org new boards 2016-12-16 10:59:00 +01:00
cores/arduino make serial.available, peek, read atomic 2017-11-13 17:04:29 +01:00
extras Add extras folder for packagein and CI 2017-11-13 11:53:21 +01:00
firmwares Added support to Genuino boards (drivers, boards.txt entries, bootloaders) 2015-08-27 10:40:03 +02:00
libraries [WIRE] Remove extra line from digital_potentiometer example 2017-11-13 12:42:12 +01:00
variants Added Adafruit Circuits Playground board 2016-12-14 15:00:23 +01:00
boards.txt Use correct part names in Tools > Processor menus 2017-07-18 12:22:43 +02:00
platform.txt Update bundled avr core to 1.6.20 2017-08-18 15:58:02 +02:00
programmers.txt Updated Arduino as ISP setting 2017-11-13 16:37:40 +01:00