* RE: [ECOS] Read an string from serial port
@ 2003-12-30 18:30 Michael Anburaj
0 siblings, 0 replies; 3+ messages in thread
From: Michael Anburaj @ 2003-12-30 18:30 UTC (permalink / raw)
To: ca06332, ecos-discuss
This may be due to difference in BAUD rate.
I don't know how you set the BAUD rate when using Âecho command (May be it
defaults to a known value, which may be different from what eCOS uses
(38400)).
Use 'minicom' on linux, where you can specify the serial port parameters
(like BAUD) & match things on both ends.
Cheers,
-Mike.
>From: Francesc Teixido Navarro <ca06332@salleURL.edu>
>To: ecos-discuss@sources.redhat.com
>Subject: [ECOS] Read an string from serial port
>Date: Tue, 30 Dec 2003 09:31:11 +0100 (CET)
>
>Hi all,
> I'm trying to read an incomng string from serial port, it is
>connected to a linux machine.
> The string is sent via "echo" command (echo <string> > /dev/ttyS1)
>but in the board I only read unrecognizable data. Can anyone helps me??
>what error I do??
>
> The idea is to read a binary file in the future.
>
> Thanks
> The code:
>..................................
> int i;
> int length;
> //unsigned char *data;
> char data;
> cyg_io_handle_t hport;
> Cyg_ErrNo err;
> cyg_serial_info_t info;
> int len;
>
> //int data_size = 0xF;
>
>
> /*
> data = (unsigned char *)malloc(sizeof(char) * data_size);
> if (!data){
> printf("There's no suficient memory\n");
> }
> */
>///////////////////////////////////
>
> printf("Trying to open Serial Port ... ");
> err = cyg_io_lookup ("/dev/ser3", &hport);
> if (err != ENOERR){
> printf("KO\n");
> }
> printf("OK\n");
>
> printf("Get configuration ...");
> len = sizeof(info);
> err = cyg_io_get_config(hport, CYG_IO_GET_CONFIG_SERIAL_INFO,
>&info, &len);
> if (err != ENOERR){
> printf("KO\n");
> }
> printf("OK\n");
>
> printf("Set configuration ...");
> info.baud=CYGNUM_SERIAL_BAUD_38400;
> info.stop=CYGNUM_SERIAL_STOP_1;
> info.word_length=CYGNUM_SERIAL_WORD_LENGTH_8;
> err = cyg_io_set_config(hport,CYG_IO_SET_CONFIG_SERIAL_INFO,
>&info, &len);
> if (err != ENOERR) {
> printf("KO\n");
> return;
> }
> printf("OK\n");
>
> printf("Trying to read Serial Port ...\n");
> length = sizeof(data);
> i = 0x0;
> while (1){
> printf("Linia: %d :\n", i);
> err = cyg_io_read(hport, &data, &length);
> printf("%c\n", data);
> i++;
> }
>
> //free(data);
>}
>
>
>--
>Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
>and search the list archive: http://sources.redhat.com/ml/ecos-discuss
>
_________________________________________________________________
Tired of slow downloads? Compare online deals from your local high-speed
providers now. https://broadband.msn.com
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [ECOS] Read an string from serial port
@ 2003-12-31 1:29 Andy Dyer
0 siblings, 0 replies; 3+ messages in thread
From: Andy Dyer @ 2003-12-31 1:29 UTC (permalink / raw)
To: ecos-discuss
> -----Original Message-----
> From: ecos-discuss-owner@sources.redhat.com
> [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Michael
> Anburaj
> Sent: Tuesday, December 30, 2003 12:09 PM
> To: ca06332@salleURL.edu; ecos-discuss@sources.redhat.com
> Subject: RE: [ECOS] Read an string from serial port
>
>
> This may be due to difference in BAUD rate.
>
> I don't know how you set the BAUD rate when using 'echo'
> command (May be it
> defaults to a known value, which may be different from what eCOS uses
> (38400)).
>
> Use 'minicom' on linux, where you can specify the serial port
> parameters
> (like BAUD) & match things on both ends.
If it is baud rate, you can use the 'stty' command to change
serial port parameters on a particular tty from the shell.
stty works on the port connected to stdin, something like this:
stty speed 38400 cs8 -parenb -cstopb < /dev/ttyS01
should set 8/N/1. There are a lot of other options dealing
with how input and output gets processed, see the info and
man pages for more.
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ECOS] Read an string from serial port
@ 2003-12-30 8:28 Francesc Teixido Navarro
0 siblings, 0 replies; 3+ messages in thread
From: Francesc Teixido Navarro @ 2003-12-30 8:28 UTC (permalink / raw)
To: ecos-discuss
Hi all,
I'm trying to read an incomng string from serial port, it is
connected to a linux machine.
The string is sent via "echo" command (echo <string> > /dev/ttyS1)
but in the board I only read unrecognizable data. Can anyone helps me??
what error I do??
The idea is to read a binary file in the future.
Thanks
The code:
..................................
int i;
int length;
//unsigned char *data;
char data;
cyg_io_handle_t hport;
Cyg_ErrNo err;
cyg_serial_info_t info;
int len;
//int data_size = 0xF;
/*
data = (unsigned char *)malloc(sizeof(char) * data_size);
if (!data){
printf("There's no suficient memory\n");
}
*/
///////////////////////////////////
printf("Trying to open Serial Port ... ");
err = cyg_io_lookup ("/dev/ser3", &hport);
if (err != ENOERR){
printf("KO\n");
}
printf("OK\n");
printf("Get configuration ...");
len = sizeof(info);
err = cyg_io_get_config(hport, CYG_IO_GET_CONFIG_SERIAL_INFO,
&info, &len);
if (err != ENOERR){
printf("KO\n");
}
printf("OK\n");
printf("Set configuration ...");
info.baud=CYGNUM_SERIAL_BAUD_38400;
info.stop=CYGNUM_SERIAL_STOP_1;
info.word_length=CYGNUM_SERIAL_WORD_LENGTH_8;
err = cyg_io_set_config(hport,CYG_IO_SET_CONFIG_SERIAL_INFO,
&info, &len);
if (err != ENOERR) {
printf("KO\n");
return;
}
printf("OK\n");
printf("Trying to read Serial Port ...\n");
length = sizeof(data);
i = 0x0;
while (1){
printf("Linia: %d :\n", i);
err = cyg_io_read(hport, &data, &length);
printf("%c\n", data);
i++;
}
//free(data);
}
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-12-30 18:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 18:30 [ECOS] Read an string from serial port Michael Anburaj
-- strict thread matches above, loose matches on Subject: below --
2003-12-31 1:29 Andy Dyer
2003-12-30 8:28 Francesc Teixido Navarro
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).