Fastserial , and serial port blocking, is it ancient history, or stil an issue ?

I am about to make something with two serial ports on a 328P , or Leonardo.
years ago, there were something called fastserial, an attempt not to miss data while sending serial data.
is it still needed ? - or can I use softwareserial and everything will be fine ?

HardwareSerial is handled with interrupts, coming and going.

SoftwareSerial is also interrupt driven, but the interrupts are timer generated, and happen often enough to make the Arduino sluggish when using SoftwareSerial.

If you NEED two serial ports, using a board with more than one hardware serial port makes more sense.

basically what I expected. :slight_smile: - thanks.

SoftwareSerial TX is not timer based. It doesn't use interrupts. The timing is determined by calculated code delays. Global interrupts are disabled while the start bit and 8 data bits are sent and reenabled for the stop bit. The entire string of data you are writing or printing has to be sent before your next line of code begins execution.

SoftwareSerial RX uses a pin change interrupt. The interrupt occurs once per character but the code then disables interrupts and uses code delays to time the reception of the bits. Interrupts are disabled for at least 95% of the time during SoftwareSerial RX.

HardwareSerial TX uses interrupts. When you write data it goes into a buffer and an interrupt is generated after each character is sent. The ISR transfers one character from the buffer into the UART output register. I believe this is what used to be referred to as FastSerial. The only time it is blocking is when you try to write more data into the buffer than there is room. Then the write() or print() function will wait until enough data has been transmitted to allow the bytes to fit in the buffer.

HardwareSerail RX also uses interrupts. When a character is received it generates an interrupt and the ISR moves the character into a buffer. If the buffer is full the character is lost. Reading from the buffer is synchronous via calls to read().

thank you for the info.
the hardware serial port (RX) usually has a x bytes buffer - is that enabled and in use when using Arduino ? and, regarding SoftwareSerial RX , how much buffer does it have ?

The standard Arduino core doesn't make any assumptions about a hardware buffer. As an example, the Atmega328p has a 2-byte FIFO for RX.

Normally there is bandwidth for the RX ISR to move each byte into the software buffer as fast as they arrive. But if this is prevented and the FIFO fills then I suppose that means one would get back to back interrupt requests from the UART. That is, it would move one character to the buffer, return from the ISR and then immediately get another interrupt. That's not as efficient as reading both characters at once but it's slightly more efficient if the vast majority of the time there's only one character in the FIFO.

The SoftwareSerial RX buffer has a size of 64 bytes by default. You can change it, with some effort. Alternatives to SoftwareSerial also exist. The best known one is AltSoftSerial. It is far more efficient and is full-duplex, although it uses some specific hardware resources. It has a default RX buffer of 80 bytes.