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.
include/ServiceProvider.h@4:2034b04c86d2, 2016-01-09 (annotated)
- Committer:
- ptpaterson
- Date:
- Sat Jan 09 17:15:29 2016 +0000
- Revision:
- 4:2034b04c86d2
- Parent:
- 3:12b3c25bdeba
- Child:
- 5:22a337cdc0e3
echo ability
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ptpaterson | 2:c724ff3a4e4d | 1 | /** |
ptpaterson | 2:c724ff3a4e4d | 2 | ****************************************************************************** |
ptpaterson | 2:c724ff3a4e4d | 3 | * @file |
ptpaterson | 2:c724ff3a4e4d | 4 | * @author Paul Paterson |
ptpaterson | 2:c724ff3a4e4d | 5 | * @version |
ptpaterson | 2:c724ff3a4e4d | 6 | * @date 2015-12-22 |
ptpaterson | 2:c724ff3a4e4d | 7 | * @brief CANOpen implementation library |
ptpaterson | 2:c724ff3a4e4d | 8 | ****************************************************************************** |
ptpaterson | 2:c724ff3a4e4d | 9 | * @attention |
ptpaterson | 2:c724ff3a4e4d | 10 | * |
ptpaterson | 2:c724ff3a4e4d | 11 | * <h2><center>© COPYRIGHT(c) 2015 Paul Paterson |
ptpaterson | 2:c724ff3a4e4d | 12 | * |
ptpaterson | 2:c724ff3a4e4d | 13 | * All rights reserved. |
ptpaterson | 2:c724ff3a4e4d | 14 | |
ptpaterson | 2:c724ff3a4e4d | 15 | This program is free software: you can redistribute it and/or modify |
ptpaterson | 2:c724ff3a4e4d | 16 | it under the terms of the GNU General Public License as published by |
ptpaterson | 2:c724ff3a4e4d | 17 | the Free Software Foundation, either version 3 of the License, or |
ptpaterson | 2:c724ff3a4e4d | 18 | (at your option) any later version. |
ptpaterson | 2:c724ff3a4e4d | 19 | |
ptpaterson | 2:c724ff3a4e4d | 20 | This program is distributed in the hope that it will be useful, |
ptpaterson | 2:c724ff3a4e4d | 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
ptpaterson | 2:c724ff3a4e4d | 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ptpaterson | 2:c724ff3a4e4d | 23 | GNU General Public License for more details. |
ptpaterson | 2:c724ff3a4e4d | 24 | |
ptpaterson | 2:c724ff3a4e4d | 25 | You should have received a copy of the GNU General Public License |
ptpaterson | 2:c724ff3a4e4d | 26 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
ptpaterson | 2:c724ff3a4e4d | 27 | */ |
ptpaterson | 2:c724ff3a4e4d | 28 | |
ptpaterson | 2:c724ff3a4e4d | 29 | #ifndef PPCAN_SERVICE_PROVIDER_H |
ptpaterson | 2:c724ff3a4e4d | 30 | #define PPCAN_SERVICE_PROVIDER_H |
ptpaterson | 2:c724ff3a4e4d | 31 | |
ptpaterson | 4:2034b04c86d2 | 32 | #include "CanOpenMessage.h" |
ptpaterson | 4:2034b04c86d2 | 33 | #include <queue> |
ptpaterson | 4:2034b04c86d2 | 34 | |
ptpaterson | 4:2034b04c86d2 | 35 | /*========================================================================= |
ptpaterson | 4:2034b04c86d2 | 36 | * Forward declarations |
ptpaterson | 4:2034b04c86d2 | 37 | *========================================================================= |
ptpaterson | 4:2034b04c86d2 | 38 | */ |
ptpaterson | 4:2034b04c86d2 | 39 | |
ptpaterson | 4:2034b04c86d2 | 40 | struct CanOpenHandle; |
ptpaterson | 2:c724ff3a4e4d | 41 | |
ptpaterson | 2:c724ff3a4e4d | 42 | namespace ppCANOpen |
ptpaterson | 2:c724ff3a4e4d | 43 | { |
ptpaterson | 2:c724ff3a4e4d | 44 | |
ptpaterson | 2:c724ff3a4e4d | 45 | /* Avoid circular reference */ |
ptpaterson | 2:c724ff3a4e4d | 46 | class Node; |
ptpaterson | 2:c724ff3a4e4d | 47 | |
ptpaterson | 2:c724ff3a4e4d | 48 | /** Node Class to implement feature of a CANOpen NMT node |
ptpaterson | 2:c724ff3a4e4d | 49 | */ |
ptpaterson | 2:c724ff3a4e4d | 50 | class ServiceProvider |
ptpaterson | 2:c724ff3a4e4d | 51 | { |
ptpaterson | 2:c724ff3a4e4d | 52 | public: |
ptpaterson | 2:c724ff3a4e4d | 53 | |
ptpaterson | 4:2034b04c86d2 | 54 | |
ptpaterson | 4:2034b04c86d2 | 55 | |
ptpaterson | 2:c724ff3a4e4d | 56 | ServiceProvider (void); |
ptpaterson | 3:12b3c25bdeba | 57 | ~ServiceProvider (void); |
ptpaterson | 2:c724ff3a4e4d | 58 | |
ptpaterson | 4:2034b04c86d2 | 59 | /** Main loop */ |
ptpaterson | 2:c724ff3a4e4d | 60 | void Run (void); |
ptpaterson | 2:c724ff3a4e4d | 61 | |
ptpaterson | 4:2034b04c86d2 | 62 | /** Register a node to get messages and get update calls |
ptpaterson | 4:2034b04c86d2 | 63 | * @note |
ptpaterson | 4:2034b04c86d2 | 64 | * @param |
ptpaterson | 4:2034b04c86d2 | 65 | * @retval |
ptpaterson | 4:2034b04c86d2 | 66 | */ |
ptpaterson | 2:c724ff3a4e4d | 67 | int AddNode (Node * node); |
ptpaterson | 2:c724ff3a4e4d | 68 | |
ptpaterson | 4:2034b04c86d2 | 69 | /** Register a node to get messages and get update calls |
ptpaterson | 4:2034b04c86d2 | 70 | * @note |
ptpaterson | 4:2034b04c86d2 | 71 | * @param |
ptpaterson | 4:2034b04c86d2 | 72 | * @retval |
ptpaterson | 4:2034b04c86d2 | 73 | */ |
ptpaterson | 4:2034b04c86d2 | 74 | |
ptpaterson | 4:2034b04c86d2 | 75 | /** Add a message to the message queue outbox |
ptpaterson | 4:2034b04c86d2 | 76 | * @note |
ptpaterson | 4:2034b04c86d2 | 77 | * @param |
ptpaterson | 4:2034b04c86d2 | 78 | */ |
ptpaterson | 4:2034b04c86d2 | 79 | void PostMessage (CanOpenMessage * msg); |
ptpaterson | 4:2034b04c86d2 | 80 | |
ptpaterson | 2:c724ff3a4e4d | 81 | // TODO: remove node (swap pointers to fill in nicely |
ptpaterson | 2:c724ff3a4e4d | 82 | private: |
ptpaterson | 2:c724ff3a4e4d | 83 | |
ptpaterson | 4:2034b04c86d2 | 84 | /** define size of arrays in one place */ |
ptpaterson | 4:2034b04c86d2 | 85 | static const int SERVICE_MAX_NODES = 8; |
ptpaterson | 2:c724ff3a4e4d | 86 | |
ptpaterson | 2:c724ff3a4e4d | 87 | /* ======================================================================== |
ptpaterson | 2:c724ff3a4e4d | 88 | * Private Members |
ptpaterson | 2:c724ff3a4e4d | 89 | * ======================================================================== |
ptpaterson | 2:c724ff3a4e4d | 90 | */ |
ptpaterson | 2:c724ff3a4e4d | 91 | |
ptpaterson | 4:2034b04c86d2 | 92 | /** array of messages in a queue |
ptpaterson | 4:2034b04c86d2 | 93 | * @note twice number of max nodes is a bit arbitrary. Will need at |
ptpaterson | 4:2034b04c86d2 | 94 | * least max nodes, but not sure how much more to be safe. |
ptpaterson | 4:2034b04c86d2 | 95 | */ |
ptpaterson | 4:2034b04c86d2 | 96 | std::queue<CanOpenMessage> outbox; |
ptpaterson | 4:2034b04c86d2 | 97 | //CanOpenMessage outbox[SERVICE_MAX_NODES * 2]; |
ptpaterson | 4:2034b04c86d2 | 98 | //int messageCount; |
ptpaterson | 4:2034b04c86d2 | 99 | |
ptpaterson | 2:c724ff3a4e4d | 100 | /** array of nodes to cycle through. |
ptpaterson | 2:c724ff3a4e4d | 101 | * @note |
ptpaterson | 2:c724ff3a4e4d | 102 | */ |
ptpaterson | 2:c724ff3a4e4d | 103 | Node * nodes[SERVICE_MAX_NODES]; |
ptpaterson | 2:c724ff3a4e4d | 104 | |
ptpaterson | 2:c724ff3a4e4d | 105 | /** Keeps count of current number of nodes. |
ptpaterson | 2:c724ff3a4e4d | 106 | * @note |
ptpaterson | 2:c724ff3a4e4d | 107 | */ |
ptpaterson | 2:c724ff3a4e4d | 108 | int nodeCount; |
ptpaterson | 3:12b3c25bdeba | 109 | |
ptpaterson | 3:12b3c25bdeba | 110 | /** stores handle for can open api */ |
ptpaterson | 3:12b3c25bdeba | 111 | CanOpenHandle * hCanOpen; |
ptpaterson | 2:c724ff3a4e4d | 112 | |
ptpaterson | 2:c724ff3a4e4d | 113 | }; |
ptpaterson | 2:c724ff3a4e4d | 114 | |
ptpaterson | 2:c724ff3a4e4d | 115 | } /* namspace ppCANOpen */ |
ptpaterson | 2:c724ff3a4e4d | 116 | |
ptpaterson | 2:c724ff3a4e4d | 117 | #endif /* PPCAN_SERVICE_PROVIDER_H */ |
ptpaterson | 2:c724ff3a4e4d | 118 |