This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
EB40 serial read
- From: "Xavier Thomas" <thomasxa at hotmail dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Thu, 22 May 2003 17:54:40 +0200
- Subject: [ECOS] EB40 serial read
- Bcc:
Hello
I'm working with a AT91EB40 board and I try to receive data from de serial
port.
The write work correctly but the read block the program. I load the program
with
gdb and I start it with minicom and redboot.
here is my sources:
#include <stdio.h>
#include <cyg/kernel/kapi.h>
#include <cyg/io/io.h>
#include <cyg/io/ttyio.h>
void cyg_user_start(void)
{ cyg_io_handle_t handle1;
char word1[20]="hello\n";
cyg_uint32 len_word1=strlen(word1);
Cyg_ErrNo error;
error=cyg_io_lookup("/dev/tty1",&handle1);
if(error<0)
{ printf("error lookup %d\n",-error);
exit(1);
}else printf("lookup OK\n");
error=cyg_io_write(handle1,word1,&len_word1);
if(error<0)
{ printf("error write %d\n",-error);
exit (3);
}else printf("write OK\n");
cyg_io_get_config(handle1,CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN,0,0);
cyg_io_get_config(handle1,CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH,0,0);
while(1)
{
len_word1=1;
error=cyg_io_read(handle1,word1,&len_word1);
if(error<0)
{ printf("error read %d\n",-error);
exit (2);
}else
{ printf("read OK\n");
printf("%c",word1[0]);
}
}
}
_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous !
http://search.fr.msn.be
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss