summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-01-10 12:31:34 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-01-10 12:31:34 (GMT)
commit6218a84102038f95683cffbbde9fcf9fff8d2827 (patch)
tree61ff60f126451ef14a8122abe0ba04102252b1a4
parent0e13f8198ac1edc6f9b3a62492425cbdfd8669e4 (diff)
improved termios settings
fixed length check at write fixed output at log
-rw-r--r--openwrt/rhctl/Makefile2
-rw-r--r--openwrt/rhctl/files/rhctl.config7
-rw-r--r--options.c3
-rw-r--r--serialclient.c3
-rw-r--r--utils.c17
5 files changed, 25 insertions, 7 deletions
diff --git a/openwrt/rhctl/Makefile b/openwrt/rhctl/Makefile
index 84fc2e3..cc2acac 100644
--- a/openwrt/rhctl/Makefile
+++ b/openwrt/rhctl/Makefile
@@ -18,7 +18,7 @@ PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://localhost/
-PKG_MD5SUM:=646e9d1439cc9c23d3cb64773b34c513
+PKG_MD5SUM:=d406052350d01799bcf69ea2c575a436
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
diff --git a/openwrt/rhctl/files/rhctl.config b/openwrt/rhctl/files/rhctl.config
index 3b4874e..7d14e51 100644
--- a/openwrt/rhctl/files/rhctl.config
+++ b/openwrt/rhctl/files/rhctl.config
@@ -1,4 +1,5 @@
config 'switchctl'
+ option log 'syslog:5,switchctl,daemon'
option command_sock '/var/run/rhctl/switchctl.sock'
option baudrate '19200'
option device '/dev/audioswitch'
@@ -9,7 +10,7 @@ config 'switchctl'
config 'serialclient'
# option disabled 1
option name 'master'
- option log 'syslog:3,serialclient-master,daemon'
+ option log 'syslog:5,serialclient-master,daemon'
option command_sock '/var/run/rhctl/switchctl.sock'
option baudrate '38400'
option device '/dev/ttyMaster'
@@ -18,13 +19,15 @@ config 'serialclient'
config 'serialclient'
# option disabled 1
option name 'standby'
- option log 'syslog:3,serialclient-standby,daemon'
+ option log 'syslog:5,serialclient-standby,daemon'
option command_sock '/var/run/rhctl/switchctl.sock'
option baudrate '38400'
option device '/dev/ttyStandby'
option type 'standby'
config 'heartbeatclient'
+ option log 'syslog:5,heartbeatclient,daemon'
option command_sock '/var/run/rhctl/switchctl.sock'
option baudrate '38400'
option device '/dev/ttyHeartbeat'
+
diff --git a/options.c b/options.c
index d4f05f3..8723981 100644
--- a/options.c
+++ b/options.c
@@ -1,3 +1,4 @@
+
/*
* rhctl
*
@@ -458,6 +459,6 @@ void options_print(options_t* opt)
#ifdef OPT_HEARTBEATCLIENT
printf("serial_dev: '%s'\n", opt->serial_dev_);
- printf("timeout: %d\m", opt->timeout_);
+ printf("timeout: %d\n", opt->timeout_);
#endif
}
diff --git a/serialclient.c b/serialclient.c
index 87e9428..f81c7cb 100644
--- a/serialclient.c
+++ b/serialclient.c
@@ -63,9 +63,10 @@ int process_data(int src_fd, int dest_fd)
}
offset += ret;
- if(offset+1 >= len)
+ if(offset >= len)
break;
}
+ log_printf(DEBUG, "wrote %d bytes to fd (%d)", offset, dest_fd);
return 0;
}
diff --git a/utils.c b/utils.c
index 6178d3b..e046b9c 100644
--- a/utils.c
+++ b/utils.c
@@ -150,6 +150,21 @@ int setup_tty(int fd, speed_t speed)
return ret;
}
+// tmio.c_iflag |= ;
+ tmio.c_iflag &= ~(INLCR | ICRNL | IGNCR | IXON | IXOFF);
+
+// tmio.c_oflag |= ;
+ tmio.c_oflag &= ~(ONLCR | OCRNL | ONOCR | ONLRET);
+
+ tmio.c_cflag |= CS8 | CLOCAL | CREAD;
+ tmio.c_cflag &= ~(CSTOPB | PARENB);
+
+// tmio.c_lflag |= ;
+ tmio.c_lflag &= ~(ICANON | ECHO);
+
+ tmio.c_cc[VTIME] = 0;
+ tmio.c_cc[VMIN] = 1;
+
ret = cfsetospeed(&tmio, speed);
if(ret) {
log_printf(ERROR, "Error on cfsetospeed(): %s", strerror(errno));
@@ -162,8 +177,6 @@ int setup_tty(int fd, speed_t speed)
return ret;
}
- tmio.c_lflag &= ~ECHO;
-
ret = tcsetattr(fd, TCSANOW, &tmio);
if(ret) {
log_printf(ERROR, "Error on tcsetattr(): %s", strerror(errno));