Lely core libraries
2.2.5
|
#include "co.h"
#include <lely/util/diag.h>
#include <lely/can/buf.h>
#include <lely/co/csdo.h>
#include <lely/util/time.h>
#include <lely/co/dev.h>
#include <lely/co/emcy.h>
#include <lely/co/nmt.h>
#include <lely/co/obj.h>
#include <lely/co/rpdo.h>
#include <lely/co/sdo.h>
#include <lely/co/tpdo.h>
#include <lely/co/val.h>
#include "nmt_boot.h"
#include "nmt_cfg.h"
#include "nmt_hb.h"
#include "nmt_srv.h"
#include <assert.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | co_nmt_slave |
A struct containing the state of an NMT slave. More... | |
struct | __co_nmt |
A CANopen NMT master/slave service. More... | |
struct | __co_nmt_state |
A CANopen NMT state. More... | |
Macros | |
#define | CO_NMT_PREOP_SRV |
The services enabled in the NMT 'pre-operational' state. | |
#define | CO_NMT_START_SRV (CO_NMT_PREOP_SRV | CO_NMT_SRV_PDO) |
The services enabled in the NMT 'operational' state. | |
#define | CO_NMT_STOP_SRV CO_NMT_SRV_LSS |
The services enabled in the NMT 'stopped' state. | |
Typedefs | |
typedef const struct __co_nmt_state | co_nmt_state_t |
An opaque CANopen NMT state type. | |
Functions | |
static co_unsigned32_t | co_100c_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for CANopen object 100C (Guard time). More... | |
static co_unsigned32_t | co_100d_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for CANopen object 100D (Life time factor). More... | |
static co_unsigned32_t | co_1016_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for CANopen object 1016 (Consumer heartbeat time). More... | |
static co_unsigned32_t | co_1017_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for CANopen object 1017 (Producer heartbeat time). More... | |
static co_unsigned32_t | co_1f25_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for (all sub-objects of) CANopen object 1F25 (Configuration request). More... | |
static co_unsigned32_t | co_1f80_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for (all sub-objects of) CANopen object 1F80 (NMT startup). More... | |
static co_unsigned32_t | co_1f82_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for (all sub-objects of) CANopen object 1F80 (Request NMT). More... | |
static int | co_nmt_recv_000 (const struct can_msg *msg, void *data) |
The CAN receive callback function for NMT messages. More... | |
static int | co_nmt_recv_700 (const struct can_msg *msg, void *data) |
The CAN receive callback function for NMT error control (node guarding RTR) messages. More... | |
static int | co_nmt_ng_timer (const struct timespec *tp, void *data) |
The CAN timer callback function for node guarding. More... | |
static int | co_nmt_ec_timer (const struct timespec *tp, void *data) |
The CAN timer callback function for life guarding or heartbeat production. More... | |
static int | co_nmt_cs_timer (const struct timespec *tp, void *data) |
The CAN timer callback function for sending buffered NMT messages. More... | |
static void | co_nmt_st_ind (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st) |
The indication function for state change events. More... | |
static void | default_ng_ind (co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data) |
The default node guarding event handler. More... | |
static void | default_lg_ind (co_nmt_t *nmt, int state, void *data) |
The default life guarding event handler. More... | |
static void | default_hb_ind (co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, void *data) |
The default heartbeat event handler. More... | |
static void | default_st_ind (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, void *data) |
The default state change event handler. More... | |
static void | co_nmt_dn_ind (const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data) |
The SDO download progress indication function. More... | |
static void | co_nmt_up_ind (const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data) |
The SDO upload progress indication function. More... | |
static void | co_nmt_tpdo_event_ind (co_unsigned16_t n, void *data) |
The Transmit-PDO event indication function. More... | |
static void | co_nmt_enter (co_nmt_t *nmt, co_nmt_state_t *next) |
Enters the specified state of an NMT master/slave service and invokes the exit and entry functions. | |
static void | co_nmt_emit_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
Invokes the 'NMT command received' transition function of the current state of an NMT master/slave service. More... | |
static void | co_nmt_emit_boot (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es) |
Invokes the 'boot slave completed' transition function of the current state of an NMT master service. More... | |
static co_nmt_state_t * | co_nmt_default_on_boot (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es) |
The default 'boot slave completed' transition function. | |
static co_nmt_state_t * | co_nmt_init_on_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
The 'NMT command received' transition function of the 'initializing' state. | |
static co_nmt_state_t * | co_nmt_reset_node_on_enter (co_nmt_t *nmt) |
The entry function of the 'reset application' state. | |
static co_nmt_state_t * | co_nmt_reset_comm_on_enter (co_nmt_t *nmt) |
The entry function of the 'reset communication' state. | |
static co_nmt_state_t * | co_nmt_reset_comm_on_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
The 'NMT command received' transition function of the 'reset communication' state. | |
static co_nmt_state_t * | co_nmt_bootup_on_enter (co_nmt_t *nmt) |
The entry function of the 'boot-up' state. | |
static co_nmt_state_t * | co_nmt_bootup_on_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
The 'NMT command received' transition function of the 'boot-up' state. | |
static co_nmt_state_t * | co_nmt_preop_on_enter (co_nmt_t *nmt) |
The entry function of the 'pre-operational' state. | |
static co_nmt_state_t * | co_nmt_preop_on_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
The 'NMT command received' transition function of the 'pre-operational' state. | |
static co_nmt_state_t * | co_nmt_preop_on_boot (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es) |
The 'boot slave completed' transition function of the 'pre-operational' state. | |
static co_nmt_state_t * | co_nmt_start_on_enter (co_nmt_t *nmt) |
The entry function of the 'operational' state. | |
static co_nmt_state_t * | co_nmt_start_on_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
The 'NMT command received' transition function of the 'operational' state. | |
static co_nmt_state_t * | co_nmt_stop_on_enter (co_nmt_t *nmt) |
The entry function of the 'stopped' state. | |
static co_nmt_state_t * | co_nmt_stop_on_cs (co_nmt_t *nmt, co_unsigned8_t cs) |
The 'NMT command received' transition function of the 'stopped' state. | |
static co_nmt_state_t * | co_nmt_startup (co_nmt_t *nmt) |
The NMT startup procedure (see Fig. 1 & 2 in CiA 302-2 version 4.1.0). | |
static co_nmt_state_t * | co_nmt_startup_master (co_nmt_t *nmt) |
The NMT master startup procedure. | |
static co_nmt_state_t * | co_nmt_startup_slave (co_nmt_t *nmt) |
The NMT slave startup procedure. | |
static void | co_nmt_ec_init (co_nmt_t *nmt) |
Initializes the error control services. More... | |
static void | co_nmt_ec_fini (co_nmt_t *nmt) |
Finalizes the error control services. More... | |
static int | co_nmt_ec_update (co_nmt_t *nmt) |
Updates and (de)activates the life guarding or heartbeat production services. More... | |
static int | co_nmt_ec_send_res (co_nmt_t *nmt, co_unsigned8_t st) |
Sends an NMT error control response message. More... | |
static void | co_nmt_hb_init (co_nmt_t *nmt) |
Initializes the heartbeat consumer services. More... | |
static void | co_nmt_hb_fini (co_nmt_t *nmt) |
Finalizes the heartbeat consumer services. More... | |
static co_nmt_hb_t * | co_nmt_hb_find (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t *pms) |
Find the heartbeat consumer for the specified node. | |
static void | co_nmt_slaves_init (co_nmt_t *nmt) |
Initializes NMT slave management. More... | |
static void | co_nmt_slaves_fini (co_nmt_t *nmt) |
Finalizes NMT slave management. More... | |
static int | co_nmt_slaves_boot (co_nmt_t *nmt) |
Starts the NMT 'boot slave' processes. More... | |
co_unsigned32_t | co_dev_cfg_hb (co_dev_t *dev, co_unsigned8_t id, co_unsigned16_t ms) |
Configures heartbeat consumption for the specified node by updating CANopen object 1016 (Consumer heartbeat time). More... | |
const char * | co_nmt_es2str (char es) |
Returns a pointer to a string describing an NMT boot error status. | |
co_nmt_t * | co_nmt_create (can_net_t *net, co_dev_t *dev) |
Creates a new CANopen NMT master/slave service. More... | |
void | co_nmt_destroy (co_nmt_t *nmt) |
Destroys a CANopen NMT master/slave service. More... | |
can_net_t * | co_nmt_get_net (const co_nmt_t *nmt) |
Returns a pointer to the CAN network of an NMT master/slave service. | |
co_dev_t * | co_nmt_get_dev (const co_nmt_t *nmt) |
Returns a pointer to the CANopen device of an NMT master/slave service. | |
void | co_nmt_get_cs_ind (const co_nmt_t *nmt, co_nmt_cs_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when an NMT command is received. More... | |
void | co_nmt_set_cs_ind (co_nmt_t *nmt, co_nmt_cs_ind_t *ind, void *data) |
Sets the indication function invoked when an NMT command is received. More... | |
void | co_nmt_get_ng_ind (const co_nmt_t *nmt, co_nmt_ng_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when a node guarding event occurs. More... | |
void | co_nmt_set_ng_ind (co_nmt_t *nmt, co_nmt_ng_ind_t *ind, void *data) |
Sets the indication function invoked when a node guarding event occurs. More... | |
void | co_nmt_on_ng (co_nmt_t *nmt, co_unsigned8_t id, int state, int reason) |
Implements the default behavior when a node guarding event occurs (see sections 7.2.8.2.2.1 and 7.2.8.3.2.1 in CiA 301 version 4.2.0). More... | |
void | co_nmt_get_lg_ind (const co_nmt_t *nmt, co_nmt_lg_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when a life guarding event occurs. More... | |
void | co_nmt_set_lg_ind (co_nmt_t *nmt, co_nmt_lg_ind_t *ind, void *data) |
Sets the indication function invoked when a life guarding event occurs. More... | |
void | co_nmt_on_lg (co_nmt_t *nmt, int state) |
Implements the default behavior when a life guarding event occurs (see section 7.2.8.2.2.2 in CiA 301 version 4.2.0). More... | |
void | co_nmt_get_hb_ind (const co_nmt_t *nmt, co_nmt_hb_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when a heartbeat event occurs. More... | |
void | co_nmt_set_hb_ind (co_nmt_t *nmt, co_nmt_hb_ind_t *ind, void *data) |
Sets the indication function invoked when a heartbeat event occurs. More... | |
void | co_nmt_on_hb (co_nmt_t *nmt, co_unsigned8_t id, int state, int reason) |
Implements the default behavior when a heartbeat event occurs (see sections 7.2.8.2.2.3 and 7.2.8.3.2.2 in CiA 301 version 4.2.0). More... | |
void | co_nmt_get_st_ind (const co_nmt_t *nmt, co_nmt_st_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when a state change is detected. More... | |
void | co_nmt_set_st_ind (co_nmt_t *nmt, co_nmt_st_ind_t *ind, void *data) |
Sets the indication function invoked when a state change is detected. More... | |
void | co_nmt_on_st (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st) |
Implements the default behavior when a state change is detected by the node guarding or heartbeat protocol. More... | |
void | co_nmt_get_lss_req (const co_nmt_t *nmt, co_nmt_lss_req_t **pind, void **pdata) |
Retrieves the request function invoked to perform LSS when booting an NMT master. More... | |
void | co_nmt_set_lss_req (co_nmt_t *nmt, co_nmt_lss_req_t *ind, void *data) |
Sets the request function invoked to perform LSS when booting an NMT master. More... | |
void | co_nmt_get_boot_ind (const co_nmt_t *nmt, co_nmt_boot_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when a CANopen NMT 'boot slave' process completes. More... | |
void | co_nmt_set_boot_ind (co_nmt_t *nmt, co_nmt_boot_ind_t *ind, void *data) |
Sets the indication function invoked when a CANopen NMT 'boot slave' process completes. More... | |
void | co_nmt_get_cfg_ind (const co_nmt_t *nmt, co_nmt_cfg_ind_t **pind, void **pdata) |
Retrieves the indication function invoked when a CANopen NMT 'configuration request' is received. More... | |
void | co_nmt_set_cfg_ind (co_nmt_t *nmt, co_nmt_cfg_ind_t *ind, void *data) |
Sets the indication function invoked when a CANopen NMT 'configuration request' process is received. More... | |
void | co_nmt_get_dn_ind (const co_nmt_t *nmt, co_nmt_sdo_ind_t **pind, void **pdata) |
Retrieves the indication function used to notify the user of the progress of the current SDO download request during the CANopen NMT 'boot slave' process. More... | |
void | co_nmt_set_dn_ind (co_nmt_t *nmt, co_nmt_sdo_ind_t *ind, void *data) |
Sets the indication function used to notify the user of the progress of the current SDO download request during the CANopen NMT 'boot slave' process. More... | |
void | co_nmt_get_up_ind (const co_nmt_t *nmt, co_nmt_sdo_ind_t **pind, void **pdata) |
Retrieves the indication function used to notify the user of the progress of the current SDO upload request during the CANopen NMT 'boot slave' process. More... | |
void | co_nmt_set_up_ind (co_nmt_t *nmt, co_nmt_sdo_ind_t *ind, void *data) |
Sets the indication function used to notify the user of the progress of the current SDO upload request during the CANopen NMT 'boot slave' process. More... | |
void | co_nmt_get_sync_ind (const co_nmt_t *nmt, co_nmt_sync_ind_t **pind, void **pdata) |
Retrieves the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/processed. More... | |
void | co_nmt_set_sync_ind (co_nmt_t *nmt, co_nmt_sync_ind_t *ind, void *data) |
Sets the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/processed. More... | |
void | co_nmt_on_sync (co_nmt_t *nmt, co_unsigned8_t cnt) |
Implements the default behavior after a SYNC object is received or transmitted. More... | |
void | co_nmt_on_err (co_nmt_t *nmt, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5]) |
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and invoking co_nmt_comm_err_ind() in case of a communication error (emergency error code 0x81xx). More... | |
void | co_nmt_on_tpdo_event (co_nmt_t *nmt, co_unsigned16_t n) |
Implements the default behavior when an event is indicated for an event-driven (asynchronous) Transmit-PDO by triggering the transmission of the PDO with co_tpdo_event(). More... | |
void | co_nmt_on_tpdo_event_lock (co_nmt_t *nmt) |
Postpones the transmission of PDOs triggered by co_nmt_on_tpdo_event() until a matching call to co_nmt_on_tpdo_event_unlock(). More... | |
void | co_nmt_on_tpdo_event_unlock (co_nmt_t *nmt) |
Undoes the effect of a single call to co_nmt_on_tpdo_event_lock() and possibly triggers the transmission of postponed PDOs. | |
co_unsigned8_t | co_nmt_get_id (const co_nmt_t *nmt) |
Returns the pending node-ID. More... | |
int | co_nmt_set_id (co_nmt_t *nmt, co_unsigned8_t id) |
Sets the pending node-ID. More... | |
co_unsigned8_t | co_nmt_get_st (const co_nmt_t *nmt) |
Returns the current state of a CANopen NMT service (one of CO_NMT_ST_BOOTUP, CO_NMT_ST_STOP, CO_NMT_ST_START, CO_NMT_ST_RESET_NODE, CO_NMT_ST_RESET_COMM or CO_NMT_ST_PREOP). | |
int | co_nmt_is_master (const co_nmt_t *nmt) |
Returns 1 if the specified CANopen NMT service is a master, and 0 if not. | |
int | co_nmt_get_timeout (const co_nmt_t *nmt) |
Returns the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes. More... | |
void | co_nmt_set_timeout (co_nmt_t *nmt, int timeout) |
Sets the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes. More... | |
int | co_nmt_cs_req (co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id) |
Submits an NMT request to a slave. More... | |
int | co_nmt_lss_con (co_nmt_t *nmt) |
Confirms the completion of the process when booting an NMT master. More... | |
int | co_nmt_boot_req (co_nmt_t *nmt, co_unsigned8_t id, int timeout) |
Requests the NMT 'boot slave' process for the specified node. More... | |
int | co_nmt_is_booting (const co_nmt_t *nmt, co_unsigned8_t id) |
Returns 1 if the NMT 'boot slave' process is currently running for the specified node, and 0 if not. | |
int | co_nmt_cfg_req (co_nmt_t *nmt, co_unsigned8_t id, int timeout, co_nmt_cfg_con_t *con, void *data) |
Issues the NMT 'configuration request' for the specified node. More... | |
int | co_nmt_cfg_res (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac) |
Indicates the result of the 'update configuration' step of an NMT 'request configuration' request for the specified node (see Fig. More... | |
int | co_nmt_ng_req (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned16_t gt, co_unsigned8_t ltf) |
Request the node guarding service for the specified node, even if it is not in the network list. More... | |
int | co_nmt_cs_ind (co_nmt_t *nmt, co_unsigned8_t cs) |
Processes an NMT command from the master or the application. More... | |
void | co_nmt_comm_err_ind (co_nmt_t *nmt) |
Indicates the occurrence of a communication error and invokes the specified error behavior (object 1029:01). More... | |
int | co_nmt_node_err_ind (co_nmt_t *nmt, co_unsigned8_t id) |
Indicates the occurrence of an error event and triggers the error handling process (see Fig. More... | |
co_rpdo_t * | co_nmt_get_rpdo (const co_nmt_t *nmt, co_unsigned16_t n) |
Returns a pointer to a Receive-PDO service. More... | |
co_tpdo_t * | co_nmt_get_tpdo (const co_nmt_t *nmt, co_unsigned16_t n) |
Returns a pointer to a Transmit-PDO service. More... | |
co_ssdo_t * | co_nmt_get_ssdo (const co_nmt_t *nmt, co_unsigned8_t n) |
Returns a pointer to a Server-SDO service. More... | |
co_csdo_t * | co_nmt_get_csdo (const co_nmt_t *nmt, co_unsigned8_t n) |
Returns a pointer to a Client-SDO service. More... | |
co_sync_t * | co_nmt_get_sync (const co_nmt_t *nmt) |
Returns a pointer to the SYNC producer/consumer service. | |
co_time_t * | co_nmt_get_time (const co_nmt_t *nmt) |
Returns a pointer to the TIME producer/consumer service. | |
co_emcy_t * | co_nmt_get_emcy (const co_nmt_t *nmt) |
Returns a pointer to the EMCY producer/consumer service. | |
co_lss_t * | co_nmt_get_lss (const co_nmt_t *nmt) |
Returns a pointer to the LSS master/slave service. | |
void | co_nmt_boot_con (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned8_t st, char es) |
The CANopen NMT 'boot slave' confirmation function, invoked when the 'boot slave' process completes. More... | |
void | co_nmt_cfg_ind (co_nmt_t *nmt, co_unsigned8_t id, co_csdo_t *sdo) |
The CANopen NMT 'update configuration' indication function, invoked when a configuration request is received. More... | |
void | co_nmt_cfg_con (co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac) |
The CANopen NMT 'configuration request' confirmation function, invoked when a configuration request completes (with success or failure). More... | |
void | co_nmt_hb_ind (co_nmt_t *nmt, co_unsigned8_t id, int state, int reason, co_unsigned8_t st) |
The CANopen NMT heartbeat indication function, invoked when a heartbeat event occurs. More... | |
This file is part of the CANopen library; it contains the implementation of the network management (NMT) functions.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file nmt.c.
|
static |
The download indication function for CANopen object 100C (Guard time).
|
static |
The download indication function for CANopen object 100D (Life time factor).
|
static |
The download indication function for CANopen object 1016 (Consumer heartbeat time).
|
static |
The download indication function for CANopen object 1017 (Producer heartbeat time).
|
static |
The download indication function for (all sub-objects of) CANopen object 1F25 (Configuration request).
|
static |
The download indication function for (all sub-objects of) CANopen object 1F80 (NMT startup).
|
static |
The download indication function for (all sub-objects of) CANopen object 1F80 (Request NMT).
|
static |
The CAN receive callback function for NMT messages.
|
static |
The CAN receive callback function for NMT error control (node guarding RTR) messages.
In case of an NMT master, this function receives and processes the boot-up events (see Fig. 13 in CiA 302-2 version 4.1.0).
|
static |
The CAN timer callback function for node guarding.
|
static |
The CAN timer callback function for life guarding or heartbeat production.
|
static |
The CAN timer callback function for sending buffered NMT messages.
|
static |
|
static |
The default node guarding event handler.
|
static |
The default life guarding event handler.
|
static |
|
static |
The default state change event handler.
|
static |
The SDO download progress indication function.
|
static |
The SDO upload progress indication function.
|
static |
The Transmit-PDO event indication function.
|
inlinestatic |
Invokes the 'NMT command received' transition function of the current state of an NMT master/slave service.
nmt | a pointer to an NMT master/slave service. |
cs | the NMT command specifier (one of CO_NMT_CS_START, CO_NMT_CS_STOP, CO_NMT_CS_ENTER_PREOP, CO_NMT_CS_RESET_NODE or CO_NMT_CS_RESET_COMM). |
|
inlinestatic |
Invokes the 'boot slave completed' transition function of the current state of an NMT master service.
nmt | a pointer to an NMT master service. |
id | the node-ID of the slave. |
st | the state of the node (including the toggle bit). |
es | the error status (in the range ['A'..'O'], or 0 on success). |
|
static |
Initializes the error control services.
|
static |
Finalizes the error control services.
|
static |
Updates and (de)activates the life guarding or heartbeat production services.
This function is invoked by the download indication functions when object 100C (Guard time), 100D (Life time factor) or 1017 (Producer heartbeat time) is updated.
|
static |
|
static |
Initializes the heartbeat consumer services.
|
static |
Finalizes the heartbeat consumer services.
|
static |
Initializes NMT slave management.
|
static |
|
static |
co_unsigned32_t co_dev_cfg_hb | ( | co_dev_t * | dev, |
co_unsigned8_t | id, | ||
co_unsigned16_t | ms | ||
) |
Configures heartbeat consumption for the specified node by updating CANopen object 1016 (Consumer heartbeat time).
dev | a pointer to a CANopen device. |
id | the node-ID (in the range [1..127]). |
ms | the heartbeat time (in milliseconds). If ms is 0, the heartbeat consumer is disabled. |
Creates a new CANopen NMT master/slave service.
net | a pointer to a CAN network. |
dev | a pointer to a CANopen device. |
void co_nmt_destroy | ( | co_nmt_t * | nmt | ) |
Destroys a CANopen NMT master/slave service.
void co_nmt_get_cs_ind | ( | const co_nmt_t * | nmt, |
co_nmt_cs_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when an NMT command is received.
nmt | a pointer to an NMT master/slave service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_cs_ind | ( | co_nmt_t * | nmt, |
co_nmt_cs_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when an NMT command is received.
nmt | a pointer to an NMT master/slave service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_get_ng_ind | ( | const co_nmt_t * | nmt, |
co_nmt_ng_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when a node guarding event occurs.
nmt | a pointer to an NMT master service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_ng_ind | ( | co_nmt_t * | nmt, |
co_nmt_ng_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when a node guarding event occurs.
nmt | a pointer to an NMT master service. |
ind | a pointer to the function to be invoked. If ind is NULL, the default indication function will be used (which invokes co_nmt_on_ng()). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_on_ng | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
int | state, | ||
int | reason | ||
) |
Implements the default behavior when a node guarding event occurs (see sections 7.2.8.2.2.1 and 7.2.8.3.2.1 in CiA 301 version 4.2.0).
This function invokes co_nmt_comm_err_ind() when an event occurs.
void co_nmt_get_lg_ind | ( | const co_nmt_t * | nmt, |
co_nmt_lg_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when a life guarding event occurs.
nmt | a pointer to an NMT slave service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_lg_ind | ( | co_nmt_t * | nmt, |
co_nmt_lg_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when a life guarding event occurs.
nmt | a pointer to an NMT slave service. |
ind | a pointer to the function to be invoked. If ind is NULL, the default indication function will be used (which invokes co_nmt_on_lg()). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_on_lg | ( | co_nmt_t * | nmt, |
int | state | ||
) |
Implements the default behavior when a life guarding event occurs (see section 7.2.8.2.2.2 in CiA 301 version 4.2.0).
This function invokes co_nmt_comm_err_ind() when an event occurs.
void co_nmt_get_hb_ind | ( | const co_nmt_t * | nmt, |
co_nmt_hb_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when a heartbeat event occurs.
nmt | a pointer to an NMT master/slave service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_hb_ind | ( | co_nmt_t * | nmt, |
co_nmt_hb_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when a heartbeat event occurs.
nmt | a pointer to an NMT master/slave service. |
ind | a pointer to the function to be invoked. If ind is NULL, the default indication function will be used (which invokes co_nmt_on_hb()). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_on_hb | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
int | state, | ||
int | reason | ||
) |
Implements the default behavior when a heartbeat event occurs (see sections 7.2.8.2.2.3 and 7.2.8.3.2.2 in CiA 301 version 4.2.0).
This function invokes co_nmt_node_err_ind() or co_nmt_comm_err_ind() when a timeout event occurs, depending on whether the NMT service is a master or not (see co_nmt_is_master()).
void co_nmt_get_st_ind | ( | const co_nmt_t * | nmt, |
co_nmt_st_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when a state change is detected.
nmt | a pointer to an NMT master/slave service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_st_ind | ( | co_nmt_t * | nmt, |
co_nmt_st_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when a state change is detected.
nmt | a pointer to an NMT master/slave service. |
ind | a pointer to the function to be invoked. If ind is NULL, the default indication function will be used (which invokes co_nmt_on_st()). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_on_st | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
co_unsigned8_t | st | ||
) |
Implements the default behavior when a state change is detected by the node guarding or heartbeat protocol.
In case of a boot-up event (and the NMT service is a master), this function invokes co_nmt_boot_req() to boot the slave (see Fig. 13 in CiA 302-2).
void co_nmt_get_lss_req | ( | const co_nmt_t * | nmt, |
co_nmt_lss_req_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the request function invoked to perform LSS when booting an NMT master.
nmt | a pointer to an NMT master service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_lss_req | ( | co_nmt_t * | nmt, |
co_nmt_lss_req_t * | ind, | ||
void * | data | ||
) |
Sets the request function invoked to perform LSS when booting an NMT master.
Setting this function means LSS is required (see Fig. 1 in CiA 302-2 version 4.1.0).
nmt | a pointer to an NMT master service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_get_boot_ind | ( | const co_nmt_t * | nmt, |
co_nmt_boot_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when a CANopen NMT 'boot slave' process completes.
nmt | a pointer to an NMT master service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_boot_ind | ( | co_nmt_t * | nmt, |
co_nmt_boot_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when a CANopen NMT 'boot slave' process completes.
nmt | a pointer to an NMT master service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_get_cfg_ind | ( | const co_nmt_t * | nmt, |
co_nmt_cfg_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked when a CANopen NMT 'configuration request' is received.
nmt | a pointer to an NMT master service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_cfg_ind | ( | co_nmt_t * | nmt, |
co_nmt_cfg_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked when a CANopen NMT 'configuration request' process is received.
nmt | a pointer to an NMT master service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_get_dn_ind | ( | const co_nmt_t * | nmt, |
co_nmt_sdo_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function used to notify the user of the progress of the current SDO download request during the CANopen NMT 'boot slave' process.
nmt | a pointer to an NMT master service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_dn_ind | ( | co_nmt_t * | nmt, |
co_nmt_sdo_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function used to notify the user of the progress of the current SDO download request during the CANopen NMT 'boot slave' process.
nmt | a pointer to an NMT master service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_get_up_ind | ( | const co_nmt_t * | nmt, |
co_nmt_sdo_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function used to notify the user of the progress of the current SDO upload request during the CANopen NMT 'boot slave' process.
nmt | a pointer to an NMT master service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_up_ind | ( | co_nmt_t * | nmt, |
co_nmt_sdo_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function used to notify the user of the progress of the current SDO upload request during the CANopen NMT 'boot slave' process.
nmt | a pointer to an NMT master service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_get_sync_ind | ( | const co_nmt_t * | nmt, |
co_nmt_sync_ind_t ** | pind, | ||
void ** | pdata | ||
) |
Retrieves the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/processed.
nmt | a pointer to an NMT master/slave service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
void co_nmt_set_sync_ind | ( | co_nmt_t * | nmt, |
co_nmt_sync_ind_t * | ind, | ||
void * | data | ||
) |
Sets the indication function invoked by co_nmt_on_sync() after all PDOs have been transmitted/processed.
nmt | a pointer to an NMT master/slave service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_nmt_on_sync | ( | co_nmt_t * | nmt, |
co_unsigned8_t | cnt | ||
) |
Implements the default behavior after a SYNC object is received or transmitted.
First all synchronous Transmit-PDOs are sent with co_tpdo_sync(). Then all synchronous Receive-PDOs are actuated with co_rpdo_sync(). Finally the user-defined callback function set with co_nmt_set_sync_ind() is invoked.
void co_nmt_on_err | ( | co_nmt_t * | nmt, |
co_unsigned16_t | eec, | ||
co_unsigned8_t | er, | ||
const co_unsigned8_t | msef[5] | ||
) |
Implements the default error handling behavior by generating an EMCY message with co_emcy_push() and invoking co_nmt_comm_err_ind() in case of a communication error (emergency error code 0x81xx).
void co_nmt_on_tpdo_event | ( | co_nmt_t * | nmt, |
co_unsigned16_t | n | ||
) |
Implements the default behavior when an event is indicated for an event-driven (asynchronous) Transmit-PDO by triggering the transmission of the PDO with co_tpdo_event().
The transmission of PDOs can be postponed with co_nmt_on_tpdo_event_lock().
nmt | a pointer to an NMT master/slave service. |
n | the PDO number (in the range [1..512]). If n is 0, the transmission of all PDOs is triggered. |
void co_nmt_on_tpdo_event_lock | ( | co_nmt_t * | nmt | ) |
Postpones the transmission of PDOs triggered by co_nmt_on_tpdo_event() until a matching call to co_nmt_on_tpdo_event_unlock().
This function can be invoked multiple times. PDO transmission will resume after an equal number of calls to co_nmt_on_tpdo_event_unlock().
co_unsigned8_t co_nmt_get_id | ( | const co_nmt_t * | nmt | ) |
int co_nmt_set_id | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id | ||
) |
Sets the pending node-ID.
The node-ID of the device will be updated once the NMT 'reset communication command' is received. This is used for the LSS configure node-ID protocol.
nmt | a pointer to an NMT master/slave service. |
id | the node-ID of the device (in the range [1..127, 255]). |
int co_nmt_get_timeout | ( | const co_nmt_t * | nmt | ) |
Returns the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.
void co_nmt_set_timeout | ( | co_nmt_t * | nmt, |
int | timeout | ||
) |
Sets the default SDO timeout used during the NMT 'boot slave' and 'check configuration' processes.
nmt | a pointer to an NMT master service. |
timeout | the SDO timeout (in milliseconds). See co_csdo_set_timeout(). |
int co_nmt_cs_req | ( | co_nmt_t * | nmt, |
co_unsigned8_t | cs, | ||
co_unsigned8_t | id | ||
) |
Submits an NMT request to a slave.
If id equals the node-ID of the master, this is equivalent to co_nmt_cs_ind(nmt, cs)
.
nmt | a pointer to an NMT master service. |
cs | the NMT command specifier (one of CO_NMT_CS_START, CO_NMT_CS_STOP, CO_NMT_CS_ENTER_PREOP, CO_NMT_CS_RESET_NODE or CO_NMT_CS_RESET_COMM). |
id | the node-ID (0 for all nodes, [1..127] for a specific slave). |
int co_nmt_lss_con | ( | co_nmt_t * | nmt | ) |
Confirms the completion of the process when booting an NMT master.
The function specified to co_nmt_set_lss_req() MUST cause this function to be invoked.
int co_nmt_boot_req | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
int | timeout | ||
) |
Requests the NMT 'boot slave' process for the specified node.
The function specified to co_nmt_set_boot_ind() is invoked on completion.
nmt | a pointer to an NMT master service. |
id | the node-ID (in the range [1..127]). |
timeout | the SDO timeout (in milliseconds). See co_csdo_set_timeout(). |
int co_nmt_cfg_req | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
int | timeout, | ||
co_nmt_cfg_con_t * | con, | ||
void * | data | ||
) |
Issues the NMT 'configuration request' for the specified node.
The function specified to co_nmt_set_cfg_ind() is invoked to complete the request.
nmt | a pointer to an NMT master service. |
id | the node-ID (0 for all nodes, [1..127] for a specific slave). |
timeout | the SDO timeout (in milliseconds). See co_csdo_set_timeout(). |
con | a pointer to the confirmation function (can be NULL). |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to con. |
int co_nmt_cfg_res | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
co_unsigned32_t | ac | ||
) |
Indicates the result of the 'update configuration' step of an NMT 'request configuration' request for the specified node (see Fig.
8 in CiA 302-2 version 4.1.0). This function MUST be called upon completion.
nmt | a pointer to an NMT master service. |
id | the node-ID (in the range [1..127]). |
ac | the SDO abort code (0 on success). |
int co_nmt_ng_req | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
co_unsigned16_t | gt, | ||
co_unsigned8_t | ltf | ||
) |
Request the node guarding service for the specified node, even if it is not in the network list.
If the guard time or lifetime factor is 0, node guarding is disabled.
nmt | a pointer to an NMT master service. |
id | the node-ID (in the range [1..127]). |
gt | the guard time (in milliseconds). |
ltf | the lifetime factor. |
int co_nmt_cs_ind | ( | co_nmt_t * | nmt, |
co_unsigned8_t | cs | ||
) |
Processes an NMT command from the master or the application.
Note that this function MAY trigger a reset of one or more CANopen services and invalidate previously obtained results of co_nmt_get_rpdo(), co_nmt_get_tpdo(), co_nmt_get_ssdo(), co_nmt_get_csdo(), co_nmt_get_sync(), co_nmt_get_time() and/or co_nmt_get_emcy().
This function MUST NOT be invoked during an NMT state transition. It is therefore unsafe to call co_nmt_cs_ind() (or co_nmt_cs_req() with the node-ID of the master) from the co_nmt_cs_ind_t and co_nmt_st_ind_t indication functions.
nmt | a pointer to an NMT master/slave service. |
cs | the NMT command specifier (one of CO_NMT_CS_START, CO_NMT_CS_STOP, CO_NMT_CS_ENTER_PREOP, CO_NMT_CS_RESET_NODE or CO_NMT_CS_RESET_COMM). |
void co_nmt_comm_err_ind | ( | co_nmt_t * | nmt | ) |
Indicates the occurrence of a communication error and invokes the specified error behavior (object 1029:01).
Note that this function MAY invoke co_nmt_cs_ind().
int co_nmt_node_err_ind | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id | ||
) |
Indicates the occurrence of an error event and triggers the error handling process (see Fig.
12 in CiA 302-2 version 4.1.0). Note that this function MAY invoke co_nmt_cs_ind().
nmt | a pointer to an NMT master service. |
id | the node-ID (in the range [1..127]). |
void co_nmt_boot_con | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
co_unsigned8_t | st, | ||
char | es | ||
) |
The CANopen NMT 'boot slave' confirmation function, invoked when the 'boot slave' process completes.
nmt | a pointer to an NMT master service. |
id | the node-ID of the slave (in the range [1..127]). |
st | the state of the node (including the toggle bit). |
es | the error status (in the range ['A'..'O'], or 0 on success). |
The CANopen NMT 'update configuration' indication function, invoked when a configuration request is received.
nmt | a pointer to an NMT master service. |
id | the node-ID of the slave (in the range [1..127]). |
sdo | a pointer to a Client-SDO connected to the slave. |
void co_nmt_cfg_con | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
co_unsigned32_t | ac | ||
) |
The CANopen NMT 'configuration request' confirmation function, invoked when a configuration request completes (with success or failure).
nmt | a pointer to an NMT master service. |
id | the node-ID of the slave (in the range [1..127]). |
ac | the SDO abort code (0 on success). |
void co_nmt_hb_ind | ( | co_nmt_t * | nmt, |
co_unsigned8_t | id, | ||
int | state, | ||
int | reason, | ||
co_unsigned8_t | st | ||
) |
The CANopen NMT heartbeat indication function, invoked when a heartbeat event occurs.
nmt | a pointer to an NMT master/slave service. |
id | the node-ID (in the range [1..127]). |
state | indicates whether the event occurred (CO_NMT_EC_OCCURRED) or was resolved (CO_NMT_EC_RESOLVED). Note that heartbeat state change events only occur and are never resolved. |
reason | indicates whether the event occurred because of a timeout (CO_NMT_EC_TIMEOUT) or a state change (CO_NMT_EC_STATE). |
st | the state of the node (if reason is CO_NMT_EC_STATE). |