This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Problems with cyg_io_read and cyg_io_write!!
- To: ecos-discuss at sources dot redhat dot com
- Subject: [ECOS] Problems with cyg_io_read and cyg_io_write!!
- From: Arif dot Abbas at combitechsystems dot com
- Date: Tue, 3 Jul 2001 12:05:31 +0200
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