X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=serial_console%2Fserial.c;h=0e4715a8b4e21e683e20ccd3080626051747484d;hp=47044f3899920977549eaf442998c6c4c5e73b34;hb=a34e51d757fe52cb19de2937ae1b211894167524;hpb=f0911e20b10fe2bfc221dba824f60c185e49a13f diff --git a/serial_console/serial.c b/serial_console/serial.c index 47044f3..0e4715a 100644 --- a/serial_console/serial.c +++ b/serial_console/serial.c @@ -87,8 +87,8 @@ int restore_tty(int fd, struct termios *termios_prev) int ret = tcsetattr(fd, TCSANOW, termios_prev); if(ret) { fprintf(stderr, "Error on tcsetattr(): %s", strerror(errno)); - return ret; } + return ret; } void connect_terminal(int door_fd) @@ -106,7 +106,7 @@ void connect_terminal(int door_fd) { if (FD_ISSET(door_fd,&fds_r)) { - if (num_byte = read(door_fd,buffer, 1) > 0) + if ((num_byte = read(door_fd,buffer, 1)) > 0) { write(STDOUT_FILENO,buffer,num_byte); } @@ -115,7 +115,7 @@ void connect_terminal(int door_fd) } if (FD_ISSET(STDIN_FILENO,&fds_r)) { - while(num_byte = read(STDIN_FILENO,buffer, 256) > 0) + while((num_byte = read(STDIN_FILENO,buffer, 256)) > 0) { write(door_fd,buffer,num_byte); } @@ -134,6 +134,9 @@ int main(int argc, char* argv[]) int door_fd = 0; struct termios tmio_prev; + if (argc > 0) + door_dev_ = argv[1]; + for(;;) { door_fd = open(door_dev_, O_RDWR | O_NONBLOCK); // | O_NOCTTY