This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Re: Serial Port in non-blocking mode
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Gatien Gillon <ggillon at ulb dot ac dot be>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Fri, 22 Apr 2005 19:28:21 +0200
- Subject: Re: Re: [ECOS] Serial Port in non-blocking mode
- References: <200504220852.KAA07995@web1.ulb.ac.be>
On Fri, Apr 22, 2005 at 10:52:23AM +0200, Gatien Gillon wrote:
> I'm getting 0x0 instead of the caracter ... *z = 0x0 when I put a breakpoint on the "if( *z >= 'A' && *z <= 'z' )" (see lower)
>
> void readch()
> {
> int i;
>
> cyg_io_read( ser_handle, z, &l );
>
> if( *z >= 'A' && *z <= 'z' )
>From the documentation:
// Read data from a device
Cyg_ErrNo cyg_io_read(
cyg_io_handle_t handle,
void *buf,
cyg_uint32 *len )
This function receives data from a device. The desired size of data to
receive is contained in *len and the actual size obtained will be
returned in the same place.
So you first need to set l to 1 before calling the function. I cannot
see this in your code. Next problem is that you have the device in
none blocking mode. So say it has nothing in its buffer. So it sets l
to 0 and returns. Your code does not look at the value of l to
determine how many charactors it has returned. You always assume it
has returned a charactor, which is obviously false!
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss