Setup and use console driver??
Andrew Sinclair
andrews at elprotech.com
Mon Mar 22 23:03:35 UTC 2004
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/
More information about the users
mailing list