Lely core libraries 2.3.4
nmt_hb.h File Reference

This is the internal header file of the NMT heartbeat consumer declarations. More...

#include "co.h"
#include <lely/co/nmt.h>
Include dependency graph for nmt_hb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct __co_nmt_hb co_nmt_hb_t
 An opaque CANopen NMT heartbeat consumer type.
 

Functions

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...
 
co_nmt_hb_tco_nmt_hb_create (can_net_t *net, co_nmt_t *nmt)
 Creates a new CANopen NMT heartbeat consumer service. More...
 
void co_nmt_hb_destroy (co_nmt_hb_t *hb)
 Destroys a CANopen NMT heartbeat consumer service. More...
 
void co_nmt_hb_set_1016 (co_nmt_hb_t *hb, co_unsigned8_t id, co_unsigned16_t ms)
 Processes the value of CANopen object 1016 (Consumer heartbeat time) for the specified heartbeat consumer. More...
 
void co_nmt_hb_set_st (co_nmt_hb_t *hb, co_unsigned8_t st)
 Sets the expected state of a remote NMT node. More...
 

Detailed Description

This is the internal header file of the NMT heartbeat consumer declarations.

See also
lely/co/nmt.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

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_hb.h.

Function Documentation

◆ co_nmt_hb_ind()

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.

Parameters
nmta pointer to an NMT master/slave service.
idthe node-ID (in the range [1..127]).
stateindicates 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.
reasonindicates whether the event occurred because of a timeout (CO_NMT_EC_TIMEOUT) or a state change (CO_NMT_EC_STATE).
stthe state of the node (if reason is CO_NMT_EC_STATE).

Definition at line 2420 of file nmt.c.

◆ co_nmt_hb_create()

co_nmt_hb_t * co_nmt_hb_create ( can_net_t net,
co_nmt_t nmt 
)

Creates a new CANopen NMT heartbeat consumer service.

Parameters
neta pointer to a CAN network.
nmta pointer to an NMT master/slave service.
Returns
a pointer to a new heartbeat consumer service, or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_nmt_hb_destroy()

Definition at line 137 of file nmt_hb.c.

◆ co_nmt_hb_destroy()

void co_nmt_hb_destroy ( co_nmt_hb_t hb)

Destroys a CANopen NMT heartbeat consumer service.

See also
co_nmt_hb_create()

Definition at line 162 of file nmt_hb.c.

◆ co_nmt_hb_set_1016()

void co_nmt_hb_set_1016 ( co_nmt_hb_t hb,
co_unsigned8_t  id,
co_unsigned16_t  ms 
)

Processes the value of CANopen object 1016 (Consumer heartbeat time) for the specified heartbeat consumer.

If the node-ID is valid and the heartbeat time is non-zero, the heartbeat consumer is activated. Note that this only activates the CAN frame receiver for heartbeat messages. The CAN timer for heartbeat events is not activated until the first heartbeat message is received or co_nmt_hb_set_st() is invoked.

Parameters
hba pointer to a heartbeat consumer service.
idthe node-ID.
msthe heartbeat time (in milliseconds).

Definition at line 171 of file nmt_hb.c.

◆ co_nmt_hb_set_st()

void co_nmt_hb_set_st ( co_nmt_hb_t hb,
co_unsigned8_t  st 
)

Sets the expected state of a remote NMT node.

If the heartbeat consumer is active, invocation of this function is equivalent to reception of a heartbeat message with the specified state and will (re)activate the CAN timer for heartbeat events.

Parameters
hba pointer to a heartbeat consumer service.
stthe state of the node (excluding the toggle bit).

Definition at line 192 of file nmt_hb.c.