1 /* vim: set sw=8 ts=8 si et: */
2 /* Linux software to set the speed on the serial line
3 * Written by Guido Socher
4 * run this program like this:
5 * ttydevinit /dev/ttyUSB0 (for usb com1) and then use
6 * cat > /dev/ttyUSB0 to write or cat /dev/ttyUSB0 to read the answers
15 int main(int argc, char *argv[])
17 struct termios portset;
22 printf("USAGE: ddcp-script-ttyinit /dev/ttyUSB0\n");
23 printf("or ddcp-script-ttyinit /dev/ttyUSB1\n");
28 /* Set up io port correctly, and open it... */
29 fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
31 fprintf(stderr, "ERROR: open for %s failed.\n",device);
34 tcgetattr(fd, &portset);
36 cfsetospeed(&portset, B9600); /* speed */
37 //cfsetospeed(&portset, B115200); /* speed */
38 //cfsetospeed(&portset, B19200); /* speed */
39 tcsetattr(fd, TCSANOW, &portset);