changeset 183:8fb361214b57 main

The sonar (ultrasonic) sensor node sends inch measurements, as uint8_t. Clean up the logging slightly.
author Bob Cook <bob@bobcookdev.com>
date Sat, 09 Feb 2013 14:30:44 -0800
parents 070201175cc6
children 2dc80826778f
files main/robots/cantool/CmdListen.cpp
diffstat 1 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/main/robots/cantool/CmdListen.cpp	Sat Feb 09 14:29:59 2013 -0800
+++ b/main/robots/cantool/CmdListen.cpp	Sat Feb 09 14:30:44 2013 -0800
@@ -35,6 +35,8 @@
 #include <string>
 #include <vector>
 
+#include <Poco/NumberFormatter.h>
+
 #include "Commands.h"
 
 #include "packages/common/can/can_helpers.h"
@@ -71,6 +73,20 @@
 
 // ----------------------------------------------------------------------------------------
 
+static void MsgSonarFrontUpdate( const CANMessage* msg )
+{
+    can_data_sonar_front info;
+    msg->msgData( reinterpret_cast< uint8_t* >( &info ), sizeof( info ) );
+
+    std::cout << "sonar front: " << Poco::NumberFormatter::format0( info.left, 3 )
+        << " " << Poco::NumberFormatter::format0( info.center_left, 3 )
+        << " " << Poco::NumberFormatter::format0( info.center_right, 3 )
+        << " " << Poco::NumberFormatter::format0( info.right, 3 )
+        << std::endl;
+}
+
+// ----------------------------------------------------------------------------------------
+
 void CommandListen( const std::vector< std::string >& args )
 {
     if ( args.size() > 1 )
@@ -83,10 +99,10 @@
 
     for ( ;; )
     {
-        if ( getchar() == 'q' )
-        {
-            return;
-        }
+//        if ( getchar() == 'q' )
+//        {
+//            return;
+//        }
 
         CANMessage* msg = CANMessage::WaitDequeueReceived( 250 ); // 250 ms
 
@@ -107,10 +123,23 @@
                 std::cout << "heartbeat from " << NodeName( srcNode ) << std::endl;
                 break;
 
+            case can_dataid_sonar_front:
+                MsgSonarFrontUpdate( msg );
+                break;
+
+            case can_dataid_sonar_front_enable:
+                std::cout << "sonar front: enable" << std::endl;
+                break;
+
+            case can_dataid_sonar_front_disable:
+                std::cout << "sonar front: disable" << std::endl;
+                break;
+                
             default:
-                std::cout << "message: " << CANMessage::asText( msg ) << std::endl;
+//                std::cout << "message: " << CANMessage::asText( msg ) << std::endl;
                 break;
         }
+
     }
 }