[POLL (Open)] Blocking behaviour of Serial.USB during TX

Post here first, or if you can't find a relevant section!

Should SerialUSB.write() block when the host is slow to process data?

Poll ended at Tue Sep 19, 2017 4:37 pm

It should block indefinitely to guarantee delivery to the application.
1
6%
It should not block and return inmediately if there is no space in the buffer (return value indicates number of bytes queued for TX).
5
28%
It should block only for a set timeout period (return value indicates number of bytes queued for TX).
0
No votes
It should block only for a timeout period that matches the baud rate set on SerialUSB.Begin(bauds) (return value indicates number of bytes queue for TX).
4
22%
Configurable at runtime (blocking or non-blocking with small timeout)
7
39%
Other (please explain in a post)
1
6%
 
Total votes: 18

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: [POLL (Open)] Blocking behaviour of Serial.USB during TX

Post by victor_pv » Mon Sep 11, 2017 6:08 pm

So if we use this method:

Code: Select all

Serial.begin(<baudrate>, bool blocking = 1 or 0); // 0 per default
What would be the expectation if the user uses the following cases?

Code: Select all

begin(115200);
begin();
Would you expect those to cause write() to return immediately if there is no buffer space, or would one act different than the other?
Also, what about:

Code: Select all

begin(115200, 1);
Would that case cause write() to block indefinitely, or only block for a timeout matching 115200 bps?

stevestrong
Posts: 1612
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [POLL (Open)] Blocking behaviour of Serial.USB during TX

Post by stevestrong » Tue Sep 12, 2017 8:26 am

As I don't prefer timeout, the

Code: Select all

begin(115200, 1);
should block, meaning don't return till all bytes are sent (put into Tx buffer).

Post Reply