changeset 262:19ac16c0ea47 main

Latest code implemented at Robothon.
author Bob Cook <bob@bobcookdev.com>
date Tue, 13 Oct 2015 19:18:48 -0700
parents 71ff00c4bae6
children 51f23203883c
files main/robots/odr-monitor/canmsgs.cpp main/robots/odr-monitor/func.h main/robots/odr-monitor/main.cpp main/robots/odr-monitor/status.cpp
diffstat 4 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/main/robots/odr-monitor/canmsgs.cpp	Tue Oct 13 19:17:59 2015 -0700
+++ b/main/robots/odr-monitor/canmsgs.cpp	Tue Oct 13 19:18:48 2015 -0700
@@ -73,6 +73,15 @@
 
 // ----------------------------------------------------------------------------------------
 
+bool canmsg_send_estop_off()
+{
+    return m1can_send( can_build_message_id( can_node_odr_monitor,
+                                             can_node_broadcast,
+                                             can_dataid_estop_off ), 0, 0 );
+}
+
+// ----------------------------------------------------------------------------------------
+
 bool canmsg_send_heartbeat()
 {
     return m1can_send( can_build_message_id( can_node_odr_monitor,
--- a/main/robots/odr-monitor/func.h	Tue Oct 13 19:17:59 2015 -0700
+++ b/main/robots/odr-monitor/func.h	Tue Oct 13 19:18:48 2015 -0700
@@ -45,6 +45,7 @@
 void status_got_rf_message( const uint8_t* data, uint8_t length );
 
 bool status_is_emergency();
+bool status_is_estop();
 
 // ----------------------------------------------------------------------------------------
 
@@ -53,6 +54,7 @@
 
 bool canmsg_send_emergency();
 bool canmsg_send_all_clear();
+bool canmsg_send_estop_off();
 bool canmsg_send_heartbeat();
 
 bool canmsg_process_pending();
--- a/main/robots/odr-monitor/main.cpp	Tue Oct 13 19:17:59 2015 -0700
+++ b/main/robots/odr-monitor/main.cpp	Tue Oct 13 19:18:48 2015 -0700
@@ -328,10 +328,19 @@
 
             if ( rfcomm_rx_read( incoming, &length ) )
             {
+                led_green_2_toggle();
                 status_got_rf_message( incoming, length );
-                led_green_2_toggle();
+
+                if ( ! canmsg_send_estop_off() )
+                {
+                    ++can_comm_errors;
+                }
             }
         }
+        else  if ( status_is_estop() )
+        {
+            led_green_2_off();
+        }
 
         //--    Any pending CAN messages to receive/process?
 
--- a/main/robots/odr-monitor/status.cpp	Tue Oct 13 19:17:59 2015 -0700
+++ b/main/robots/odr-monitor/status.cpp	Tue Oct 13 19:18:48 2015 -0700
@@ -88,6 +88,7 @@
 void status_got_rf_message( const uint8_t* data, uint8_t length )
 {
     g_beats_without_estop = 0;
+    g_status_flags &= ~status_flag_estop_triggered;
 }
 
 // ----------------------------------------------------------------------------------------
@@ -118,20 +119,27 @@
 
 bool status_is_emergency()
 {
+    // more than one second == ESTOP
+    if ( g_beats_without_estop > 2 )
+    {
+        g_status_flags |= status_flag_estop_triggered;
+    }
+
     // more than two seconds == down
     if ( g_beats_without_mgr > 5 )
     {
         return true;
     }
 
-    // more than one second == ESTOP
-    if ( g_beats_without_estop > 2 )
-    {
-        return true;
-    }
-
     return ( g_status_flags & status_flag_emergency_active ) > 0;
 }
 
 // ----------------------------------------------------------------------------------------
 
+bool status_is_estop()
+{
+    return ( g_status_flags & status_flag_estop_triggered ) > 0;
+}
+
+// ----------------------------------------------------------------------------------------
+