[ECOS] Serial Port in non-blocking mode

Andrew Lunn andrew@lunn.ch
Fri Apr 22 21:47:00 GMT 2005


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



More information about the Ecos-discuss mailing list