Revision: 7075
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7075&view=rev
Author:   thjc
Date:     2008-10-07 10:42:15 +0000 (Tue, 07 Oct 2008)

Log Message:
-----------
Merging changes from 2-1 to trunk
6987    P2-1            fixed up colour setting in graphics3d example
6989    P2-1            applied [ 2082498 ] fixed Geometry-Request
6990    P2-1            [ 2074625 ] serialstream fix for osx
6991    P2-1            aplpied [ 2046418 ] roomba driver: stall notification
6992    P2-1            applied [ 2016923 ] Error checking and better timeouts 
in SICK LMS200
6993    P2-1            Applied [ 1998688 ] camerav4l patch
6994    P2-1            Applied [ 1957498 ] Fixes for segfaults on the 
InsideM300 RFID driver
6996    P2-1            added headers suggested by [ 2020265 ] gcc 4.3 
compatibility

Modified Paths:
--------------
    code/player/trunk/client_libs/libplayerc++/playerc++.h
    code/player/trunk/examples/libplayerc++/clientgraphics3d.cc
    code/player/trunk/server/drivers/actarray/amtecM5.cc
    code/player/trunk/server/drivers/camera/v4l/camerav4l.cc
    code/player/trunk/server/drivers/laser/lms400_cola.h
    code/player/trunk/server/drivers/laser/sicklms200.cc
    code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc
    code/player/trunk/server/drivers/mixed/mricp/src/geometry2D.cpp
    code/player/trunk/server/drivers/opaque/serialstream.cc
    code/player/trunk/server/drivers/rfid/insideM300.cc

Property Changed:
----------------
    code/player/trunk/


Property changes on: code/player/trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985
/code/player/trunk:6985
   + 
/code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996
/code/player/trunk:6985

Modified: code/player/trunk/client_libs/libplayerc++/playerc++.h
===================================================================
--- code/player/trunk/client_libs/libplayerc++/playerc++.h      2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/client_libs/libplayerc++/playerc++.h      2008-10-07 
10:42:15 UTC (rev 7075)
@@ -53,6 +53,7 @@
 #include <string>
 #include <list>
 #include <vector>
+#include <cstring>
 
 #include "libplayerc/playerc.h"
 #include "libplayerc++/utility.h"

