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

Modified Files:
        readlog.cc writelog.cc 
Log Message:
applied patch 1771458

Index: writelog.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/server/drivers/shell/writelog.cc,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** writelog.cc 18 Oct 2007 21:14:18 -0000      1.84
--- writelog.cc 18 Oct 2007 21:31:20 -0000      1.85
***************
*** 76,79 ****
--- 76,80 ----
  - @ref interface_wifi
  - @ref interface_wsn
+ - @ref interface_opaque
  - @ref interface_imu
  - @ref interface_pointcloud3d
***************
*** 213,216 ****
--- 214,220 ----
    private: int WriteLocalize(player_msghdr_t* hdr, void *data);
  
+   // Write opaque data to file
+   private: int WriteOpaque(player_msghdr_t* hdr, void *data);
+ 
    // Write position data to file
    private: int WritePosition(player_msghdr_t* hdr, void *data);
***************
*** 808,811 ****
--- 812,818 ----
        retval = this->WritePTZ(hdr, data);
        break;
+     case PLAYER_OPAQUE_CODE:
+       retval = this->WriteOpaque(hdr, data);
+       break;
      case PLAYER_SONAR_CODE:
        retval = this->WriteSonar(hdr, data);
***************
*** 1245,1248 ****
--- 1252,1326 ----
  
  /** @ingroup tutorial_datalog
+  @defgroup player_driver_writelog_opaque opaque format
+ 
+  * @defgroup player_driver_writelog_position aio format
+ 
+ @brief opaque log format
+ 
+ The following type:subtype opaque messages can be logged:
+ - 1:1 (PLAYER_OPAQUE_DATA_STATE) Data information.  The format is:
+   - data_count (uint32_t): Number of valid bytes to follow
+   - list of bytes; for each byte:
+     - data uint8_t: 
+ 
+ - 2:2 (PLAYER_OPAQUE_CMD) Command information. The format is:
+   - data_count (uint32_t): Number of valid bytes to follow
+   - list of bytes; for each byte:
+     - data uint8_t:
+  */
+ int
+ WriteLog::WriteOpaque (player_msghdr_t* hdr, void *data)
+ {
+   // Check the type
+   switch(hdr->type)
+   {
+     case PLAYER_MSGTYPE_DATA:
+       printf("Data State:\n");
+       // Check the subtype
+       switch(hdr->subtype)
+       {
+         case PLAYER_OPAQUE_DATA_STATE:
+           {
+             player_opaque_data_t* odata =
+                     (player_opaque_data_t*)data;
+             fprintf(this->file, "%04d ", odata->data_count);
+ 
+             for (unsigned int i = 0; i < odata->data_count; i++)
+             {
+                fprintf(this->file, "%03d ", odata->data[i]);
+             }
+ 
+             return(0);
+           }
+         default:
+           return(-1);
+       }
+     case PLAYER_MSGTYPE_CMD:
+       printf("Data Command: \n");
+       // Check the subtype
+       switch(hdr->subtype)
+       {
+         case PLAYER_OPAQUE_CMD:
+           {
+             player_opaque_data_t* odata =
+                     (player_opaque_data_t*)data;
+             fprintf(this->file, "%04d ", odata->data_count);
+ 
+             for (unsigned int i = 0; i < odata->data_count; i++)
+             {
+                fprintf(this->file, "%03d ", odata->data[i]);
+             }
+ 
+             return(0);
+           }
+         default:
+           return(-1);
+       }
+     default:
+       return(-1);
+   }
+ }
+ 
+ /** @ingroup tutorial_datalog
   @defgroup player_driver_writelog_sonar sonar format
  

Index: readlog.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/server/drivers/shell/readlog.cc,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** readlog.cc  21 Sep 2007 03:31:50 -0000      1.53
--- readlog.cc  18 Oct 2007 21:31:20 -0000      1.54
***************
*** 64,67 ****
--- 64,68 ----
  - @ref interface_imu
  - @ref interface_pointcloud3d
+ - @ref interface_opaque
  - @ref interface_ptz
  - @ref interface_actarray
***************
*** 274,277 ****
--- 275,284 ----
                               int token_count, char **tokens, double time);
  
+   // Parse opaque data
+   private: int ParseOpaque(player_devaddr_t id,
+                              unsigned short type, unsigned short subtype,
+                              int linenum,
+                              int token_count, char **tokens, double time);
+ 
    // Parse wifi data
    private: int ParseWifi(player_devaddr_t id,
***************
*** 1206,1209 ****
--- 1213,1219 ----
      return this->ParsePosition(id, type, subtype, linenum,
                                 token_count, tokens, time);
+   else if (id.interf == PLAYER_OPAQUE_CODE)
+     return this->ParseOpaque(id, type, subtype, linenum,
+                                token_count, tokens, time);
    else if (id.interf == PLAYER_WIFI_CODE)
      return this->ParseWifi(id, type, subtype, linenum,
***************
*** 1924,1927 ****
--- 1934,2034 ----
  
  ////////////////////////////////////////////////////////////////////////////
+ // Parse opaque data
+ int ReadLog::ParseOpaque(player_devaddr_t id,
+                         unsigned short type, unsigned short subtype,
+                         int linenum,
+                         int token_count, char **tokens, double time)
+ {
+   int i, count;
+ 
+   switch(type)
+   {
+     case PLAYER_MSGTYPE_DATA:
+       switch(subtype)
+       {
+         case PLAYER_OPAQUE_DATA_STATE:
+           {
+             player_opaque_data_t data;
+ 
+             if (token_count < 8)
+             {
+               PLAYER_ERROR2("incomplete line at %s:%d",
+                             this->filename, linenum);
+               return -1;
+             }
+ 
+             data.data_count = atoi(tokens[7]);
+ 
+             count = 0;
+             for (i = 8; i < token_count; i++)
+             {
+               data.data[count] = atoi(tokens[i]);
+               count++;
+             }
+ 
+             if (count != (int)data.data_count)
+             {
+               PLAYER_ERROR2("data count mismatch at %s:%d",
+                             this->filename, linenum);
+               return -1;
+            }
+             this->Publish(id,  type, subtype,
+                           (void*)&data, sizeof(data), &time);
+             return(0);
+           }
+ 
+         default:
+           PLAYER_ERROR1("unknown opaque data subtype %d\n", subtype);
+           return(-1);
+       }
+       break;
+ 
+     case PLAYER_MSGTYPE_CMD:
+       switch(subtype)
+       {
+         case PLAYER_OPAQUE_CMD:
+           {
+             player_opaque_data_t data;
+ 
+             if (token_count < 8)
+             {
+               PLAYER_ERROR2("incomplete line at %s:%d",
+                             this->filename, linenum);
+               return -1;
+             }
+ 
+             data.data_count = atoi(tokens[7]);
+ 
+             count = 0;
+             for (i = 8; i < token_count; i++)
+             {
+               data.data[count] = atoi(tokens[i]);
+               count++;
+             }
+ 
+             if (count != (int)data.data_count)
+             {
+               PLAYER_ERROR2("data count mismatch at %s:%d",
+                             this->filename, linenum);
+               return -1;
+            }
+             this->Publish(id,  type, subtype,
+                           (void*)&data, sizeof(data), &time);
+             return(0);
+           }
+ 
+         default:
+           PLAYER_ERROR1("unknown opaque data subtype %d\n", subtype);
+           return(-1);
+       }
+       break;
+ 
+     default:
+       PLAYER_ERROR1("unknown opaque msg type %d\n", type);
+       return(-1);
+   }
+ }
+ 
+ ////////////////////////////////////////////////////////////////////////////
  // Parse wifi data
  int ReadLog::ParseWifi(player_devaddr_t id,
***************
*** 2182,2185 ****
--- 2289,2293 ----
                    {
                        player_pointcloud3d_element_t element;
+                         
memset(&element,0,sizeof(player_pointcloud3d_element_t));
                        player_point_3d_t point;
                        point.px = atof (tokens[8+i*3]);


-------------------------------------------------------------------------
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