library for C++ CANOpen implementation. mbed independant, but is easy to attach into with mbed.

Dependents:   ppCANOpen_Example DISCO-F746NG_rtos_test

Example:

Import programppCANOpen_Example

I am no longer actively working on the ppCANOpen library, however, I want to publish this project so that anyone who wants to pick up any of the pieces can have a good example. This is a a project I was working on using the ppCANOpen library. It has a pretty in deep use of the object dictionary structure. And a number of functions to control high voltage pinball drivers, if you're into that sort of thing.

Revision:
3:12b3c25bdeba
Parent:
2:c724ff3a4e4d
Child:
4:2034b04c86d2
--- a/include/Node.h	Wed Dec 30 13:33:41 2015 +0000
+++ b/include/Node.h	Mon Jan 04 06:10:49 2016 +0000
@@ -38,27 +38,50 @@
 class ServiceProvider;
 class ObjectDictionary;
 
-/** Maintain the multitude of states for a node */
-typedef struct {
-    NmtState nmtState;
-    int csBoot_Up;
-    int csSDO;
-    int csEmergency;
-    int csSYNC;
-    int csLifeGuard;
-    int csPDO;
-    int csLSS;
-} NodeState;
-
 /** Node Class to implement feature of a CANOpen NMT node
  */
 class Node
 {
 public:
-    Node (void);    
+
+    /** Maintain the multitude of states for a node */
+    typedef struct {
+        NmtState nmtState;
+        int bBoot;
+        int bSDO;
+        int bEmergency;
+        int bSYNC;
+        int bLifeGuard;
+        int bPDO;
+        int bLSS;
+    } State;
+
+    Node (ServiceProvider * provider);    
+
+    /* ========================================================================
+     * Methods to handle operation of node device
+     * ========================================================================
+     */
+    
+    // TODO: pass elapsed time to Update method
+    virtual void Update (void);
     
     /* ========================================================================
-     * Methods to message indication and confirmation
+     * Message indication
+     * Called by a ServiceProvider when a message is received.
+     * ========================================================================
+     */
+     
+    /**
+      * @note
+      */
+     int DispatchMessage(CanOpenMessage *canOpenMsg);
+
+
+protected:
+
+    /* ========================================================================
+     * Methods to handle various messages
      * Called by a ServiceProvider when a message is received.
      * ========================================================================
      */
@@ -94,8 +117,7 @@
     
     /* Network Management (7.2.8) -------------------------------------------*/
     /* ---- Node Control (7.2.8.2.1) ----------------------------------------*/
-    
-    int HandleNodeControl (void);
+    int HandleNodeControl (int commandSpecifier);
 
 
     /* ---- Error Control (7.2.8.2.2) ---------------------------------------*/
@@ -105,19 +127,49 @@
     
     
     /* ========================================================================
-     * Methods to handle operation of node device
+     * Methods to implement node control in derived classes
      * ========================================================================
      */
+     
+     /** Perform actions every cycle
+      * @note Override to implement user application
+      */
+     virtual void OnUpdate(void) = 0;
     
-    /**
-     *  @note
-     */
-    // TODO: pass elapsed time to Update method
-    virtual void Update (void);
+    /** Perform actions when node reset
+      * @note Override to implement user application
+      */
+    virtual void OnInitialize (void) = 0;
+    
+    /** Perform actions when state changed to pre-operational
+      * @note Override to implement user application
+      */
+    virtual void OnPreoperational (void) = 0;
     
+    /** Perform actions when state changed to operational
+      * @note Override to implement user application
+      */
+    virtual void OnOperational (void) = 0;
+    
+    /** Perform actions when state changed to stop
+      * @note Override to implement user application
+      */
+    virtual void OnStopped (void) = 0;
     
     /* ========================================================================
-     * Public members
+     * Protected Members
+     * ========================================================================
+     */
+
+    ServiceProvider * pMyProvider;
+
+    /** object dictionary */
+    ObjectDictionary * pMyDictionary;
+
+private:
+
+    /* ========================================================================
+     * Private members
      * ========================================================================
      */
      
@@ -129,47 +181,7 @@
     /** Network and communication state of the node
       * @note
       */
-    NodeState state; 
-
-
-protected:
-    
-    /* ========================================================================
-     * Methods to implement node control in derived classes
-     * ========================================================================
-     */
-    
-    /** Perform actions when node reset
-      * @note Override to implement user application
-      */
-    virtual void OnInitialize (void);
-    
-    /** Perform actions when state changed to pre-operational
-      * @note Override to implement user application
-      */
-    virtual void OnPreoperational (void);
-    
-    /** Perform actions when state changed to operational
-      * @note Override to implement user application
-      */
-    virtual void OnOperational (void);
-    
-    /** Perform actions when state changed to stop
-      * @note Override to implement user application
-      */
-    virtual void OnStopped (void);
-    
-    
-    /* ========================================================================
-     * Object Dictionary
-     * ========================================================================
-     */
-
-    /** object dictionary */
-    ObjectDictionary * pDictionary;
-
-private:    
-    
+    State state;     
 };
 
 } /* namespace ppCANOpen */