mbed-os/drivers
Kevin Bracey 9678c8052e Make UARTSerial send all data when blocking
Previously, write() was somewhat soft - it only ever made one attempt to
wait for buffer space, so it would take as much data as would fit in the
buffer in one call.

This is not the intent of a POSIX filehandle write. It should try to
send everything if blocking, and only send less if interrupted by a
signal:

 - If the O_NONBLOCK flag is clear, write() shall block the calling
   thread until the data can be accepted.

 - If the O_NONBLOCK flag is set, write() shall not block the thread.
   If some data can be written without blocking the thread, write()
   shall write what it can and return the number of bytes written.
   Otherwise, it shall return -1 and set errno to [EAGAIN].

This "send all" behaviour is of slightly limited usefulness in POSIX, as
you still usually have to worry about the interruption possibility:

  - If write() is interrupted by a signal before it writes any data, it
    shall return -1 with errno set to [EINTR].

  - If write() is interrupted by a signal after it successfully writes
    some data, it shall return the number of bytes written.

But as mbed OS does not have the possibility of signal interruption, if we
strengthen write to write everything, we can make applications' lives
easier - they can just do "write(large amount)" confident that it will
all go in one call (if no errors).

So, rework to make multiple writes to the buffer, blocking as necessary,
until all data is written.

This change does not apply to read(), which is correct in only blocking until
some data is available:

 - If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].

 - If O_NONBLOCK is clear, read() shall block the calling thread until some
   data becomes available.

 - The use of the O_NONBLOCK flag has no effect if there is some data
   available.
2017-11-21 09:51:36 +02:00
..
AnalogIn.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
AnalogIn.h Enable doxygen to use the pre-processor 2017-04-12 09:01:29 -05:00
AnalogOut.h Enabled operator API documentation in drivers 2017-06-08 15:53:53 -05:00
BusIn.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
BusIn.h drivers: Replace private copy constructor and Copy assignement operator by NonCopyable traits. 2017-06-20 16:23:46 +01:00
BusInOut.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
BusInOut.h drivers: Replace private copy constructor and Copy assignement operator by NonCopyable traits. 2017-06-20 16:23:46 +01:00
BusOut.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
BusOut.h drivers: Replace private copy constructor and Copy assignement operator by NonCopyable traits. 2017-06-20 16:23:46 +01:00
CAN.cpp Properly unlock sleep in destructor of drivers 2017-10-02 11:35:08 -05:00
CAN.h Drivers with interrupts: adding sleep deep locking 2017-09-07 15:35:05 +01:00
DigitalIn.h Enabled operator API documentation in drivers 2017-06-08 15:53:53 -05:00
DigitalInOut.h Enabled operator API documentation in drivers 2017-06-08 15:53:53 -05:00
DigitalOut.h Enabled operator API documentation in drivers 2017-06-08 15:53:53 -05:00
Ethernet.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
Ethernet.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
FlashIAP.cpp FlashIAP: Add explicit read function to flash_api.h 2017-07-06 18:53:32 +01:00
FlashIAP.h flash: add note about program size 2017-09-06 07:54:18 +01:00
I2C.cpp drivers: fix attach sleep locking 2017-09-07 15:35:06 +01:00
I2C.h Drivers with interrupts: adding sleep deep locking 2017-09-07 15:35:05 +01:00
I2CSlave.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
I2CSlave.h Enable doxygen to use the pre-processor 2017-04-12 09:01:29 -05:00
InterruptIn.cpp InterruptIn: callback to NULL clean-up 2017-09-09 09:48:10 +02:00
InterruptIn.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
InterruptManager.cpp Deprecate InterruptManager 2017-10-27 14:47:55 -05:00
InterruptManager.h Deprecate InterruptManager 2017-10-27 14:47:55 -05:00
LowPowerTicker.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
LowPowerTimeout.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
LowPowerTimer.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
PortIn.h Enable doxygen to use the pre-processor 2017-04-12 09:01:29 -05:00
PortInOut.h Enabled operator API documentation in drivers 2017-06-08 15:53:53 -05:00
PortOut.h Enabled operator API documentation in drivers 2017-06-08 15:53:53 -05:00
PwmOut.h PWMOut: lock deesleep addition 2017-09-22 15:08:02 +01:00
RawSerial.cpp Stream class should use mbed::fdopen() to attach a stream 2017-05-31 15:02:11 +03:00
RawSerial.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
SPI.cpp Drivers with interrupts: adding sleep deep locking 2017-09-07 15:35:05 +01:00
SPI.h Drivers with interrupts: adding sleep deep locking 2017-09-07 15:35:05 +01:00
SPISlave.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
SPISlave.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
Serial.cpp Renamed files in platform to match source names 2017-02-22 18:17:54 -06:00
Serial.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
SerialBase.cpp Properly unlock sleep in destructor of drivers 2017-10-02 11:35:08 -05:00
SerialBase.h Properly unlock sleep in destructor of drivers 2017-10-02 11:35:08 -05:00
Ticker.cpp Enable deepsleep for low power Ticker and low power Timer. 2017-09-22 08:30:17 +02:00
Ticker.h Protect Ticker attach with a critical section 2017-10-02 11:35:05 -05:00
Timeout.cpp For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
Timeout.h Drivers with interrupts: adding sleep deep locking 2017-09-07 15:35:05 +01:00
Timer.cpp Fix sleep lock underflow in LowPowerTimer 2017-10-02 19:32:20 -05:00
Timer.h Merge pull request #5148 from mprse/fix_enable_deepsleep_for_lp_timer 2017-09-28 14:11:40 -05:00
TimerEvent.cpp TimerEvent: Use ticker_insert_event_us instead of the old API in 2017-05-31 19:14:21 +01:00
TimerEvent.h drivers: Mark non identity types as non copyable with the NonCopyable traits. 2017-06-20 16:23:46 +01:00
UARTSerial.cpp Make UARTSerial send all data when blocking 2017-11-21 09:51:36 +02:00
UARTSerial.h Make UARTSerial send all data when blocking 2017-11-21 09:51:36 +02:00
mbed_lib.json Major Refactoring & extensions 2017-05-31 15:02:11 +03:00