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:
2:c724ff3a4e4d
Child:
3:12b3c25bdeba
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/Node.h	Wed Dec 30 13:33:41 2015 +0000
@@ -0,0 +1,178 @@
+/**
+ ******************************************************************************
+ * @file
+ * @author  Paul Paterson
+ * @version
+ * @date    2015-12-14
+ * @brief   CANOpen implementation library
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2015 Paul Paterson
+ *
+ * All rights reserved.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PPCAN_NODE_H
+#define PPCAN_NODE_H
+
+#include "canopen_protocol.h"
+
+namespace ppCANOpen
+{
+
+/* Avoid circular reference */
+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);    
+    
+    /* ========================================================================
+     * Methods to message indication and confirmation
+     * Called by a ServiceProvider when a message is received.
+     * ========================================================================
+     */
+    
+    /* PDO (7.2.2), MPDO (7.2.3) --------------------------------------------*/
+    
+    int ConsumePdo (int pdoNum, char * dataIn);
+    int HandlePdoReadRequest (int pdoNum);
+    
+    
+    /* SDO (7.2.4) ----------------------------------------------------------*/
+    
+    int HandleExpeditedDownload (int sdoNum, int index, int subIndex, int dataCount, char * data);
+    int HandleInitiateDownloadRequest (int sdoNum, int index, int subIndex, int dataCount, char * data);
+    
+    int HandleExpeditedUpload (int sdoNum, int index, int subIndex);
+    
+    
+    // TODO: express and not express
+    
+    /* SYNC object (7.2.5) --------------------------------------------------*/
+    
+    // TODO: SYNC consumer 
+    
+    /* Time Stamp object (7.2.6) --------------------------------------------*/
+    
+    // TODO: time consumer
+    
+    /* Emergency object (7.2.7) ---------------------------------------------*/
+    
+    int ConsumeEmergency (void);// TODO: fix params
+    
+    
+    /* Network Management (7.2.8) -------------------------------------------*/
+    /* ---- Node Control (7.2.8.2.1) ----------------------------------------*/
+    
+    int HandleNodeControl (void);
+
+
+    /* ---- Error Control (7.2.8.2.2) ---------------------------------------*/
+    
+    int HandleNodeGuardRequest (int masterId);
+    int ConsumeHeartbeat (int producerId);
+    
+    
+    /* ========================================================================
+     * Methods to handle operation of node device
+     * ========================================================================
+     */
+    
+    /**
+     *  @note
+     */
+    // TODO: pass elapsed time to Update method
+    virtual void Update (void);
+    
+    
+    /* ========================================================================
+     * Public members
+     * ========================================================================
+     */
+     
+    /** Network id for the node
+      * @note May need to be a pointer, because node id is held in object dictionary
+      */
+    int nodeId;
+    
+    /** 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:    
+    
+};
+
+} /* namespace ppCANOpen */
+
+#endif // PPCAN_NODE_H
+