From: Christian Pointner Date: Tue, 12 Jul 2011 22:53:32 +0000 (+0000) Subject: fixed ttyread X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=bd1f47a70c33f1a9861feeb363adb9c65f679dfe;p=svn42.git fixed ttyread updated start-dart --- diff --git a/dart/start-dart.sh b/dart/start-dart.sh index 248b32a..b166866 100755 --- a/dart/start-dart.sh +++ b/dart/start-dart.sh @@ -20,8 +20,7 @@ signal_handler() } stty -echo -ssh dart stty -F /dev/ttyDart 57600 -ssh dart cat /dev/ttyDart >$FIFO & +ssh dart ttyread /dev/ttyDart >$FIFO & ./eet $FIFO | ./dart-$mode.pl $* | ../dart-sounds/src/dart-sounds ../dart-sounds/media > /dev/null rm -rf $FIFO_D diff --git a/dart/ttyread.c b/dart/ttyread.c index cd057f7..65a6248 100644 --- a/dart/ttyread.c +++ b/dart/ttyread.c @@ -31,7 +31,7 @@ int setup_tty(int fd) { struct termios tmio; - + int ret = tcgetattr(fd, &tmio); if(ret) { perror("tcgetattr()"); @@ -51,14 +51,21 @@ int setup_tty(int fd) } tmio.c_lflag &= ~ECHO; + tmio.c_lflag &= ~ISIG; tmio.c_lflag |= CLOCAL; + tmio.c_iflag &= ~ICRNL; + tmio.c_iflag &= ~IGNCR; + tmio.c_iflag |= IGNBRK | BRKINT; + + tmio.c_cflag |= CLOCAL; + ret = tcsetattr(fd, TCSANOW, &tmio); if(ret) { perror("tcsetattr()"); return ret; } - + ret = tcflush(fd, TCIFLUSH); if(ret) { perror("tcflush()"); @@ -101,13 +108,19 @@ int main(int argc, char* argv[]) char buf[100]; for(;;) { - int r = read(fd, buf, sizeof(buf)); - if(r <=0 ) return r; - - int i; + ssize_t r = read(fd, buf, sizeof(buf)); + if(r < 0 ) { + perror("read()"); + return r; + } + + ssize_t i; for(i=0; i < r;) { - int w = write(fd, &(buf[i]), r - i); - if(w < 0) return w; + ssize_t w = write(1, &(buf[i]), r - i); + if(w < 0) { + perror("write()"); + return w; + } i+=w; } }