changeset 257:9e43076f1433 main

Updates for the more modern platform: 500kHz bus speed, better error handling, remvoe unnecessary code.
author Bob Cook <bob@bobcookdev.com>
date Mon, 07 Sep 2015 20:28:32 -0700
parents d3231309c17e
children 066659214b23
files main/robots/odr-gps/canmsgs.cpp main/robots/odr-gps/main.cpp main/robots/odr-gps/project_defs.h
diffstat 3 files changed, 32 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/main/robots/odr-gps/canmsgs.cpp	Mon Sep 07 20:26:50 2015 -0700
+++ b/main/robots/odr-gps/canmsgs.cpp	Mon Sep 07 20:28:32 2015 -0700
@@ -1,6 +1,6 @@
 // ----------------------------------------------------------------------------------------
 //
-//  Copyright (C) 2013 Bob Cook
+//  Copyright (C) 2013-2015 Bob Cook
 //    
 //  Bob Cook Development, Robotics Library
 //  http://www.bobcookdev.com/rl/
@@ -138,35 +138,38 @@
     uint8_t  recvdata[ 8 ];
     uint8_t  recvlen = sizeof( recvdata );
 
-    if ( ! m1can_read( &recvid, &recvrequest, recvdata, &recvlen ) )
+    for ( ;; )
     {
-        return true; // no messages, everything ok
-    }
+        if ( ! m1can_read( &recvid, &recvrequest, recvdata, &recvlen ) )
+        {
+            return true; // no messages, everything ok
+        }
 
-    uint8_t  srcnode;
-    uint8_t  dstnode;
-    uint16_t dataid;
-    can_parse_message_id( recvid, &srcnode, &dstnode, &dataid );
-
-    if ( dstnode != can_node_broadcast && dstnode != can_node_sensor_gps )
-    {
-        return true; // not for us, everything ok
-    }
+        uint8_t  srcnode;
+        uint8_t  dstnode;
+        uint16_t dataid;
+        can_parse_message_id( recvid, &srcnode, &dstnode, &dataid );
 
-    switch ( dataid )
-    {
-        case can_dataid_emergency:
-            status_got_emergency( srcnode );
-            break;
+        if ( dstnode != can_node_broadcast && dstnode != can_node_sensor_gps )
+        {
+            return true; // not for us, everything ok
+        }
 
-        case can_dataid_all_clear:
-            status_got_all_clear( srcnode );
-            break;
+        switch ( dataid )
+        {
+            case can_dataid_emergency:
+                status_got_emergency( srcnode );
+                break;
 
-        case can_dataid_heartbeat:
-        case can_dataid_odrmgr_update:
-            status_got_heartbeat( srcnode );
-            break;
+            case can_dataid_all_clear:
+                status_got_all_clear( srcnode );
+                break;
+
+            case can_dataid_heartbeat:
+            case can_dataid_odrmgr_update:
+                status_got_heartbeat( srcnode );
+                break;
+        }
     }
 
     return true; // no errors
--- a/main/robots/odr-gps/main.cpp	Mon Sep 07 20:26:50 2015 -0700
+++ b/main/robots/odr-gps/main.cpp	Mon Sep 07 20:28:32 2015 -0700
@@ -1,6 +1,6 @@
 // ----------------------------------------------------------------------------------------
 //
-//  Copyright (C) 2013-2014 Bob Cook
+//  Copyright (C) 2013-2015 Bob Cook
 //    
 //  Bob Cook Development, Robotics Library
 //  http://www.bobcookdev.com/rl/
@@ -316,14 +316,10 @@
             if ( status_is_emergency() )
             {
                 led_red_on();
-                //motorctl_suspend();
-                //servo_suspend();
             }
             else
             {
                 led_red_off();
-                //motorctl_unsuspend();
-                //servo_unsuspend();
             }
         }
 
@@ -354,13 +350,6 @@
         {
             ++can_comm_errors;
         }
-        else
-        {
-            if ( can_comm_errors > 0 )
-            {
-                --can_comm_errors;
-            }
-        }
 
         //--    Report warning and/or error conditions.
 
--- a/main/robots/odr-gps/project_defs.h	Mon Sep 07 20:26:50 2015 -0700
+++ b/main/robots/odr-gps/project_defs.h	Mon Sep 07 20:28:32 2015 -0700
@@ -1,6 +1,6 @@
 // ----------------------------------------------------------------------------------------
 //
-//  Copyright (C) 2013-2014 Bob Cook
+//  Copyright (C) 2013-2015 Bob Cook
 //
 //  Permission is hereby granted, free of charge, to any person obtaining a copy
 //  of this software and associated documentation files (the "Software"), to deal
@@ -34,8 +34,8 @@
 //  packages/avr/can
 
 #define PRJ_M1CAN_ENABLE
-#define PRJ_M1CAN_CANBUS_250_KHZ
-#define PRJ_M1CAN_TX_BUFFER_SIZE  16
+#define PRJ_M1CAN_CANBUS_500_KHZ
+#define PRJ_M1CAN_TX_BUFFER_SIZE  8
 
 // ----------------------------------------------------------------------------------------
 //  packages/avr/device