Serial communication: gina_serdev_read() returning -1 and no data | Thales IoT Developer Community
June 22, 2021 - 3:53am, 1994 views
I am using the SDK to develop an app in C to read and write on the serial (ASC1).
For that, I've followed the examples found in SDK, however, I am having an issue.
Basically, I have these steps:
- gina_serdev_open() for ASC1
- gina_serdev_ioctl() to register the callback for the serial device events
- at the serdev callback, I use this tx_event_flags_set() to set the corresponding event: GINA_SERDEV_CB_DATA_AVAILABLE;
- busy waits in a while(1) loop for: tx_event_flags_get(..., TX_WAIT_FOREVER);
- sends data to the Module via ASC1
- this will cause the tx_egent_flags_get() to return the bit set to read data from uart
- read data gina_serdev_read();
- print data in DEBUG interface (ASC0)
- loop again to tx_event_flags_get(..., TX_WAIT_FOREVER);
When I write data on ASC1, the code calls the registered uart callback, sets the corresponding flag, which causes the code to read data via gina_serdev_read(), but it is returning -1 and no data is seen.
Since the code is an infinite loop, after reading data (error), it starts again waiting for the next event.
At this point, it never passes again the tx_event_flags_get(..., TX_WAIT_FOREVER);
Even though I am sending more data.
Am I missing something?
Is there a way to verify why gina_serdev_read() returned -1? Similar to "errno" or something.