This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Problem with SCANF function
- From: Jonathan Larmour <jifl at jifvik dot org>
- To: bkankur <connintel at gmail dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Fri, 12 Mar 2010 23:56:25 +0000
- Subject: Re: [ECOS] Problem with SCANF function
- References: <27874746.post@talk.nabble.com>
On 12/03/10 13:59, bkankur wrote:
>
> Dear Friends,
>
> I am using polling based serial driver by specifying buffer size(cbuf->len)
> to zero through configuration tool.
> When I call scanf function from application layer, I found that it is
> calling serial_read function from file
> packages\io\serial\current\src\common\serial.c.
>
> For given function, static Cyg_ErrNo serial_read(cyg_io_handle_t handle,
> void *_buf, cyg_uint32 *len)
> I printed the argument values and found that *len=-1, which makes "while
> (size++ < *len) " condition true always and my program gets stuck there.
That certainly doesn't seem right. *len should not be -1 while in the loop
in serial_read (presumably that's the loop you mean). That would imply
it's been called with *len==-1. But the libc stream support should be
using a positive integer of at least 1. (refill_read_buffer() in
stream.cxx is the key here.)
Just in case, you may want to increase your stack sizes in case
something's getting scribbled on due to stack overflow.
> I did similar thing for serial_write and I got *len value correct when I
> call Printf function from user application.
>
> I try to debug the /libc/sdio/current/src/input/scanf.cxx, but I couldn't
> understand it. Can anyone please guide me where to look at for the error, in
> my case *len = -1 which should be greater than 1 ?
Double check what the value of *len is at the entry to serial_read. You
can also try stepping through
Cyg_StdioStream::refill_read_buffer() to see what it's calling it with.
Jifl
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss