Setup and use console driver??
andrews at elprotech.com
Thu Mar 25 02:41:16 UTC 2004
I think what you are seeing has to do with the ICANON flag. When it is set
the preceeding data is buffered and is only sent once a return character is
The website below has some good info on which flags to set for your
It could be something to do with using printf. I use the following
functions to write and read from the serial port.
<no of bytes read> read(<file descriptor>, <buffer address>, <number of
eg. bytes=read(fd, &buf, 1);
write(<file descriptor>, <buffer address>, <number of bytes>);
eg. write(fd, &val, 1);
From: Carl-Johan Hansson [SMTP:cjhansson at hotmail.com]
Sent: Wednesday, 24 March 2004 12:50 AM
To: andrews at elprotech.com; rtems-users at rtems.com
Subject: RE: Setup and use console driver??
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
way of disabling it?
>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
>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
>no interest ;) ) From there you use the file read and write functions to
> struct termios options;
> 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
> 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 TRUE;
>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.
>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 http://motor.msn.se/
Chatta med vanner pa natet, prova MSN Messenger http://messenger.msn.se
More information about the users