Console question

Thomas Doerfler Thomas.Doerfler at imd-systems.de
Mon Nov 1 17:25:51 UTC 2004


Etienne,

as always, it depends :-)

If you have a termios based console driver, things are quite 
simple, you can set your console device to "transparent" 
operation without echo, CR/LF conversion or other special 
character filtering.

Here is a sniplet from one of my applications, setting the 
serial port to transparent mode, and make the receive (read) 
function wait at most 1 second...

--------------------------------------------
  struct termios  old_termsettings;
  struct termios  new_termsettings;
  /*
   * save old termios settings, 
   * set new ones: 
   * - read with timeout
   * - set hardware handshake
   */
    if (0 > tcgetattr(dev_fd,&old_termsettings)) {
      rc = pgh_error_io;
      errlog_printf(__FILE__,__LINE__,rc,
		    "%s: can't get device attributes for 
%s",argv[0],dev_name);
    }
    else {
      new_termsettings = old_termsettings;
      new_termsettings.c_lflag 
	&= ~(ICANON|ECHO|ECHONL|ECHOK|ECHOE|ECHOPRT|ECHOCTL);
      new_termsettings.c_cflag |= CRTSCTS;
      new_termsettings.c_cc[VMIN]  =  0; /* minimum receive 
chars: 0         */
      new_termsettings.c_cc[VTIME] = 10; /* minimum time to wait 
for rx: 1sec*/

      if (0 > tcsetattr(dev_fd,TCSANOW,&new_termsettings)) {
--------------------------------------------
wkr,
Thomas.


> Hi everyone,
> A very simple question: How does the console deal with the very
> unpleasant issue of CR/LF end of lines? I mean, is there any conversion
> or what you receive is exactly what was sent by the remote device and
> vice-versa?
> 
> The reason I ask is that I want to code the XMODEM-1K transfer protocol
> on top of my serial connection, which is controled by termios. I need to
> know if the CR/LF will get mixed up.
> 
> Thanks,
> 
> Etienne Fortin
> Sensio

--------------------------------------------
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de
PGP public key available at: http://www.imd-
systems.de/pgp_keys.htm




More information about the users mailing list