cAT icon indicating copy to clipboard operation
cAT copied to clipboard

Add CAT_STATUS_AGAIN to report io::[write|read] can't send or receive more data

Open xiaoxiang781216 opened this issue 2 years ago • 6 comments

xiaoxiang781216 avatar Jun 30 '22 05:06 xiaoxiang781216

The main idea behind returning BUSY state when can't send out character is related with sleep and low power modes. The main service function should return OK only when there is nothing to do (no pending read/write characters, no pending operations, and etc...). Many applications and projects use it so this is not backward-compatible change.

marcinbor85 avatar Aug 27 '22 16:08 marcinbor85

The main idea behind returning BUSY state when can't send out character is related with sleep and low power modes. The main service function should return OK only when there is nothing to do (no pending read/write characters, no pending operations, and etc...). Many applications and projects use it so this is not backward-compatible change.

The return from cat_io_interface::write doesn't equal to 1 mean that the low level can't accept more character(e.g. when fd is set to non-blocking mode, write will return -EAGAIN in this case). Application need to know this state to avoid the busy loop.

xiaoxiang781216 avatar Aug 27 '22 18:08 xiaoxiang781216

So maybe it should return BUSY_WRITE (add new state) to distinguish this state from BUSY and OK ?

marcinbor85 avatar Aug 27 '22 18:08 marcinbor85

So maybe it should return BUSY_WRITE (add new state) to distinguish this state from BUSY and OK ?

Add CAT_STATUS_AGAIN(mimic non blocking io return AGAIN) to indicate this situation.

xiaoxiang781216 avatar Aug 27 '22 20:08 xiaoxiang781216

So now, in which case the main service function will return OK instead of BUSY or AGAIN? This change needs to fix tests also, because the logic will change.

marcinbor85 avatar Aug 27 '22 20:08 marcinbor85

Yes, I will find time to ensure all test pass.

xiaoxiang781216 avatar Aug 28 '22 09:08 xiaoxiang781216