+ const char *serialpath = "/dev/ttyUSB0";
+ if (argc >= 4) {
+ serialpath = argv[3];
+ }
+ int serialfd = open(serialpath, O_RDWR);
+ if (serialfd == -1) {
+ perror(serialpath);
+ exit(1);
+ }
+
+ struct termios options;
+ memset(&options, 0, sizeof(options));
+ options.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
+ options.c_iflag = IGNBRK | IGNPAR;
+ options.c_lflag = 0;
+ options.c_cc[VMIN] = 1; // Blocking read, minimum one byte.
+ tcsetattr(serialfd, TCSANOW, &options);