Modified: code/player/trunk/examples/libplayerc++/clientgraphics3d.cc
===================================================================
--- code/player/trunk/examples/libplayerc++/clientgraphics3d.cc 2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/examples/libplayerc++/clientgraphics3d.cc 2008-10-07 
10:42:15 UTC (rev 7075)
@@ -57,7 +57,8 @@
     for( r=3; r>0; r-=0.1 )
       {
        col.blue = (int)(r * 255.0 /3);
-       col.red  = (int)((255.0 - r * 255.0)/3);
+       col.red  = 255 - col.blue;
+       gp.Color( col );
 
        player_point_3d_t pts[4];
        pts[0].px = -r;

Modified: code/player/trunk/server/drivers/actarray/amtecM5.cc
===================================================================
--- code/player/trunk/server/drivers/actarray/amtecM5.cc        2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/actarray/amtecM5.cc        2008-10-07 
10:42:15 UTC (rev 7075)
@@ -600,14 +600,14 @@
                        pclDevice->getConfig(idModuleList[i],&configword);
 
                        uint8_t hasbrakes=0;
-                       if (configword && CONFIGID_MOD_BRAKE_PRESENT) {
+                       if (configword & CONFIGID_MOD_BRAKE_PRESENT) {
                                hasbrakes=1;
                        } else {
                                hasbrakes=0;
                        }
 
                        uint8_t type=0;
-                       if (configword && CONFIGID_MOD_LINEAR) {
+                       if (configword & CONFIGID_MOD_LINEAR) {
                                type=PLAYER_ACTARRAY_TYPE_LINEAR;
                        } else {
                                type=PLAYER_ACTARRAY_TYPE_ROTARY;

Modified: code/player/trunk/server/drivers/camera/v4l/camerav4l.cc
===================================================================
--- code/player/trunk/server/drivers/camera/v4l/camerav4l.cc    2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/camera/v4l/camerav4l.cc    2008-10-07 
10:42:15 UTC (rev 7075)
@@ -174,7 +174,8 @@
 #include <errno.h>
 #include <string.h>
 #include <math.h>
-#include <stdlib.h>       // for atoi(3)
+#include <stddef.h>
+#include <stdlib.h>       // for malloc() and free()
 #include <unistd.h>
 #include <time.h>
 
@@ -220,6 +221,10 @@
   // Pixel depth
   private: int depth;
 
+  // Format
+
+  private: uint32_t format;
+
   // Camera palette
   private: const char *palette;
 
@@ -263,16 +268,13 @@
 
   private: time_t publish_time;
 
-  // Data to send to server
-  private: player_camera_data_t data;
-
 };
 
 
 // Initialization function
 Driver* CameraV4L_Init( ConfigFile* cf, int section)
 {
-  return ((Driver*) (new CameraV4L( cf, section)));
+  return (reinterpret_cast<Driver *>(new CameraV4L( cf, section)));
 }
 
 
@@ -373,28 +375,28 @@
   {
     fg_set_format(this->fg, VIDEO_PALETTE_GREY);
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_GREY );
-    this->data.format = PLAYER_CAMERA_FORMAT_MONO8;
+    this->format = PLAYER_CAMERA_FORMAT_MONO8;
     this->depth = 8;
   }
   else if (strcasecmp(this->palette, "RGB565") == 0)
   {
     fg_set_format(this->fg, VIDEO_PALETTE_RGB565 );
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_RGB565 );
-    this->data.format = PLAYER_CAMERA_FORMAT_RGB565;
+    this->format = PLAYER_CAMERA_FORMAT_RGB565;
     this->depth = 16;
   }
   else if (strcasecmp(this->palette, "RGB888") == 0)
   {
     fg_set_format(this->fg, VIDEO_PALETTE_RGB24 );
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_RGB24 );
-    this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
+    this->format = PLAYER_CAMERA_FORMAT_RGB888;
     this->depth = 24;
   }
   else if (strcasecmp(this->palette, "RGB32") == 0)
   {
     fg_set_format(this->fg, VIDEO_PALETTE_RGB32 );
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_RGB32 );
-    this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
+    this->format = PLAYER_CAMERA_FORMAT_RGB888;
     this->depth = 32;
   }
   else if (strcasecmp(this->palette, "YUV420P") == 0)
@@ -403,25 +405,23 @@
     // 1.6.2 and earlier
     fg_set_format(this->fg, VIDEO_PALETTE_YUV420P);
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_YUV420P );
-    this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
+    this->format = PLAYER_CAMERA_FORMAT_RGB888;
     this->depth = 24;
     this->rgb_converted_frame = frame_new(this->width,
             this->height, VIDEO_PALETTE_RGB24 );
-    //    this->data.format = PLAYER_CAMERA_FORMAT_MONO8;
-    //    this->depth = 8;
   }
   else if (strcasecmp(this->palette, "YUV420P_GREY") == 0)
   {
     fg_set_format(this->fg, VIDEO_PALETTE_YUV420P);
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_YUV420P );
-    this->data.format = PLAYER_CAMERA_FORMAT_MONO8;
+    this->format = PLAYER_CAMERA_FORMAT_MONO8;
     this->depth = 8;
    }
   else if (strcasecmp(this->palette, "JPEG") == 0)
   {
     fg_set_format(this->fg, VIDEO_PALETTE_JPEG );
     this->frame = frame_new(this->width, this->height, VIDEO_PALETTE_JPEG );
-    this->data.format = PLAYER_CAMERA_FORMAT_RGB888;
+    this->format = PLAYER_CAMERA_FORMAT_RGB888;
     this->depth = 24;
   }
   else
@@ -450,7 +450,7 @@
   // Free resources
   frame_release(this->frame);
   if ((this->frame->format == VIDEO_PALETTE_YUV420P)&&
-      (this->data.format == PLAYER_CAMERA_FORMAT_RGB888))
+      (this->format == PLAYER_CAMERA_FORMAT_RGB888))
        frame_release(this->rgb_converted_frame);
   fg_close(this->fg);
   return 0;
