Update of /cvsroot/playerstage/code/player/server/drivers/opaque
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24692/server/drivers/opaque

Modified Files:
        serialstream.cc 
Log Message:
fixed provides parsing in driver examples
serial stream fixes
added mapping capability to nav200 driver, and other bug fixes
added vectormap to playerprop utility


Index: serialstream.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/opaque/serialstream.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** serialstream.cc     7 Dec 2007 02:15:21 -0000       1.3
--- serialstream.cc     14 Dec 2007 00:19:55 -0000      1.4
***************
*** 120,123 ****
--- 120,124 ----
  #define DEFAULT_OPAQUE_PORT "/dev/ttyS0"
  #define DEFAULT_OPAQUE_TRANSFER_RATE 38400
+ #define DEFAULT_OPAQUE_PARITY "none"
  
  
////////////////////////////////////////////////////////////////////////////////
***************
*** 168,171 ****
--- 169,176 ----
      virtual int CloseTerm();
      
+     // Set the io flags.
+     // Just a little helper function that sets the parity and so on.
+     void UpdateFlags();
+     
      // Set the terminal speed
      // Valid values are 9600, 19200, 38400, 115200
***************
*** 190,194 ****
      // Properties
      IntProperty buffer_size, transfer_rate;
!     StringProperty port;
      
      // This is the data we store and send
--- 195,199 ----
      // Properties
      IntProperty buffer_size, transfer_rate;
!     StringProperty port, parity;
      
      // This is the data we store and send
***************
*** 223,231 ****
      : Driver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN,
               PLAYER_OPAQUE_CODE),
!              buffer_size ("buffer_size", DEFAULT_OPAQUE_BUFFER_SIZE, 0), port 
("port", DEFAULT_OPAQUE_PORT, 0), transfer_rate ("transfer_rate", 
DEFAULT_OPAQUE_TRANSFER_RATE, 0)
  {
          this->RegisterProperty ("buffer_size", &this->buffer_size, cf, 
section);
          this->RegisterProperty ("port", &this->port, cf, section);
          this->RegisterProperty ("transfer_rate", &this->transfer_rate, cf, 
section);
        
          rx_buffer = new uint8_t[buffer_size];
--- 228,240 ----
      : Driver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN,
               PLAYER_OPAQUE_CODE),
!              buffer_size ("buffer_size", DEFAULT_OPAQUE_BUFFER_SIZE, 0),
!              transfer_rate ("transfer_rate", DEFAULT_OPAQUE_TRANSFER_RATE, 0),
!              port ("port", DEFAULT_OPAQUE_PORT, 0),
!              parity ("parity", DEFAULT_OPAQUE_PARITY, 0)
  {
          this->RegisterProperty ("buffer_size", &this->buffer_size, cf, 
section);
          this->RegisterProperty ("port", &this->port, cf, section);
          this->RegisterProperty ("transfer_rate", &this->transfer_rate, cf, 
section);
+         this->RegisterProperty ("parity", &this->parity, cf, section);
        
          rx_buffer = new uint8_t[buffer_size];
***************
*** 289,293 ****
            player_intprop_req_t req = *reinterpret_cast<player_intprop_req_t*> 
(data);
            PLAYER_MSG1(2, "%s", req.key);
!           if (strcmp("transfer_rate", req.key))
            {
                res = ChangeTermSpeed(req.value);           
--- 298,302 ----
            player_intprop_req_t req = *reinterpret_cast<player_intprop_req_t*> 
(data);
            PLAYER_MSG1(2, "%s", req.key);
!           if (strcmp("transfer_rate", req.key) == 0)
            {
                res = ChangeTermSpeed(req.value);           
***************
*** 306,309 ****
--- 315,329 ----
            }
        }
+       else if (Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, 
PLAYER_SET_STRPROP_REQ, this->device_addr))
+       {
+           player_strprop_req_t req = *reinterpret_cast<player_strprop_req_t*> 
(data);
+           PLAYER_MSG1(2, "%s", req.key);
+               if (strcmp("parity", req.key) == 0)
+           {
+               parity.SetValueFromMessage(reinterpret_cast<void*> (&req));
+               UpdateFlags();
+               return 0;
+           }
+       }
        //else if it is a opaque data message then I want to flush the current 
serial port and write to whatever is connected to the serial port
        else if (Message::MatchMessage (hdr, PLAYER_MSGTYPE_CMD, 
PLAYER_OPAQUE_CMD_DATA, this->device_addr))
***************
*** 382,394 ****
    
    // set up new settings
!   struct termios newtio;
!   memset(&newtio, 0,sizeof(newtio));
!   newtio.c_cflag = CS8 | CREAD | PARENB;
!   newtio.c_iflag = INPCK;
!   newtio.c_oflag = 0;
!   newtio.c_lflag = 0;
!   
!   tcsetattr(opaque_fd, TCSANOW, &newtio);
!   tcflush(opaque_fd, TCIOFLUSH);
    if (ChangeTermSpeed(transfer_rate))
            return -1;
--- 402,406 ----
    
    // set up new settings
!   UpdateFlags();
    if (ChangeTermSpeed(transfer_rate))
            return -1;
***************
*** 402,405 ****
--- 414,442 ----
  }
  
+ 
////////////////////////////////////////////////////////////////////////////////
+ // Update io flags
+ // Parity is set to whatever the parity property contains.
+ //
+ void SerialStream::UpdateFlags()
+ {
+       // set up new settings
+       struct termios newtio;
+       memset(&newtio, 0,sizeof(newtio));
+       newtio.c_cflag = CS8 | CREAD;
+       newtio.c_iflag = INPCK;
+       newtio.c_oflag = 0;
+       newtio.c_lflag = 0;
+       if (strncmp(parity, "none", 4) == 0)
+               ; // Do nothing.
+       else if (strncmp(parity, "even", 4) == 0)
+               newtio.c_cflag |= PARENB;
+       else if (strncmp(parity, "odd", 3) == 0)
+               newtio.c_cflag |= PARENB | PARODD;
+       else
+               PLAYER_WARN("Invalid parity. Defaulting to none.");
+       
+       tcsetattr(opaque_fd, TCSANOW, &newtio);
+       tcflush(opaque_fd, TCIOFLUSH);
+ }
  
  
////////////////////////////////////////////////////////////////////////////////


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to