12 int read_data(int infd, int outfd)
14 struct epoll_event ev;
19 epoll_fd = epoll_create(1);
21 pr_err("Failed to create epoll socket: %m\n");
27 if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, infd, &ev) == -1) {
28 pr_err("epoll_ctl: %m\n");
33 ret = epoll_wait(epoll_fd, &ev, 1, -1);
38 pr_err("epoll: %m\n");
42 ret = read(infd, buf, sizeof(buf));
49 pr_err("Read EOF, stopping\n");
53 ret = write(outfd, buf, ret);
55 pr_err("write: %m\n");
63 int main(int argc, char *argv[])
65 struct plotter_options options;
66 int fd, baud, ret = 0, out_fd = STDOUT_FILENO;
68 if (read_args(argc, argv, &options))
71 baud = options.baud_rate;
72 fd = open_at_baud(options.device_path, &baud);
76 if (baud != options.baud_rate) {
77 pr_err("Failed to set baudrate to %d, only got %d\n",
78 options.baud_rate, baud);
83 if (options.output_path) {
84 pr_debug("Opening %s for writing the log file\n",
87 out_fd = open(options.output_path,
88 O_CREAT | O_APPEND | O_WRONLY, 0664);
90 pr_err("Failed to open file %s for writing: %m\n",
97 read_data(fd, out_fd);