This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
cyg_io_read
- From: grahamlab <graham dot labdon at cranems dot co dot uk>
- To: ecos-discuss at ecos dot sourceware dot org
- Date: Mon, 20 Apr 2009 03:52:38 -0700 (PDT)
- Subject: [ECOS] cyg_io_read
Hello all
I am having trouble understanding the operation of the cyg_io_read
operation.
I have a simple programto read the /dev/ser1 device on my stm3120e dev
board.
If i set blocking on read then my cyg_io_read call only returns when the
specified number of bytes has been received -
char msg[10]
cyg_uint32 msglen=10;
res = cyg_io_read(handle,msg,&msglen); // returns when 10 bytes have been
received.
However, I want to read bytes as they arrive. With this in mind I set the
device to operate in non blocking mode -
block = 0;
len = sizeof(cyg_uint32);
cyg_io_set_config(handle,CYG_IO_SET_CONFIG_SERIAL_READ_BLOCKING,&block,&len);
I set up my code to ignore EAGAIN errors on the read -
while(1)
{
char msg[10];
cyg_uint32 msglen=10;
res = cyg_io_read(handle,msg,&msglen);
if (res != -EAGAIN)
{
diag_printf ("read %d %d\n",res,msglen);
for (cyg_uint32 x = 0; x < msglen; ++x)
{
diag_printf("%c",msg[x]);
}
diag_printf("\n\n");
}
With this in place I expected to receive all bytes sent by the sending
program , BUT NO
I only receive the first 2 or three. If I send single characters I get these
but if I send anything more I dont get what I sent.
I would be grateful if someone could explain this behavior.
Thanks Graham
--
View this message in context: http://www.nabble.com/cyg_io_read-tp23134401p23134401.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss