The requirement for iot_uart_ioctl() with xUartRequest = eGetTxNoOfbytes or eGetRxNoOfbytes is not reasonable
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- c
- Domain
- api, embedded-iot
Research direction
Start with the eGetTxNoOfbytes and eGetRxNoOfbytes definitions in iot_uart.h, then read test/test_iot_uart.c to understand the assumed concurrent async operations. Determine the intended behavior when reads and writes overlap, and document the agreed API semantics in iot_uart.h with tests covering the decision.
Written by the indexing model from the issue text.
Description
Hello,
We are thinking of developing our own device driver as compliant to common-io-basic interface.
Among all, we are facing an issue with iot_uart_ioctl() definition as below.
Description
The requirement for iot_uart_ioctl() with xUartRequest = eGetTxNoOfbytes or eGetRxNoOfbytes is not reasonable.
Test Steps
N/A.
This is an issue with API definitions.
Target Revision
ddfb538 (or any version on and after 8151c98).
Details
iot_uart.h says eGetTxNoOfbytes (eGetRxNoOfbytes) requires "If the last operation was read, this returns 0" (If the last operation was write, this returns 0"). See below.
* @note eGetTxNoOfbytes returns the number of written bytes in last operation. * This is supposed to be called in the caller task or application callback, right after last operation completes. * This request expects 2 bytes buffer (uint16_t). * * - If the last operation was write, this returns the actual number of written bytes which might be smaller than the requested number (partial write). * - If the last operation was read, this returns 0. * * @note eGetRxNoOfbytes returns the number of read bytes in last operation. * This is supposed to be called in the caller task or application callback, right after last operation completes. * This request expects 2 bytes buffer (uint16_t). * * - If the last operation was read, this returns the actual number of read bytes which might be smaller than the requested number (partial read). * - If the last operation was write, this returns 0.
As test/test_iot_uart.c implies, we assume here you can call iot_uart_read_async() and iot_uart_write_async() concurrently.
In such concurrent call case, "the last operation" could change in an unexpected manner, and therefore the return value for eGetTxNoOfbytes/eGetRxNoOfbytes could be unreliable.
Imagine the events occur in the following order.
- (1) Call iot_uart_write_async()
- (2) Call iot_uart_read_async()
- (3) Async write operation is complete and the callback function is called with xOpStatus = eUartWriteCompleted
- (4) Call iot_uart_ioctl() with xUartRequest = eGetTxNoOfbytes
In (4), the guy who codes this does want to get the number of successfully written bytes in (1) and (3).
But according to iot_uart.h, this guy could get 0 in this case because "the last operation was(or could be) read".
Probably, this result is not what most people expect.
I suggest we remove "If the last operation was read, this returns 0" and "If the last operation was write, this returns 0" out of this definition.
What do you think of this idea ?
- Dominant language
- C
- Stars
- 16
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·