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

Modified Files:
      Tag: release-2-0-patches
        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.71.2.4
retrieving revision 1.71.2.5
diff -C2 -d -r1.71.2.4 -r1.71.2.5
*** writelog.cc 18 Oct 2007 21:18:18 -0000      1.71.2.4
--- writelog.cc 18 Oct 2007 21:25:48 -0000      1.71.2.5
***************
*** 77,80 ****
--- 77,81 ----
  - @ref interface_wifi
  - @ref interface_wsn
+ - @ref interface_opaque
  
  The following interfaces are supported in principle but are currently
***************
*** 209,212 ****
--- 210,216 ----
    private: int WriteLaser(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);
***************
*** 782,785 ****
--- 786,792 ----
        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);
***************
*** 1114,1117 ****
--- 1121,1195 ----
  
  /** @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.40.2.2
retrieving revision 1.40.2.3
diff -C2 -d -r1.40.2.2 -r1.40.2.3
*** readlog.cc  18 Oct 2007 21:18:18 -0000      1.40.2.2
--- readlog.cc  18 Oct 2007 21:25:48 -0000      1.40.2.3
***************
*** 61,64 ****
--- 61,65 ----
  - @ref interface_position2d
  - @ref interface_ptz
+ - @ref interface_opaque
  - @ref interface_sonar
  - @ref interface_wifi
***************
*** 267,270 ****
--- 268,277 ----
                               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,
***************
*** 1106,1109 ****
--- 1113,1119 ----
      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,
***************
*** 1747,1750 ****
--- 1757,1857 ----
  
  ////////////////////////////////////////////////////////////////////////////
+ // 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] = atof(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, NULL, 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] = atof(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, NULL, 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, 


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