I am reading a response from a perpherial, but some timesome I get no response at all. If the driver is blocking, then the driver waits forever. If the driver is non-blocking, then the application must loop on fread() for whatever the timeout period is.
Is there feature of fread() or some other read function, that waits for a response until the timeout period has expired (and becomes non-blocking)?
Hello Mark,
Which driver are you using? could you please post the code you are using?
Regards
Soledad
UART driver.
uartfd = fopen("ittya:", (void*)(IO_SERIAL_RAW_IO | IO_SERIAL_NON_BLOCKING));
result = fwrite(&command, length, uartfd);
result = fread(&response, length, uartfd);
If the driver is BLOCKING, and the perpherial doesn't have a response, the fread will wait forever.
if the driver is NON_BLOCKING, then the driver simply get the data if present (does not wait at all).
Is there a flag that BLOCKS for a certain time (i.e. timeout), then returns? The application can then determine if there was a timeout or data.
Linux does allow this behavior. Does MQX?
Hi Mark:
unfortunately there is not a time out flag in current MQX uart driver. we support the following open flags, please refer to mqx\source\io\serial\serial.h
#define IO_SERIAL_RAW_IO (0)
#define IO_SERIAL_XON_XOFF (0x01)
#define IO_SERIAL_TRANSLATION (0x02)
#define IO_SERIAL_ECHO (0x04)
#define IO_SERIAL_HW_FLOW_CONTROL (0x08)
#define IO_SERIAL_NON_BLOCKING (0x10)
#define IO_SERIAL_HW_485_FLOW_CONTROL (0x20)
Regards
Daniel