Setup and use console driver??
Carl-Johan Hansson
cjhansson at hotmail.com
Tue Mar 23 14:50:15 UTC 2004
Ok, that pushed me a bit in the right direction but unfortunately not all
the way to my goal. The driver works and I can write data and I can also
make changes to the settings, but I cant make it read my data. I tried to
disable the line : options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);,
then its possible to read data but I need to press return to get a
reaction. Any suggestion way I cant get data into the system? My printf
calls are connected to the same port, is that the problem? Is there a simple
way of disabling it?
Best Regards
CJ
>From: Andrew Sinclair <andrews at elprotech.com>
>Reply-To: "andrews at elprotech.com" <andrews at elprotech.com>
>To: 'Carl-Johan Hansson' <cjhansson at hotmail.com>, "rtems-users at rtems.com"
><rtems-users at rtems.com>
>Subject: RE: Setup and use console driver??
>Date: Tue, 23 Mar 2004 09:03:35 +1000
>
>You could use termios. There is plenty of info in the man files in unix /
>linux on how to use it. Below is pretty close to what I use to init termios
>for binary data at 115200bps, 8 data bits, no parity, 1 stop bit, 100msec
>read timeout, on a pc386 platform. (I took the liberty of removing stuff of
>no interest ;) ) From there you use the file read and write functions to
>send data.
>
>#include <stdio.h>
>#include <termios.h>
>
>int serial_init()
>{
> struct termios options;
>
> RadioState=RS_RX_IDLE;
> fp = fopen ("/dev/ttyS1", "r+b"); // B9600|CS0 termios default
> fd = fileno(fp);
> tcgetattr(fd, &options);
> /* set raw input, 1 second timeout */
> options.c_cflag |= (CLOCAL | CREAD); /* Enable the receiver and set local
>mode...*/
> options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /*input is
>unprocessed.*/
> options.c_oflag &= ~OPOST; /*Postprocess output (not set = raw output)*/
> options.c_cc[VMIN] = 0;
> options.c_cc[VTIME] = 1; /*delay specified in 10ths of seconds - wait
>forever*/
> /*No parity (8N1):*/
> options.c_cflag &= ~PARENB;
> options.c_cflag &= ~CSTOPB;
> options.c_cflag &= ~CSIZE; /* Mask the character size bits */
> options.c_cflag &= ~CRTSCTS;
> options.c_cflag |= CS8; /* Select 8 data bits */
> options.c_iflag &= ~(IGNBRK | BRKINT | INLCR | ICRNL | IXON | IXOFF |
>IXANY); /*disable flow control, disable CR->LF*/
> /* set the options */
> cfsetispeed(&options, B115200);
> cfsetospeed(&options, B115200);
>/* options.c_cflag |= CNEW_RTSCTS; hardware flow control*/
> /* fcntl(fd, F_SETFL, 0);*/
> tcsetattr(fd, TCSANOW, &options);
> if (!fd)
> {
> printf ("Unable to open /dev/ttyS1");
> return(FALSE);
>
> }
> else
> return TRUE;
>}
>
>
>-----Original Message-----
>From: Carl-Johan Hansson [SMTP:cjhansson at hotmail.com]
>Sent: Tuesday, 23 March 2004 2:12 AM
>To: rtems-users at rtems.com
>Subject: Setup and use console driver??
>
>I'm developing application for an ERC32 processor and now I reached the
>point where I want to use the serial port for sending and receiving data.
>If
>I just open the port and start using it, I end up in some kind of console
>application mode. I just want to send and receive binary data in various
>speeds, how hard can it be??
>Anyone got hints or software that shows how to do it?
>
>/CJ
>
>_________________________________________________________________
>Senaste nytt fran motormarknaden http://motor.msn.se/
>
_________________________________________________________________
Chatta med vänner på nätet, pröva MSN Messenger http://messenger.msn.se
More information about the users
mailing list