Setup and use console driver??

Carl-Johan Hansson cjhansson at
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 can’t make it read my data. I tried to 
disable the line : “options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);”, 
then it’s possible to read data but I need to press “return” to get a 
reaction. Any suggestion way I can’t 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

>From: Andrew Sinclair <andrews at>
>Reply-To: "andrews at" <andrews at>
>To: 'Carl-Johan Hansson' <cjhansson at>, "rtems-users at" 
><rtems-users at>
>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
>	options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);	 /*input is
>	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
>	/*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]
>Sent:	Tuesday, 23 March 2004 2:12 AM
>To:	rtems-users at
>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.
>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?
>Senaste nytt fran motormarknaden

Chatta med vänner på nätet, pröva MSN Messenger

More information about the users mailing list