@@ -510,7 +510,7 @@
       //printf("click %d\n", frameno);
       snprintf(filename, sizeof(filename), "click-%04d.ppm", frameno++);
       if ((this->frame->format == VIDEO_PALETTE_YUV420P)&&
-         (this->data.format == PLAYER_CAMERA_FORMAT_RGB888))
+         (this->format == PLAYER_CAMERA_FORMAT_RGB888))
           {
                frame_save(this->rgb_converted_frame, filename);
                //printf("saved converted frame\n");
@@ -528,12 +528,12 @@
                               void * data)
 {
   assert(hdr);
-  assert(data);
 
   /* We currently don't support any messages, but if we do...
   if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
                            PLAYER_CAMERA_REQ_GET_GEOM, this->device_addr))
   {
+    assert(data);
     assert(hdr->size == sizeof(player_position2d_data_t));
     ProcessGetGeom(hdr, *reinterpret_cast<player_camera_data_t *> (data));
     return(0);
@@ -544,60 +544,96 @@
   return -1;
 }
 
+#define IS_JPEG(ptr) ((((ptr)[0]) == 0xff) && (((ptr)[1]) == 0xd8))
+
 
////////////////////////////////////////////////////////////////////////////////
 // Update the device data (the data going back to the client).
 void CameraV4L::RefreshData()
 {
   int i;
-  size_t image_count;
   unsigned char * ptr1, * ptr2;
+  player_camera_data_t * data = reinterpret_cast<player_camera_data_t 
*>(malloc(sizeof(player_camera_data_t)));
 
-  // Compute size of image
-  image_count = this->width * this->height * this->depth / 8;
+  if (!data)
+  {
+    PLAYER_ERROR("Out of memory!");
+    return;
+  }
 
   // Set the image properties
-  this->data.width       = this->width;
-  this->data.height      = this->height;
-  this->data.bpp         = this->depth;
-  this->data.image_count = image_count;
-  this->data.image       = new unsigned char [image_count];
-  this->data.compression = PLAYER_CAMERA_COMPRESS_RAW;
+  data->width       = this->width;
+  data->height      = this->height;
+  data->bpp         = this->depth;
+  data->format      = this->format;
+  data->fdiv        = 0;
+  data->image_count = 0;
+  data->image       = NULL;
+  data->compression = PLAYER_CAMERA_COMPRESS_RAW;
 
   if (have_ov519)
   {
-    this->data.image_count = (*(unsigned short *)(frame->data))*8;
-    assert(data.image_count > 0);
-    assert(data.image_count <= ((size_t)(this->frame->size)));
-    this->data.compression = PLAYER_CAMERA_COMPRESS_JPEG;
-    memcpy(data.image, &(((char*)frame->data)[2]), data.image_count);
+    data->image_count = (*(reinterpret_cast<unsigned short *>(frame->data))) * 
8;
+    assert(data->image_count > 0);
+    assert(data->image_count <= static_cast<size_t>(this->frame->size));
+    data->image = reinterpret_cast<uint8_t *>(malloc(data->image_count));
+    if (!(data->image))
+    {
+      PLAYER_ERROR("Out of memory!");
+      free(data);
+      return;
+    }
+    data->compression = PLAYER_CAMERA_COMPRESS_JPEG;
+    memcpy(data->image, &((reinterpret_cast<char *>(frame->data))[2]), 
data->image_count);
   }
   else if (this->fg->picture.palette == VIDEO_PALETTE_JPEG)
   {
-    this->data.compression = PLAYER_CAMERA_COMPRESS_JPEG;
     memcpy(&i, this->frame->data, sizeof(int));
-    data.image_count = i;
-    assert(data.image_count > 0);
-    assert(data.image_count <= ((size_t)(this->frame->size)));
-    memcpy(data.image, ((unsigned char *)(this->frame->data)) + sizeof(int), 
data.image_count);
+    data->image_count = i;
+    assert(data->image_count > 1);
+    assert(data->image_count <= static_cast<size_t>(this->frame->size));
+    if (!(IS_JPEG((reinterpret_cast<unsigned char *>(this->frame->data)) + 
sizeof(int))))
+    {
+      PLAYER_ERROR("Not an JPEG image...");
+      free(data);
+      return;
+    }
+    data->image = reinterpret_cast<uint8_t *>(malloc(data->image_count));
+    if (!(data->image))
+    {
+      PLAYER_ERROR("Out of memory!");
+      free(data);
+      return;
+    }
+    data->compression = PLAYER_CAMERA_COMPRESS_JPEG;
+    memcpy(data->image, (reinterpret_cast<unsigned char *>(this->frame->data)) 
+ sizeof(int), data->image_count);
   }
   else
   {
+    data->image_count = this->width * this->height * this->depth / 8;
+    assert(data->image_count > 0);
+    data->image = reinterpret_cast<uint8_t *>(malloc(data->image_count));
+    if (!(data->image))
+    {
+      PLAYER_ERROR("Out of memory!");
+      free(data);
+      return;
+    }
     // Copy the image pixels
     if ((this->frame->format == VIDEO_PALETTE_YUV420P) &&
-       (this->data.format == PLAYER_CAMERA_FORMAT_RGB888))
+       (this->format == PLAYER_CAMERA_FORMAT_RGB888))
         {// do conversion to RGB (which is bgr at the moment for some reason?)
-             assert(data.image_count <= (size_t) 
this->rgb_converted_frame->size);
+             assert(data->image_count <= 
static_cast<size_t>(this->rgb_converted_frame->size));
              ccvt_420p_bgr24(this->width, this->height,
-                  (unsigned char*) this->frame->data,
-                  (unsigned char*) this->rgb_converted_frame->data);
-             ptr1 = (unsigned char *)this->rgb_converted_frame->data;
+                   reinterpret_cast<unsigned char *>(this->frame->data),
+                   reinterpret_cast<unsigned char 
*>(this->rgb_converted_frame->data));
+              ptr1 = reinterpret_cast<unsigned char 
*>(this->rgb_converted_frame->data);
         }
     else
         {
-             assert(data.image_count <= (size_t) this->frame->size);
-             ptr1 = (unsigned char *)this->frame->data;
+             assert(data->image_count <= 
static_cast<size_t>(this->frame->size));
+             ptr1 = reinterpret_cast<unsigned char *>(this->frame->data);
         }
-    ptr2 = this->data.image;
+    ptr2 = reinterpret_cast<unsigned char *>(data->image);
     switch (this->depth)
     {
     case 24:
@@ -622,7 +658,7 @@
       }
       break;
     default:
-      memcpy(ptr2, ptr1, data.image_count);
+      memcpy(ptr2, ptr1, data->image_count);
     }
   }
 
@@ -630,17 +666,19 @@
   {
     if ((time(NULL) - (this->publish_time)) < (this->publish_interval))
     {
-      this->data.width       = 0;
-      this->data.height      = 0;
-      this->data.bpp         = 0;
-      this->data.image_count = 0;
+      data->width       = 0;
+      data->height      = 0;
+      data->bpp         = 0;
+      data->image_count = 0;
+      free(data->image);
+      data->image       = NULL;
     } else this->publish_time = time(NULL);
   }
 
   Publish(this->device_addr,
           PLAYER_MSGTYPE_DATA, PLAYER_CAMERA_DATA_STATE,
-          reinterpret_cast<void*>(&this->data));
-  delete [] this->data.image;
+          reinterpret_cast<void *>(data), 0, NULL, false);
+  // copy = false, don't dispose anything here!
 
   return;
 }

Modified: code/player/trunk/server/drivers/laser/lms400_cola.h
===================================================================
--- code/player/trunk/server/drivers/laser/lms400_cola.h        2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/laser/lms400_cola.h        2008-10-07 
10:42:15 UTC (rev 7075)
@@ -12,6 +12,7 @@
 #include <vector>
 #include <netinet/in.h>
 #include <libplayercore/player.h>
+#include <iostream>
 
 #define BUF_SIZE 1024
 

Modified: code/player/trunk/server/drivers/laser/sicklms200.cc
===================================================================
--- code/player/trunk/server/drivers/laser/sicklms200.cc        2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/laser/sicklms200.cc        2008-10-07 
10:42:15 UTC (rev 7075)
@@ -1660,43 +1660,6 @@
   if(timeout_header == -1)
     timeout_header = timeout;
 
-  // If the timeout is infinite,
-  // go to blocking io
-  //
-  if (timeout < 0)
-  {
-    //PLAYER_MSG0(2, "using blocking io");
-    int flags = ::fcntl(this->laser_fd, F_GETFL);
-    if (flags < 0)
-    {
-      PLAYER_ERROR("unable to get device flags");
-      return 0;
-    }
-    if (::fcntl(this->laser_fd, F_SETFL, flags & (~O_NONBLOCK)) < 0)
-    {
-      PLAYER_ERROR("unable to set device flags");
-      return 0;
-    }
-  }
-  //
-  // Otherwise, use non-blocking io
-  //
-  else
-  {
-    //PLAYER_MSG0(2, "using non-blocking io");
-    int flags = ::fcntl(this->laser_fd, F_GETFL);
-    if (flags < 0)
-    {
-      PLAYER_ERROR("unable to get device flags");
-      return 0;
-    }
-    if (::fcntl(this->laser_fd, F_SETFL, flags | O_NONBLOCK) < 0)
-    {
-      PLAYER_ERROR("unable to set device flags");
-      return 0;
-    }
-  }
-
   int64_t start_time = GetTime();
   int64_t stop_time = start_time + timeout;
   int64_t stop_time_header = start_time + timeout_header;
@@ -1713,10 +1676,42 @@
   while (true)
   {
     if (timeout >= 0)
-      usleep(1000);
+    {
+      fd_set rfds, efds;
+      FD_ZERO(&rfds);
+      FD_SET(this->laser_fd, &rfds);
+      FD_ZERO(&efds);
+      FD_SET(this->laser_fd, &efds);
+      int64_t delay = stop_time_header - GetTime();
+      if (delay < 0) delay = 0;
+      struct timeval tv;
+      tv.tv_usec = (delay % 1000) * 1000;
+      tv.tv_sec = delay / 1000;
+      int retval = ::select(this->laser_fd + 1, &rfds, 0, &efds, &tv);
+      if (retval < 0)
+      {
+        PLAYER_ERROR("error on select (1)");
+        return 0;
+      }
+      if (!retval)
+      {
+        PLAYER_MSG0(2, "timeout on select (1)");
+        return 0;
+      }
+    }
 
     //printf("reading %d\n", timeout); fflush(stdout);
     bytes = ::read(this->laser_fd, header + sizeof(header) - 1, 1);
+    if (bytes < 0)
+    {
+      PLAYER_ERROR("error on read (1)");
+      return 0;
+    }
+    if (!bytes)
+    {
+      PLAYER_MSG0(2, "eof on read (1)");
+      return 0;
+    }
     //printf("bytes read %d\n", bytes); fflush(stdout);
 
     if (header[0] == STX && header[1] == 0x80)
@@ -1727,12 +1722,6 @@
         break;
     }
     memmove(header, header + 1, sizeof(header) - 1);
-    if (timeout >= 0 && GetTime() >= stop_time_header)
-    {
-      //PLAYER_MSG2(2, "%Ld %Ld", GetTime(), stop_time);
-      PLAYER_MSG0(2, "timeout on read (1)");
-      return 0;
-    }
   }
 
   // Determine data length
@@ -1754,13 +1743,41 @@
   while (bytes < len)
   {
     if (timeout >= 0)
-      usleep(1000);
-    bytes += ::read(this->laser_fd, data + bytes, len - bytes);
-    if (timeout >= 0 && GetTime() >= stop_time)
     {
-      //PLAYER_MSG2(2, "%Ld %Ld", GetTime(), stop_time);
-      RETURN_ERROR(0, "timeout on read (3)");
+      fd_set rfds, efds;
+      FD_ZERO(&rfds);
+      FD_SET(this->laser_fd, &rfds);
+      FD_ZERO(&efds);
+      FD_SET(this->laser_fd, &efds);
+      int64_t delay = stop_time - GetTime();
+      if (delay < 0) delay = 0;
+      struct timeval tv;
+      tv.tv_usec = (delay % 1000) * 1000;
+      tv.tv_sec = delay / 1000;
+      int retval = ::select(this->laser_fd + 1, &rfds, 0, &efds, &tv);
+      if (retval < 0)
+      {
+        PLAYER_ERROR("error on select (3)");
+        return 0;
+      }
+      if (!retval)
+      {
+        PLAYER_MSG0(2, "timeout on select (3)");
+        return 0;
+      }
     }
+    int retval = ::read(this->laser_fd, data + bytes, len - bytes);
+    if (retval < 0)
+    {
+      PLAYER_ERROR("error on read (3)");
+      return 0;
+    }
+    if (!retval)
+    {
+      PLAYER_MSG0(2, "eof on read (3)");
+      return 0;
+    }
+    bytes += retval;
   }
 
   // Read in footer
@@ -1769,13 +1786,41 @@
   while (bytes < 3)
   {
     if (timeout >= 0)
-      usleep(1000);
-    bytes += ::read(this->laser_fd, footer + bytes, 3 - bytes);
-    if (timeout >= 0 && GetTime() >= stop_time)
     {
-      //PLAYER_MSG2(2, "%Ld %Ld", GetTime(), stop_time);
-      RETURN_ERROR(0, "timeout on read (4)");
+      fd_set rfds, efds;
+      FD_ZERO(&rfds);
+      FD_SET(this->laser_fd, &rfds);
+      FD_ZERO(&efds);
+      FD_SET(this->laser_fd, &efds);
+      int64_t delay = stop_time - GetTime();
+      if (delay < 0) delay = 0;
+      struct timeval tv;
+      tv.tv_usec = (delay % 1000) * 1000;
+      tv.tv_sec = delay / 1000;
+      int retval = ::select(this->laser_fd + 1, &rfds, 0, &efds, &tv);
+      if (retval < 0)
+      {
+        PLAYER_ERROR("error on select (4)");
+        return 0;
+      }
+      if (!retval)
+      {
+        PLAYER_MSG0(2, "timeout on select (4)");
+        return 0;
+      }
     }
+    int retval = ::read(this->laser_fd, footer + bytes, 3 - bytes);
+    if (retval < 0)
+    {
+      PLAYER_ERROR("error on read (4)");
+      return 0;
+    }
+    if (!retval)
+    {
+      PLAYER_MSG0(2, "eof on read (4)");
+      return 0;
+    }
+    bytes += retval;
   }
 
   // Construct entire packet

Modified: code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc
===================================================================
--- code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc       
2008-10-07 10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc       
2008-10-07 10:42:15 UTC (rev 7075)
@@ -325,6 +325,7 @@
      posdata.pos.px = this->roomba_dev->ox;
      posdata.pos.py = this->roomba_dev->oy;
      posdata.pos.pa = this->roomba_dev->oa;
+     posdata.stall = static_cast<uint8_t>(this->bumplocked);
 
      this->Publish(this->position_addr,
                    PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE,

Modified: code/player/trunk/server/drivers/mixed/mricp/src/geometry2D.cpp
===================================================================
--- code/player/trunk/server/drivers/mixed/mricp/src/geometry2D.cpp     
2008-10-07 10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/mixed/mricp/src/geometry2D.cpp     
2008-10-07 10:42:15 UTC (rev 7075)
@@ -6,6 +6,7 @@
 #include <cmath>
 #include <cassert>
 #include <stdio.h>
+#include <iostream>
 
 using namespace std;
 

Modified: code/player/trunk/server/drivers/opaque/serialstream.cc
===================================================================
--- code/player/trunk/server/drivers/opaque/serialstream.cc     2008-10-07 
10:27:52 UTC (rev 7074)
+++ code/player/trunk/server/drivers/opaque/serialstream.cc     2008-10-07 
10:42:15 UTC (rev 7075)
@@ -61,6 +61,9 @@
 - buffer_size (integer
   - The size of the buffer to be used when reading, this is the maximum that 
can be read in one read command
   - Default 4096
+ 
+- parity
+ - The parity that you want. Vaid vaules are "none" (default), "even", "odd"
 
 @par Example
 
@@ -390,7 +393,9 @@
   }
 
   // save the current io settings
-  tcgetattr(opaque_fd, &oldtio);
+  if (tcgetattr(opaque_fd, &oldtio) < 0) {
+       PLAYER_WARN("Failed to get old tty attributes");
+  }
 
   // set up new settings
   UpdateFlags();
@@ -416,7 +421,13 @@
        // set up new settings
        struct termios newtio;
        memset(&newtio, 0,sizeof(newtio));
-       newtio.c_cflag = CS8 | CREAD;
+       
+       if(tcgetattr( this->opaque_fd, &newtio ) < 0 )
+               PLAYER_WARN("Failed to get old tty attribltes");
+       
+       newtio.c_cc[VMIN] = 0;
+       newtio.c_cc[VTIME] = 0;
+       newtio.c_cflag = CS8 | CREAD; 
        newtio.c_iflag = INPCK;
        newtio.c_oflag = 0;
        newtio.c_lflag = 0;
@@ -428,8 +439,9 @@
                newtio.c_cflag |= PARENB | PARODD;
        else
                PLAYER_WARN("Invalid parity. Defaulting to none.");
-
-       tcsetattr(opaque_fd, TCSANOW, &newtio);
+       
+       if(tcsetattr(opaque_fd, TCSANOW, &newtio) < 0)
+               PLAYER_ERROR("Failed to set new tty device attributes");
        tcflush(opaque_fd, TCIOFLUSH);
 }
 

Modified: code/player/trunk/server/drivers/rfid/insideM300.cc
===================================================================
--- code/player/trunk/server/drivers/rfid/insideM300.cc 2008-10-07 10:27:52 UTC 
(rev 7074)
+++ code/player/trunk/server/drivers/rfid/insideM300.cc 2008-10-07 10:42:15 UTC 
(rev 7075)
@@ -22,6 +22,7 @@
  Author: Radu Bogdan Rusu
  Date: 25 Jan 2006
  CVS: $Id$
+ Fixes by Alexis Maldonado <maldonad //at// cs.tum.edu>. April/2008.
 */
 
 /** @ingroup drivers */
@@ -225,7 +226,6 @@
 // Destructor.
 InsideM300::~InsideM300()
 {
-       free(Data.tags);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -380,6 +380,14 @@
        tcsetattr (this->fd, TCSANOW, &this->initial_options);
        close (this->fd);
 
+       for (unsigned int i=0; i != allocated_tags; ++i) {
+               delete [] Data.tags[i].guid;
+       }
+       
+       free(Data.tags);
+       Data.tags=NULL;
+       allocated_tags=0;
+       
        PLAYER_MSG0 (1, "> InsideM300 driver shutting down... [done]");
        return (0);
 }
@@ -459,7 +467,7 @@
 // RefreshData function
 void InsideM300::RefreshData ()
 {
-       memset (&this->Data, 0, sizeof (player_rfid_data_t));
+       memset (&this->Data, 0, sizeof (Data));
 
        // Get the time at which we started reading
        // This will be a pretty good estimate of when the phenomena occured
@@ -680,10 +688,12 @@
                                if (this->Data.tags_count >= 
this->allocated_tags)
                                {
                                        this->allocated_tags = 
this->Data.tags_count+1;
-                                       this->Data.tags = 
(player_rfid_tag_t*)realloc(this->Data.tags,sizeof(this->Data.tags[0])*this->allocated_tags);
+                                       this->Data.tags = 
(player_rfid_tag_t*)realloc(this->Data.tags,sizeof(player_rfid_tag_t)*this->allocated_tags);
+                                       
this->Data.tags[this->Data.tags_count].guid_count = 8;
+                                       
this->Data.tags[this->Data.tags_count].guid=new char[8];
+
                                }
                                this->Data.tags[this->Data.tags_count].type = 
chipAnswer[1];
-                               
this->Data.tags[this->Data.tags_count].guid_count = 8;
                                int j;
                                for (j = 0; j < 8; j++)
                                        
this->Data.tags[this->Data.tags_count].guid[j] =
@@ -760,10 +770,11 @@
                        if (this->Data.tags_count >= this->allocated_tags)
                        {
                                this->allocated_tags = this->Data.tags_count+1;
-                               this->Data.tags = 
(player_rfid_tag_t*)realloc(this->Data.tags,sizeof(this->Data.tags[0])*this->allocated_tags);
+                               this->Data.tags = 
(player_rfid_tag_t*)realloc(this->Data.tags,sizeof(player_rfid_tag_t)*this->allocated_tags);
+                               
this->Data.tags[this->Data.tags_count].guid_count = 8;
+                               this->Data.tags[this->Data.tags_count].guid=new 
char[8];
                        }
                        this->Data.tags[this->Data.tags_count].type = 
chipAnswer[1];
-                       this->Data.tags[this->Data.tags_count].guid_count = 8;
                        int j;
                        for (j = 0; j < 8; j++)
                                this->Data.tags[this->Data.tags_count].guid[j] 
= chipAnswer [9-j];


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to