FT12LowLevelDriver::FT12LowLevelDriver (const char *dev, Trace * tr) { struct termios t1; t = tr; pth_sem_init (&in_signal); pth_sem_init (&out_signal); pth_sem_init (&send_empty); pth_sem_set_value (&send_empty, 1); getwait = pth_event (PTH_EVENT_SEM, &out_signal); TRACEPRINTF (t, 1, this, "Open"); fd = open (dev, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC); if (fd == -1) return; set_low_latency (fd, &sold); close (fd); fd = open (dev, O_RDWR | O_NOCTTY); if (fd == -1) return; if (tcgetattr (fd, &old)) { restore_low_latency (fd, &sold); close (fd); fd = -1; return; } if (tcgetattr (fd, &t1)) { restore_low_latency (fd, &sold); close (fd); fd = -1; return; } t1.c_cflag = CS8 | PARENB | CLOCAL | CREAD; t1.c_iflag = IGNBRK | INPCK | ISIG; t1.c_oflag = 0; t1.c_lflag = 0; t1.c_cc[VTIME] = 1; t1.c_cc[VMIN] = 0; cfsetospeed (&t1, B19200); cfsetispeed (&t1, 0); if (tcsetattr (fd, TCSAFLUSH, &t1)) { restore_low_latency (fd, &sold); close (fd); fd = -1; return; } sendflag = 0; recvflag = 0; repeatcount = 0; mode = 0; Start (); TRACEPRINTF (t, 1, this, "Opened"); }
BCU1SerialLowLevelDriver::BCU1SerialLowLevelDriver (const char *dev, Trace * tr) { struct termios ti; t = tr; pth_sem_init (&in_signal); pth_sem_init (&out_signal); pth_sem_init (&send_empty); pth_sem_set_value (&send_empty, 1); getwait = pth_event (PTH_EVENT_SEM, &out_signal); TRACEPRINTF (t, 1, this, "Open"); fd = open (dev, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC); if (fd == -1) return; set_low_latency (fd, &sold); close (fd); fd = open (dev, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC); if (fd == -1) return; if (tcgetattr (fd, &told)) { restore_low_latency (fd, &sold); close (fd); fd = -1; return; } if (tcgetattr (fd, &ti)) { restore_low_latency (fd, &sold); close (fd); fd = -1; return; } ti.c_cflag = CS8 | CLOCAL | CREAD; ti.c_iflag = IGNBRK | INPCK | ISIG; ti.c_oflag = 0; ti.c_lflag = 0; ti.c_cc[VTIME] = 1; ti.c_cc[VMIN] = 0; cfsetospeed (&ti, B9600); cfsetispeed (&ti, 0); if (tcsetattr (fd, TCSAFLUSH, &ti)) { restore_low_latency (fd, &sold); close (fd); fd = -1; return; } setstat (getstat () & ~(TIOCM_RTS | TIOCM_CTS)); while ((getstat () & TIOCM_CTS)); Start (); TRACEPRINTF (t, 1, this, "Opened"); }