From e9ebe3fc3c4f6c15fc66b59ffaa9de0c13b3432d Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Thu, 25 Mar 2010 03:19:08 +0000 Subject: [PATCH] grml --- openwrt-packages/usocket/Makefile | 2 +- serial_console/sample_sensors.c | 31 +++++++++++++++++-------------- serial_console/usocket.c | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/openwrt-packages/usocket/Makefile b/openwrt-packages/usocket/Makefile index e6d4699..4bcec8a 100644 --- a/openwrt-packages/usocket/Makefile +++ b/openwrt-packages/usocket/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=usocket -PKG_VERSION:=0.3 +PKG_VERSION:=0.4 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/usocket diff --git a/serial_console/sample_sensors.c b/serial_console/sample_sensors.c index d81daa1..923f274 100644 --- a/serial_console/sample_sensors.c +++ b/serial_console/sample_sensors.c @@ -60,7 +60,7 @@ void sample_sensors(int fd) buffer_offset+=num_byte; } - if (num_byte == 0 || (num_byte <0 && errno != EAGAIN)) + if (num_byte < 1) return; char linebreak_found=0; @@ -135,7 +135,6 @@ int establish_socket_connection(const char* path) int main(int argc, char* argv[]) { - int ret = 0; int socket_fd = 0; char *socket_file; if (argc > 1) @@ -143,19 +142,23 @@ int main(int argc, char* argv[]) else socket_file = default_socket_file_; - socket_fd = establish_socket_connection(socket_file); - if(socket_fd) + while (1) { - sample_sensors(socket_fd); - } - else - { - fprintf(stderr, "%s error, aborting..\n", socket_file); - ret=2; - } + socket_fd = establish_socket_connection(socket_file); + if(socket_fd) + { + sample_sensors(socket_fd); + } + else + { + fprintf(stderr, "%s error, retrying..\n", socket_file); + } - if(socket_fd > 0) - shutdown(socket_fd,SHUT_RDWR); - return(ret); + if(socket_fd > 0) + shutdown(socket_fd,SHUT_RDWR); + + sleep(2); + } + return 0; } diff --git a/serial_console/usocket.c b/serial_console/usocket.c index 52817f2..5c90061 100644 --- a/serial_console/usocket.c +++ b/serial_console/usocket.c @@ -21,7 +21,7 @@ void connect_terminal(int fd) //~ printf("%d:%s\n",num_byte,buffer); write(STDOUT_FILENO,buffer,num_byte); } - if (num_byte == 0 || (num_byte <0 && errno != EAGAIN)) + if (num_byte < 1) return; } if (stdin_valid_fd && FD_ISSET(STDIN_FILENO,&fds_r)) -- 1.7.10.4