77#define B115200 0010002 80#define B230400 0010003 84#define O_NDELAY O_NONBLOCK 90 Value baudv = pop_value(vm);
95 fprintf(stderr,
"Runtime type error: serial_open expects (string path, int baud_rate)\n");
103 int baud = (int)baudv.
i;
166 fd = open(
path, O_RDWR | O_NOCTTY | O_NDELAY);
168 struct termios options;
169 tcgetattr(
fd, &options);
170 cfsetispeed(&options, speed);
171 cfsetospeed(&options, speed);
172 options.c_cflag |= (CLOCAL | CREAD);
173 options.c_cflag &= ~PARENB;
174 options.c_cflag &= ~CSTOPB;
175 options.c_cflag &= ~CSIZE;
176 options.c_cflag |= CS8;
177 options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
178 options.c_iflag &= ~(IXON | IXOFF | IXANY);
179 options.c_oflag &= ~OPOST;
180 tcsetattr(
fd, TCSANOW, &options);
181 fcntl(
fd, F_SETFL, 0);
push_value(vm, make_int(fd > 0 ? fd :0))
Tagged union representing a Fun value.
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.