This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Serial Port in non-blocking mode


Question on the related subject:
How to set the io_read write in non-blocking
mode. I have tried the following code without
success:

cyg_uint32 oeblen=0;	// length of blocking/non
blocking variable
cyg_uint32 oeb;			// variable blocking/non
blocking - 0 is non blocking
    oeb=0;
    oeblen=sizeof(oeb);
#if 1
cyg_io_get_config(handle_ser1,CYG_IO_GET_CONFIG_SERIAL_READ_BLOCKING,&oeb,&oeblen);
oeb=0;
oeblen=sizeof(oeb);
cyg_io_set_config(handle_ser1,CYG_IO_SET_CONFIG_SERIAL_READ_BLOCKING,&oeb,&oeblen);


cyg_io_get_config(handle_ser1,CYG_IO_GET_CONFIG_SERIAL_WRITE_BLOCKING,&oeb,&oeblen);
    oeb=0;
	oeblen=sizeof(oeb);
   
cyg_io_set_config(handle_ser1,CYG_IO_GET_CONFIG_SERIAL_WRITE_BLOCKING,&oeb,&oeblen);

#endif

Do we need to specify the non-blocking mode
during the ecos build?

Baljeet



--- Andrew Lunn <andrew@lunn.ch> wrote:
> 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
> 
> 



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]