Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Call to read() returns EINVAL when it should be returning EAGAIN: (3 Items)
   
Call to read() returns EINVAL when it should be returning EAGAIN  
OS version 6.5.0 SP1

My application is reading from a serial port created using devc-serusb. The port is opened using the O_NONBLOCK flag. 
The port (m_in) is polled every 10 ms with a call like -

uint8_t c = 0;
int32_t ret = read( m_in, &c, 1 );

When there is nothing to read ret is set to -1 and errno is set to EINVAL, whereas according to the documentation it 
should be set to EAGAIN. When there is data available to be read, ret is set to 1 and c contains the received byte, 
which is correct.

I cannot just ignore the errno because I need to detect a failure caused by the user unplugging the USB cable.

Is this a bug, or am I missing something?
RE: Call to read() returns EINVAL when it should be returning EAGAIN  
Hi Jim,

This is likely not the best forum for this hardware related question; core OS is more like scheduling algorithms or IPC 
mechanisms.

You would be more likely to get a relevant reply either via a hardware-related forum or, if you have one, via your 
formal support interface.


-----Original Message-----
From: Jim Douglas [mailto:community-noreply@qnx.com] 
Sent: Wednesday, January 30, 2013 5:58 PM
To: ostech-core_os
Subject: Call to read() returns EINVAL when it should be returning EAGAIN

OS version 6.5.0 SP1

My application is reading from a serial port created using devc-serusb. The port is opened using the O_NONBLOCK flag. 
The port (m_in) is polled every 10 ms with a call like -

uint8_t c = 0;
int32_t ret = read( m_in, &c, 1 );

When there is nothing to read ret is set to -1 and errno is set to EINVAL, whereas according to the documentation it 
should be set to EAGAIN. When there is data available to be read, ret is set to 1 and c contains the received byte, 
which is correct.

I cannot just ignore the errno because I need to detect a failure caused by the user unplugging the USB cable.

Is this a bug, or am I missing something?




_______________________________________________

OSTech
http://community.qnx.com/sf/go/post98886
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
Re: Call to read() returns EINVAL when it should be returning EAGAIN  
I tried this and it worked as expected - both on ser1 and and serusb1.  read() returned -1 with errno as  EAGAIN.