[En-Nut-Discussion] USART _read Problem

Harald Kipp harald.kipp at egnite.de
Wed Jan 10 14:45:25 CET 2007


Jason Walton schrieb:
> My application includes a thread created in the main thread whose sole
> purpose is to _read() from UART1 utilizing the devUsartAvr1 Device.  I've
> set the Receive Timeout to 150ms via the _ioctl function and the appropriate
> UART_SETREADTIMEOUT Flag; however, the thread does not return from the
> _read() call until ~60-65 seconds later in the event of "No Data".  I've
>   
...
>     unsigned short read_timeout;
>
>
>   
...
>     _ioctl(_fileno(UART1_PARAMS.File_Handle), UART_SETREADTIMEOUT,
> &UART1_PARAMS.read_timeout); //Set The Receive Timeout
>   

Jason,

_ioctl(UART_SETREADTIMEOUT) expects a pointer to a long, while you 
passed a short. Thus it will the the two high bytes from the memory that 
follows your parameter structure. In the worst case the read will return 
in 49 days. Thus, 60-65 seconds was sheer luck.

Harald






More information about the En-Nut-Discussion mailing list