Setup and use console driver??

Fernando RUIZ CASAS correo at fernando-ruiz.com
Thu Mar 25 12:35:11 UTC 2004


Hi,

       In shell.c you can see the raw mode to open a serial tty.

       One char with CR.  

       The shell function uses the tty in raw mode to avoid this kind of problems and to interpret
ctrl-D (eof) to exit.

BRGDS.


On Thu, 25 Mar 2004 12:41:16 +1000, Andrew Sinclair wrote:

> 
> 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 
> received.
> 
> The website below has some good info on which flags to set for your 
> purposes.
> http://www.openbsd.org/cgi-bin/man.cgi?query=termios&apropos=0&sektion=0  
> &manpath=OpenBSD+Current&arch=i386&format=html
> 
> 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 
> bytes>);
> eg. bytes=read(fd, &buf, 1);
> 
> write(<file descriptor>, <buffer address>, <number of bytes>);
> eg. write(fd, &val, 1);
> 
> 
> 
> -----Original Message-----
> 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 
> 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 vanner pa natet, prova MSN Messenger http://messenger.msn.se



More information about the users mailing list