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

Modified Files:
        .cvsignore erratic.cc erratic.h 
Log Message:
applied Toby's patch to replace fixed-size arrays

Index: erratic.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/erratic/erratic.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** erratic.cc  23 Aug 2007 19:58:45 -0000      1.16
--- erratic.cc  1 Nov 2007 22:16:20 -0000       1.17
***************
*** 174,177 ****
--- 174,178 ----
  
  #include "erratic.h"
+ #include <libplayerxdr/playerxdr.h>
  
  #ifdef HAVE_CONFIG_H
***************
*** 211,214 ****
--- 212,216 ----
        memset(&this->power_id, 0, sizeof(player_devaddr_t));
        memset(&this->aio_id, 0, sizeof(player_devaddr_t));
+       memset(&erratic_data, 0, sizeof(erratic_data));
  
        memset(&this->last_position_cmd, 0, 
sizeof(player_position2d_cmd_vel_t));
***************
*** 220,224 ****
        // intialise members
        motor_packet = NULL;
!   mcount = 0;
  
        // Do we create a robot position interface?
--- 222,226 ----
        // intialise members
        motor_packet = NULL;
!       mcount = 0;
  
        // Do we create a robot position interface?
***************
*** 299,302 ****
--- 301,311 ----
  }
  
+ Erratic::~Erratic()
+ {
+       player_aio_data_t_cleanup (&erratic_data.aio);
+       player_ir_data_t_cleanup (&erratic_data.ir);
+       
+ }
+ 
  // Called by player when the driver is asked to connect
  int Erratic::Setup() {
***************
*** 809,820 ****
                        case (reply_e)ain:
                                // This data goes in two places, analog input 
and ir rangers
!                               erratic_data.aio.voltages_count = 
packet.packet[4];
!                               erratic_data.ir.voltages_count = 
RobotParams[this->param_idx]->NumIR;
!                               erratic_data.ir.ranges_count = 
RobotParams[this->param_idx]->NumIR;;
                                unsigned int i_voltage;
                                for (i_voltage = 0; i_voltage < 
erratic_data.aio.voltages_count ;i_voltage++) 
                                        {
-                                               if (i_voltage >= 
PLAYER_AIO_MAX_INPUTS)
-                                                       continue;
                                                
erratic_data.aio.voltages[i_voltage] = (packet.packet[5+i_voltage*2]
                                                                        + 
256*packet.packet[6+i_voltage*2]) * (1.0 / 1024.0) * CPU_VOLTAGE;
--- 818,842 ----
                        case (reply_e)ain:
                                // This data goes in two places, analog input 
and ir rangers
!                               if (erratic_data.aio.voltages_count != 
packet.packet[4])
!                               {
!                                       erratic_data.aio.voltages_count = 
packet.packet[4];
!                                       erratic_data.aio.voltages = new 
float[erratic_data.aio.voltages_count];
!                               }
!                               if (erratic_data.ir.voltages_count-4 != 
RobotParams[this->param_idx]->NumIR)
!                               {
!                                       erratic_data.ir.voltages_count = 
RobotParams[this->param_idx]->NumIR;
!                                       erratic_data.ir.voltages = new 
float[erratic_data.ir.voltages_count+4];
!                               }
!                               else
!                                       erratic_data.ir.voltages_count = 
RobotParams[this->param_idx]->NumIR;
!                                       
!                               if (erratic_data.ir.ranges_count != 
RobotParams[this->param_idx]->NumIR)
!                               {
!                                       erratic_data.ir.ranges_count = 
RobotParams[this->param_idx]->NumIR;
!                                       erratic_data.ir.ranges = new 
float[erratic_data.ir.ranges_count];
!                               }
                                unsigned int i_voltage;
                                for (i_voltage = 0; i_voltage < 
erratic_data.aio.voltages_count ;i_voltage++) 
                                        {
                                                
erratic_data.aio.voltages[i_voltage] = (packet.packet[5+i_voltage*2]
                                                                        + 
256*packet.packet[6+i_voltage*2]) * (1.0 / 1024.0) * CPU_VOLTAGE;
***************
*** 828,833 ****
                                for (int i=0; i < 4; i++) 
                                        {
-                                               if (i_voltage >= 
PLAYER_AIO_MAX_INPUTS)
-                                                       continue;
                                                
erratic_data.aio.voltages[i_voltage+i] = 
                                                        
(packet.packet[5+i_voltage*2] & (0x1 << i+4)) ? 1.0 : 0.0;
--- 850,853 ----
***************
*** 1219,1222 ****
--- 1239,1243 ----
                player_ir_pose_t pose;
                pose.poses_count = RobotParams[param_idx]->NumIR;
+               pose.poses = new player_pose3d_t[pose.poses_count];
                for (uint16_t i = 0; i < pose.poses_count ;i++)
                        pose.poses[i] = RobotParams[param_idx]->IRPose[i];
***************
*** 1225,1229 ****
                              PLAYER_MSGTYPE_RESP_ACK,
                              PLAYER_IR_REQ_POSE,
!                             (void*)&pose, sizeof(pose), NULL);
                return(0);
        }
--- 1246,1251 ----
                              PLAYER_MSGTYPE_RESP_ACK,
                              PLAYER_IR_REQ_POSE,
!                             (void*)&pose);
!               delete [] pose.poses;
                return(0);
        }

Index: erratic.h
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/erratic/erratic.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** erratic.h   23 Aug 2007 19:58:45 -0000      1.9
--- erratic.h   1 Nov 2007 22:16:20 -0000       1.10
***************
*** 221,224 ****
--- 221,225 ----
  
    Erratic(ConfigFile* cf, int section);
+   virtual ~Erratic();
  
    virtual int Subscribe(player_devaddr_t id);

Index: .cvsignore
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/erratic/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** .cvsignore  17 Sep 2007 02:18:52 -0000      1.2
--- .cvsignore  1 Nov 2007 22:16:20 -0000       1.3
***************
*** 3,4 ****
--- 3,6 ----
  .deps
  *.la
+ .libs
+ *.lo


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to