#include <string.h>
#include <linux/termios.h>
#include <unistd.h>
+#include "debug.h"
/*
* HACK: declare the ioctl function by hand...
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
- fprintf(stderr, "error opening %s: %m\n", device);
+ pr_err("error opening %s: %m\n", device);
return fd;
}
if (ioctl(fd, TCGETS2, &tios)) {
- perror("TCGETS2");
+ pr_err("TCGETS2: %m\n");
goto err;
}
tios.c_ospeed = *baud;
if (ioctl(fd, TCSETS2, &tios)) {
- perror("TCSETS2");
+ pr_err("TCSETS2: %m");
goto err;
}
if (ioctl(fd, TCGETS2, &tios)) {
- perror("TCGETS2");
+ pr_err("TCGETS2: %m");
goto err;
}
#include "options.h"
#include "baud.h"
+#include "debug.h"
int main(int argc, char *argv[])
{
return 1;
if (baud != options.baud_rate) {
- printf("Failed to set baudrate to %d, only got %d\n",
+ pr_err("Failed to set baudrate to %d, only got %d\n",
options.baud_rate, baud);
close(fd);
return 1;
ev.events = EPOLLIN;
ev.data.fd = fd;
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) {
- perror("epoll_ctl");
+ pr_err("epoll_ctl: %m\n");
return 1;
}
continue;
if (ret < 0) {
- perror("epoll");
+ pr_err("epoll: %m\n");
return 1;
}
ret = read(fd, buf, sizeof(buf));
if (read < 0) {
- perror("read");
+ pr_err("read: %m\n");
break;
}
- if (ret == 0)
+ if (ret == 0) {
+ pr_err("Read EOF, stopping\n");
break;
+ }
ret = write(1, buf, ret);
if (read < 0) {
- perror("write");
+ pr_err("write: %m\n");
break;
}
}