Subject: Re: 2 stop-bits and 8 data bits?
To: None <netbsd-help@netbsd.org>
From: David Wetzel <dave@turbocat.de>
List: netbsd-help
Date: 03/15/2000 12:58:34
Hi,

the person who made the hardware has a QBASIC program that works with this  
serial port setting:

OPEN "com1: 19200,N,8,2,CD0,CS0,DS0,OP0,RS,TB2048,RB2048" FOR RANDOM AS #1


I tried this, but not all LEDs flash and that hardware does not answer :-(

What should I use in term.c_cflag? Thanks!




#define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_))
#define TTY_SETATTR(_FD_, _ARG_) tcsetattr((_FD_), TCSANOW, (_ARG_))

#define SERPORTNAME    "/dev/tty01"

static int port;

struct termios term;  // new

int open_line(char *device)
{

    printf("in open_line open device %s port= %d \n",device,port);


    /* open the serial device */
    if ((port = open (device, O_RDWR | O_NDELAY)) == -1) {
        fprintf (stderr, "cannot open %s\n", device);
        perror ("open");
        exit (1);
    }
    fcntl (port, F_SETFL, O_RDWR);
    fprintf (stderr, "startup, reading from %s", device);

    if (TTY_GETATTR(port,  &term) == -1) {
        perror("tcgetattr");
        exit(1);
    }

    memset(term.c_cc, 0, sizeof(term.c_cc));
    term.c_cc[VMIN] = 1;             /* read one char */
    term.c_cc[VTIME] = 0;            /* no timer */
    //term.c_cflag = B9600|CS8|CREAD|CLOCAL|CRTSCTS;
    printf("term.c_cflag =%x\n",term.c_cflag);
    term.c_cflag = B19200|CS8|CSTOPB|CLOCAL;
    printf("term.c_cflag =%x\n",term.c_cflag);

    term.c_iflag = 0;
    term.c_oflag = 0;
    term.c_lflag = 0;

    if (TTY_SETATTR(port, &term) == -1) {
        perror("tcsetattr");
        exit(1);
    }


    printf("in open_line open device %s port= %d \n",device,port);

    if(port==-1)    printf("in open_line failed to open device %s\n",device);

    return port;
}


---
   _  _
 _(_)(_)_  David Wetzel, Turbocat's Development,
(_) __ (_) Buchhorster Strasse 23, D-16567 Muehlenbeck/Berlin, FRG,
  _/  \_   Fax +49 33056 82835 NeXTmail dave@turbocat.de
 (______)  http://www.turbocat.de/
           DEVELOPMENT * CONSULTING * ADMINISTRATION