Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ppCANOpen_Example DISCO-F746NG_rtos_test
Diff: include/ServiceProvider.h
- Revision:
- 4:2034b04c86d2
- Parent:
- 3:12b3c25bdeba
- Child:
- 5:22a337cdc0e3
diff -r 12b3c25bdeba -r 2034b04c86d2 include/ServiceProvider.h --- a/include/ServiceProvider.h Mon Jan 04 06:10:49 2016 +0000 +++ b/include/ServiceProvider.h Sat Jan 09 17:15:29 2016 +0000 @@ -29,7 +29,15 @@ #ifndef PPCAN_SERVICE_PROVIDER_H #define PPCAN_SERVICE_PROVIDER_H -#include "canopen_protocol.h" +#include "CanOpenMessage.h" +#include <queue> + +/*========================================================================= + * Forward declarations + *========================================================================= + */ + +struct CanOpenHandle; namespace ppCANOpen { @@ -43,117 +51,52 @@ { public: + + ServiceProvider (void); ~ServiceProvider (void); - /** Main loop - * @note - * @param - * @retval - */ + /** Main loop */ void Run (void); - /** - * @note - * @param - * @retval - */ + /** Register a node to get messages and get update calls + * @note + * @param + * @retval + */ int AddNode (Node * node); + /** Register a node to get messages and get update calls + * @note + * @param + * @retval + */ + + /** Add a message to the message queue outbox + * @note + * @param + */ + void PostMessage (CanOpenMessage * msg); + // TODO: remove node (swap pointers to fill in nicely private: - static const int SERVICE_MAX_NODES = 8; - - /* ======================================================================== - * Methods to handle message requests and responses - * Called by the node, usually during Update() or during handling of - * incoming messages. - * ======================================================================== - */ - - /* PDO (7.2.2), MPDO (7.2.3) --------------------------------------------*/ - - /** Build and send a PDO request - * @note - * @param - */ - void RequestPdo (int pdoNum); - - /** Build and send a PDO - * @note - * @param - */ - void ProducePdo (int pdoNum, char * data); - - - /* SDO (7.2.4) ----------------------------------------------------------*/ - - /** initiate SDO download - * @note Handles automatically whether it will be a expedited transfer or - * or if message will be split into - * @param - * - * Node will create a big data array and Service provide will have to - * iterate through and send all of the data. ServiceProvider will pass - * the confirmation to the node, and the node will free up it's buffer. - */ - void DownloadSdo (int sdoNum, int index, int subindex, int size, char * data); - - /** initiate SDO upload - * @note - * @param - */ - void UploadSdo (int sdoNum, int index, int subindex); - - /** Acknowledge that SDO was recieved properly - * @note - * @param - */ - void ConfirmSdo (int sdoNum, int bSuccess); - - /** Abort current SDO transfer - * @note - * @param - */ - void AbortSdo (int sdoNum); - - - /* Emergency object (7.2.7) ---------------------------------------------*/ - - // TODO: emergency producer - - - /* Network Management (7.2.8) -------------------------------------------*/ - /* ---- Node Control (7.2.8.2.1) ----------------------------------------*/ - - /** Build a CANOpen nmt control message to a node - * @note - * @param - */ - int SendNodeControl (NmtCommandSpecifier cs, unsigned int nodeId); - - - /* ---- Error Control (7.2.8.2.2) ---------------------------------------*/ - - /** Build a CANOpen error control request to a node - * @note - * @param - */ - int RequestErrorControl (NmtCommandSpecifier cs, unsigned int nodeId); - - /** Build a CANOpen error control response - * @note - * @param - */ - int RespondErrorControl (NmtCommandSpecifier cs, unsigned int nodeId); - + /** define size of arrays in one place */ + static const int SERVICE_MAX_NODES = 8; /* ======================================================================== * Private Members * ======================================================================== */ + /** array of messages in a queue + * @note twice number of max nodes is a bit arbitrary. Will need at + * least max nodes, but not sure how much more to be safe. + */ + std::queue<CanOpenMessage> outbox; + //CanOpenMessage outbox[SERVICE_MAX_NODES * 2]; + //int messageCount; + /** array of nodes to cycle through. * @note */