CANMessage is the primitive CAN message object. It supports creation, parsing, formatting of messages. Can be easily integrated with CANPort and CANQueue libraries.

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Thu Sep 19 21:46:09 2019 +0000
Parent:
1:c56577ae52df
Child:
3:c2a26d9d689b
Commit message:
Eliminate the unnecessary Timer, and clean-up the CANPort to have access to underlying CAN methods.

Changed in this revision

CANMessage.cpp Show annotated file Show diff for this revision Revisions of this file
CANMessage.h Show annotated file Show diff for this revision Revisions of this file
--- a/CANMessage.cpp	Wed Aug 28 22:02:43 2019 +0000
+++ b/CANMessage.cpp	Thu Sep 19 21:46:09 2019 +0000
@@ -24,8 +24,6 @@
 #include "CANMessage.h"
 #include "Utilities.h"      // missing functions...
 
-//#include "FreeRunTimer.h"
-
 static Timer timer;
 static bool timer_on;
 
@@ -56,7 +54,7 @@
         timer.start();
         timer_on = true;
     }
-    timestamp = timer.read_us();
+    timestamp = timer.read_high_resolution_us();
 }
 
 CANmsg::CANmsg(CANCHANNEL_T _ch, CANDIR_T _dir, CANMessage _msg) {
@@ -64,7 +62,7 @@
         timer.start();
         timer_on = true;
     }
-    timestamp = timer.read_us();
+    timestamp = timer.read_high_resolution_us();
     ch = _ch;
     dir = _dir;
     id = _msg.id;
@@ -122,14 +120,14 @@
     token = strtok(NULL, search);
     // lostMessages = atoi(token);
     token = strtok(NULL, search);
-    timestamp = timer.read_us();        // set it to "now"
+    timestamp = timer.read_high_resolution_us();        // set it to "now"
     if (token)
         timestamp = (uint32_t)(1000000 * atof(token));
     return true;
 }
 
 void CANmsg::SetTimestamp() {
-    timestamp = (uint32_t)timer.read_us();
+    timestamp = (uint32_t)timer.read_high_resolution_us();
 }
 
 // 12345678901234567890123456789012345678901234567890123456789012345
--- a/CANMessage.h	Wed Aug 28 22:02:43 2019 +0000
+++ b/CANMessage.h	Thu Sep 19 21:46:09 2019 +0000
@@ -134,8 +134,9 @@
     /// Overrides the timestamp in this message with the current time
     void SetTimestamp();
     
-    /// Gets the timestamp of this message
+    /// Gets the 64-bit timestamp of this message
     /// @returns time in microseconds
+    ///
     uint64_t GetTimestamp() { return timestamp; };
     
     /// direction of this CAN message - rcv or xmt