SampleSensors in C
[svn42.git] / serial_console / usocket.c
index 01d5090..52817f2 100644 (file)
@@ -1,40 +1,5 @@
 #include "usocket.h"
 
-
-int set_tty_raw(int fd, struct termios *termios_prev)
-{
-  struct termios tmio;
-  
-  int ret = tcgetattr(fd, &tmio);
-  if(ret) {
-    fprintf(stderr, "Error on tcgetattr(): %s\n", strerror(errno));
-    return ret;
-  }
-  
-  memcpy(termios_prev, &tmio,sizeof(struct termios));
-  
-  cfmakeraw(&tmio);
-  
-  ret = tcsetattr(fd, TCSANOW, &tmio);
-  if(ret) {
-    fprintf(stderr, "Error on tcsetattr(): %s\n", strerror(errno));
-    return ret;
-  }  
-  
-  fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
-  
-  return 0;
-}
-
-int restore_tty(int fd, struct termios  *termios_prev)
-{
-  int ret = tcsetattr(fd, TCSANOW, termios_prev);
-  if(ret) {
-    fprintf(stderr, "Error on tcsetattr(): %s\n", strerror(errno));
-  }
-  return ret;
-}
-
 void  connect_terminal(int fd)
 {
   if (fd < 3)
@@ -104,7 +69,7 @@ int establish_socket_connection(const char* path)
   int len = SUN_LEN(&local);
   int ret = connect(fd, (struct sockaddr*) &local, len);
   if(ret) {
-    fprintf(stderr, "unable to bind to '%s': %s\n", local.sun_path, strerror(errno));
+    fprintf(stderr, "unable to connect to '%s': %s\n", local.sun_path, strerror(errno));
     return -1;
   }
   
@@ -117,7 +82,7 @@ int main(int argc, char* argv[])
   int ret = 0;
   int socket_fd = 0;
   char *socket_file;
-  //~ struct termios tmio_prev;
+  
   if (argc > 1)
     socket_file = argv[1];
   else
@@ -131,15 +96,8 @@ int main(int argc, char* argv[])
   socket_fd = establish_socket_connection(socket_file);
   if(socket_fd)
   {
-    //~ ret = set_tty_raw(STDIN_FILENO,&tmio_prev);
-    //~ if (ret)
-      //~ break;
     fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
     connect_terminal(socket_fd);
-      
-    //~ ret = restore_tty(STDIN_FILENO,&tmio_prev);
-    //~ if (ret)
-      //~ break;        
   }
   else
   {