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 com-port-device\n");
23 printf("Example, linux: ddcp-script-ttyinit /dev/ttyUSB0\n");
24 printf("Example, mac: ddcp-script-ttyinit /dev/tty.usbserial-*\n");
29 /* Set up io port correctly, and open it... */
30 fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
32 fprintf(stderr, "ERROR: open for %s failed.\n",device);
35 tcgetattr(fd, &portset);
37 cfsetospeed(&portset, B9600); /* speed */
38 //cfsetospeed(&portset, B115200); /* speed */
39 //cfsetospeed(&portset, B19200); /* speed */
40 tcsetattr(fd, TCSANOW, &portset);