public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Problems with cyg_io_read and cyg_io_write!!
@ 2001-07-03  3:05 Arif.Abbas
  2001-07-03  3:10 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Arif.Abbas @ 2001-07-03  3:05 UTC (permalink / raw)
  To: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2733 bytes --]

Hi!!

I am having problems with both the cyg_io_read and the cyg_io_write
functions...
With the cyg_io_write, the problem is that if I write the string ONCE or
twice, it's ok.
But when I have a loop that keeps on writing, I get a SIGTRAP error...
The code looks like follows:


#include <stdio.h>                      /* printf */
#include <string.h>                     /* strlen */
#include <cyg/kernel/kapi.h>            /* All the kernel specific stuff */
#include <cyg/io/io.h>                  /* I/O functions */
#include <cyg/hal/hal_arch.h>           /* CYGNUM_HAL_STACK_SIZE_TYPICAL */
#include <cyg/io/ttyio.h>
#include <cyg/io/serialio.h>

int cyg_user_start(void)
{
  	cyg_io_handle_t serial_handle;
	Cyg_ErrNo ErrorLookup,ErrorNumberWrite,ErrorConfig;
	cyg_serial_info_t ser_info;
	cyg_uint32 config_len;
	char strang[10]="TESTING \n";
	cyg_uint32 len;

	//Find device
	ErrorLookup = cyg_io_lookup("/dev/tty0",&serial_handle );
	
	//Set up device
	ser_info.baud = CYGNUM_SERIAL_BAUD_38400;
	ser_info.stop = CYGNUM_SERIAL_STOP_1;
	ser_info.parity = CYGNUM_SERIAL_PARITY_EVEN;
	ser_info.word_length = CYGNUM_SERIAL_WORD_LENGTH_8;
	ser_info.flags = CYG_SERIAL_FLAGS_DEFAULT;
	config_len = sizeof(ser_info);
	ErrorConfig =
cyg_io_set_config(serial_handle,CYG_IO_SET_CONFIG_SERIAL_INFO,&ser_info,&con
fig_len);
	
	//Write to device
	len=sizeof(strang);	
	ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);
	if(ErrorNumberWrite == 0)
	{
		printf("Writing to COM2 FAILED! \n");
	}

	while(1)
	{
		len=sizeof(strang);
		ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);

	}
}

When I use the step option in insigth, I see that the variable "len" is
INCREASED each time I run 
the cyg_io_write()...Why???
That is why I declare the value of "len" for each loop.
Strange isn't it!!
When I step at a slow speed, there is no problem, but when I "let go", I get
the error...


Then comes the problem with the read...
The code is exactly the same (with the lookup and configure parts), but the
difference lies in
the change of cyg_io_write() to cyg_io_read()...

	//Read from device
	len=1;

	ErrorRead=cyg_io_read(serial_handle,&strang,&len);
	if(ErrorRead == 0)
	{
		printf("Läsning av COM2 lyckades! \n");
		printf( " %s ",strang);
	}	

When I get to the cyg_io_read() part, I get a SIGTRAP error...And I haven't
written anything in the terminal!!
The cyg_io_read() uses the blocking per default, so it should wait until
something has been written on the terminal
and ENTER has been pressed, right?

WHAT AM I DOING WRONG???
I'd really appreciate if someone could help me out.
I am using a StrongArm processor on a mediaEngine board (quite similiar to
the supported nanoEngine).

THANK YOU!

Regards
Arif
	

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] Problems with cyg_io_read and cyg_io_write!!
  2001-07-03  3:05 [ECOS] Problems with cyg_io_read and cyg_io_write!! Arif.Abbas
@ 2001-07-03  3:10 ` Andrew Lunn
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2001-07-03  3:10 UTC (permalink / raw)
  To: Arif.Abbas; +Cc: ecos-discuss

> 	ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);

Do you realy want &strang, or just strang?

> 		ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);

Same as above.

        Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [ECOS] Problems with cyg_io_read and cyg_io_write!!
@ 2001-07-03  3:53 Arif.Abbas
  0 siblings, 0 replies; 3+ messages in thread
From: Arif.Abbas @ 2001-07-03  3:53 UTC (permalink / raw)
  To: ecos-discuss

I tried replacing the pointer with the variable, but the problem still
remains...
I get exactly the same error as I got before.... 

confusing huh??

/Arif

-----Original Message-----
From: Andrew Lunn [ mailto:andrew.lunn@ascom.ch ]
Sent: den 3 juli 2001 12:11
To: Abbas Arif
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] Problems with cyg_io_read and cyg_io_write!!


> 	ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);

Do you realy want &strang, or just strang?

> 		ErrorNumberWrite = cyg_io_write(serial_handle,&strang,&len);

Same as above.

        Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-03  3:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-03  3:05 [ECOS] Problems with cyg_io_read and cyg_io_write!! Arif.Abbas
2001-07-03  3:10 ` Andrew Lunn
2001-07-03  3:53 Arif.Abbas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).