glcddrivers: reworked cSerialPort::Open. now avrctl also compiles.
authorcpresser@rika
Thu, 07 Feb 2008 14:28:07 +0100
changeset 21f1573dd6dace
parent 20 23b8c749e5a0
child 22 80359450002a
glcddrivers: reworked cSerialPort::Open. now avrctl also compiles.
graphlcd-base/glcddrivers/avrctl.c
graphlcd-base/glcddrivers/port.c
graphlcd-base/glcddrivers/port.h
     1.1 --- a/graphlcd-base/glcddrivers/avrctl.c	Thu Feb 07 12:41:15 2008 +0000
     1.2 +++ b/graphlcd-base/glcddrivers/avrctl.c	Thu Feb 07 14:28:07 2008 +0100
     1.3 @@ -109,7 +109,7 @@
     1.4      {
     1.5          return -1;
     1.6      }
     1.7 -//    if (port->Open(config->device.c_str()) != 0)
     1.8 +    if (port->Open(config->device.c_str()) != 0)
     1.9          return -1;
    1.10  
    1.11      *oldConfig = *config;
     2.1 --- a/graphlcd-base/glcddrivers/port.c	Thu Feb 07 12:41:15 2008 +0000
     2.2 +++ b/graphlcd-base/glcddrivers/port.c	Thu Feb 07 14:28:07 2008 +0100
     2.3 @@ -288,16 +288,15 @@
     2.4  
     2.5  int cSerialPort::Open(const char * device, void (*FP)(int))
     2.6  {
     2.7 -    struct termios options;
     2.8      struct sigaction saio;
     2.9  
    2.10 -    fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);
    2.11 -    if (fd == -1)
    2.12 +    if (FP == NULL)
    2.13      {
    2.14          printf("error opening port\n");
    2.15          return -1;
    2.16      }
    2.17  
    2.18 +    Open(device);
    2.19  
    2.20      // install the signal handler before making the device asynchronous/
    2.21      saio.sa_handler = FP;
    2.22 @@ -311,6 +310,20 @@
    2.23      // Make the file descriptor asynchronous 
    2.24      fcntl(fd, F_SETFL, FASYNC | O_NONBLOCK);
    2.25  
    2.26 +    return(0);
    2.27 +}
    2.28 +
    2.29 +int cSerialPort::Open(const char * device)
    2.30 +{
    2.31 +    struct termios options;
    2.32 +
    2.33 +    fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);
    2.34 +    if (fd == -1)
    2.35 +    {
    2.36 +        printf("error opening port\n");
    2.37 +        return -1;
    2.38 +    }
    2.39 +
    2.40      tcgetattr(fd, &options);
    2.41  
    2.42      cfsetispeed(&options, B921600);
     3.1 --- a/graphlcd-base/glcddrivers/port.h	Thu Feb 07 12:41:15 2008 +0000
     3.2 +++ b/graphlcd-base/glcddrivers/port.h	Thu Feb 07 14:28:07 2008 +0100
     3.3 @@ -66,6 +66,7 @@
     3.4      ~cSerialPort();
     3.5  
     3.6      int Open(const char * device, void (*FP)(int));
     3.7 +    int Open(const char * device);
     3.8      int Close();
     3.9  
    3.10      int ReadData(unsigned char * data);