+int setup_tty(int fd)
+{
+ struct termios tmio;
+
+ int ret = tcgetattr(fd, &tmio);
+ if(ret) {
+ log_printf(ERROR, "Error on tcgetattr(): %s", strerror(errno));
+ return ret;
+ }
+
+ ret = cfsetospeed(&tmio, B9600);
+ if(ret) {
+ log_printf(ERROR, "Error on cfsetospeed(): %s", strerror(errno));
+ return ret;
+ }
+
+ ret = cfsetispeed(&tmio, B9600);
+ if(ret) {
+ log_printf(ERROR, "Error on cfsetispeed(): %s", strerror(errno));
+ return ret;
+ }
+
+ ret = tcsetattr(fd, TCSANOW, &tmio);
+ if(ret) {
+ log_printf(ERROR, "Error on tcsetattr(): %s", strerror(errno));
+ return ret;
+ }
+
+ return 0;
+}
+