Lely core libraries  2.2.5
emcy.h File Reference
#include <lely/can/net.h>
#include <lely/co/type.h>
Include dependency graph for emcy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CO_EMCY_COBID_VALID   UINT32_C(0x80000000)
 The bit in the EMCY COB-ID specifying whether the EMCY exists and is valid.
 
#define CO_EMCY_COBID_FRAME   UINT32_C(0x20000000)
 The bit in the EMCY COB-ID specifying whether to use an 11-bit (0) or 29-bit (1) CAN-ID.
 

Typedefs

typedef void co_emcy_ind_t(co_emcy_t *emcy, co_unsigned8_t id, co_unsigned16_t eec, co_unsigned8_t er, co_unsigned8_t msef[5], void *data)
 The type of a CANopen EMCY indication function, invoked when an EMCY message is received. More...
 

Functions

co_emcy_tco_emcy_create (can_net_t *net, co_dev_t *dev)
 Creates a new CANopen EMCY producer/consumer service. More...
 
void co_emcy_destroy (co_emcy_t *emcy)
 Destroys a CANopen EMCY producer/consumer service. More...
 
can_net_tco_emcy_get_net (const co_emcy_t *emcy)
 Returns a pointer to the CAN network of an EMCY producer/consumer service.
 
co_dev_tco_emcy_get_dev (const co_emcy_t *emcy)
 Returns a pointer to the CANopen device of an EMCY producer/consumer service.
 
int co_emcy_push (co_emcy_t *emcy, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
 Pushes a CANopen EMCY message to the stack and broadcasts it if the EMCY producer service is active. More...
 
int co_emcy_pop (co_emcy_t *emcy, co_unsigned16_t *peec, co_unsigned8_t *per)
 Pops the most recent CANopen EMCY message from the stack and broadcasts an 'error reset' message if the EMCY producer service is active. More...
 
void co_emcy_peek (const co_emcy_t *emcy, co_unsigned16_t *peec, co_unsigned8_t *per)
 Retrieves, but does not pop, the most recent CANopen EMCY message from the stack. More...
 
int co_emcy_clear (co_emcy_t *emcy)
 Clears the CANopen EMCY message stack and broadcasts the 'error reset/no error' message if the EMCY producer service is active. More...
 
void co_emcy_get_ind (const co_emcy_t *emcy, co_emcy_ind_t **pind, void **pdata)
 Retrieves the indication function invoked when a CANopen EMCY message is received. More...
 
void co_emcy_set_ind (co_emcy_t *emcy, co_emcy_ind_t *ind, void *data)
 Sets the indication function invoked when a CANopen EMCY message is received. More...
 

Detailed Description

This header file is part of the CANopen library; it contains the emergency (EMCY) object declarations.

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

Typedef Documentation

◆ co_emcy_ind_t

typedef void co_emcy_ind_t(co_emcy_t *emcy, co_unsigned8_t id, co_unsigned16_t eec, co_unsigned8_t er, co_unsigned8_t msef[5], void *data)

The type of a CANopen EMCY indication function, invoked when an EMCY message is received.

Parameters
emcya pointer to an EMCY consumer service.
idthe node-ID of the producer.
eecthe emergency error code.
erthe error register.
msefthe manufacturer-specific error code.
dataa pointer to user-specified data.

Definition at line 52 of file emcy.h.

Function Documentation

◆ co_emcy_create()

co_emcy_t* co_emcy_create ( can_net_t net,
co_dev_t dev 
)

Creates a new CANopen EMCY producer/consumer service.

Parameters
neta pointer to a CAN network.
deva pointer to a CANopen device.
Returns
a pointer to a new EMCY service, or NULL on error. In the latter case, the error number can be obtained with get_errc().
See also
co_emcy_destroy()

Definition at line 324 of file emcy.c.

◆ co_emcy_destroy()

void co_emcy_destroy ( co_emcy_t emcy)

Destroys a CANopen EMCY producer/consumer service.

See also
co_emcy_create()

Definition at line 351 of file emcy.c.

◆ co_emcy_push()

int co_emcy_push ( co_emcy_t emcy,
co_unsigned16_t  eec,
co_unsigned8_t  er,
const co_unsigned8_t  msef[5] 
)

Pushes a CANopen EMCY message to the stack and broadcasts it if the EMCY producer service is active.

Parameters
emcya pointer to an EMCY producer service.
eecthe emergency error code.
erthe error register.
msefthe manufacturer-specific error code (can be NULL).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_emcy_pop(), co_emcy_peek(), co_emcy_clear()

Definition at line 377 of file emcy.c.

◆ co_emcy_pop()

int co_emcy_pop ( co_emcy_t emcy,
co_unsigned16_t *  peec,
co_unsigned8_t *  per 
)

Pops the most recent CANopen EMCY message from the stack and broadcasts an 'error reset' message if the EMCY producer service is active.

Parameters
emcya pointer to an EMCY producer service.
peecthe address at which to store the emergency error code (can be NULL).
perthe address at which to store the error register (can be NULL).
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_emcy_push(), co_emcy_peek(), co_emcy_clear()

Definition at line 423 of file emcy.c.

◆ co_emcy_peek()

void co_emcy_peek ( const co_emcy_t emcy,
co_unsigned16_t *  peec,
co_unsigned8_t *  per 
)

Retrieves, but does not pop, the most recent CANopen EMCY message from the stack.

Parameters
emcya pointer to an EMCY producer service.
peecthe address at which to store the emergency error code (can be NULL).
perthe address at which to store the error register (can be NULL).
See also
co_emcy_push(), co_emcy_pop(), co_emcy_clear()

Definition at line 453 of file emcy.c.

◆ co_emcy_clear()

int co_emcy_clear ( co_emcy_t emcy)

Clears the CANopen EMCY message stack and broadcasts the 'error reset/no error' message if the EMCY producer service is active.

Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_emcy_push(), co_emcy_pop(), co_emcy_peek()

Definition at line 464 of file emcy.c.

◆ co_emcy_get_ind()

void co_emcy_get_ind ( const co_emcy_t emcy,
co_emcy_ind_t **  pind,
void **  pdata 
)

Retrieves the indication function invoked when a CANopen EMCY message is received.

Parameters
emcya pointer to an EMCY consumer service.
pindthe address at which to store a pointer to the indication function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_emcy_set_ind()

Definition at line 483 of file emcy.c.

◆ co_emcy_set_ind()

void co_emcy_set_ind ( co_emcy_t emcy,
co_emcy_ind_t ind,
void *  data 
)

Sets the indication function invoked when a CANopen EMCY message is received.

Parameters
emcya pointer to an EMCY consumer service.
inda pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to func.
See also
co_emcy_get_ind()

Definition at line 494 of file emcy.c.