Lely core libraries 2.3.4
sync.h File Reference

This header file is part of the CANopen library; it contains the synchronization (SYNC) object declarations. More...

#include <lely/can/net.h>
#include <lely/co/type.h>
Include dependency graph for sync.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CO_SYNC_COBID_PRODUCER   UINT32_C(0x40000000)
 The bit in the SYNC COB-ID specifying whether the device is a producer.
 
#define CO_SYNC_COBID_FRAME   UINT32_C(0x20000000)
 The bit in the SYNC COB-ID specifying whether to use an 11-bit (0) or 29-bit (1) CAN-ID.
 

Typedefs

typedef void co_sync_ind_t(co_sync_t *sync, co_unsigned8_t cnt, void *data)
 The type of a CANopen SYNC indication function, invoked after a SYNC message is received or transmitted.
 
typedef void co_sync_err_t(co_sync_t *sync, co_unsigned16_t eec, co_unsigned8_t er, void *data)
 The type of a CANopen SYNC error handling function, invoked when the SYNC data length does not match.
 

Functions

co_sync_tco_sync_create (can_net_t *net, co_dev_t *dev)
 Creates a new CANopen SYNC producer/consumer service.
 
void co_sync_destroy (co_sync_t *sync)
 Destroys a CANopen SYNC producer/consumer service.
 
int co_sync_start (co_sync_t *sync)
 Starts a SYNC service.
 
void co_sync_stop (co_sync_t *sync)
 Stops a SYNC service.
 
int co_sync_is_stopped (const co_sync_t *sync)
 Retuns 1 if the specified SYNC service is stopped, and 0 if not.
 
can_net_tco_sync_get_net (const co_sync_t *sync)
 Returns a pointer to the CAN network of a SYNC producer/consumer service.
 
co_dev_tco_sync_get_dev (const co_sync_t *sync)
 Returns a pointer to the CANopen device of a SYNC producer/consumer service.
 
void co_sync_get_ind (const co_sync_t *sync, co_sync_ind_t **pind, void **pdata)
 Retrieves the indication function invoked after a CANopen SYNC message is received or transmitted.
 
void co_sync_set_ind (co_sync_t *sync, co_sync_ind_t *ind, void *data)
 Sets the indication function invoked after a CANopen SYNC message is received or transmitted.
 
void co_sync_get_err (const co_sync_t *sync, co_sync_err_t **perr, void **pdata)
 Retrieves the error handling function of a SYNC consumer service.
 
void co_sync_set_err (co_sync_t *sync, co_sync_err_t *err, void *data)
 Sets the error handling function of a SYNC consumer service.
 

Detailed Description

This header file is part of the CANopen library; it contains the synchronization (SYNC) 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 sync.h.

Typedef Documentation

◆ co_sync_ind_t

typedef void co_sync_ind_t(co_sync_t *sync, co_unsigned8_t cnt, void *data)

The type of a CANopen SYNC indication function, invoked after a SYNC message is received or transmitted.

Parameters
synca pointer to a SYNC consumer service.
cntthe counter.
dataa pointer to user-specified data.

Definition at line 49 of file sync.h.

◆ co_sync_err_t

typedef void co_sync_err_t(co_sync_t *sync, co_unsigned16_t eec, co_unsigned8_t er, void *data)

The type of a CANopen SYNC error handling function, invoked when the SYNC data length does not match.

Parameters
synca pointer to a SYNC consumer service.
eecthe emergency error code (0x8240).
erthe error register (0x10).
dataa pointer to user-specified data.

Definition at line 60 of file sync.h.

Function Documentation

◆ co_sync_create()

co_sync_t * co_sync_create ( can_net_t net,
co_dev_t dev 
)

Creates a new CANopen SYNC producer/consumer service.

The service is started as if by co_sync_start().

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

Definition at line 211 of file sync.c.

◆ co_sync_destroy()

void co_sync_destroy ( co_sync_t sync)

Destroys a CANopen SYNC producer/consumer service.

See also
co_sync_create()

Definition at line 238 of file sync.c.

◆ co_sync_start()

int co_sync_start ( co_sync_t sync)

Starts a SYNC service.

Postcondition
on success, co_sync_is_stopped() returns 0.
Returns
0 on success, or -1 on error. In the latter case, the error number can be obtained with get_errc().
See also
co_sync_stop()

Definition at line 248 of file sync.c.

◆ co_sync_stop()

void co_sync_stop ( co_sync_t sync)

Stops a SYNC service.

Postcondition
co_sync_is_stopped() returns 1.
See also
co_sync_start()

Definition at line 285 of file sync.c.

◆ co_sync_is_stopped()

int co_sync_is_stopped ( const co_sync_t sync)

Retuns 1 if the specified SYNC service is stopped, and 0 if not.

See also
co_sync_start, co_sync_stop()

Definition at line 316 of file sync.c.

◆ co_sync_get_ind()

void co_sync_get_ind ( const co_sync_t sync,
co_sync_ind_t **  pind,
void **  pdata 
)

Retrieves the indication function invoked after a CANopen SYNC message is received or transmitted.

Parameters
synca pointer to a SYNC 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_sync_set_ind()

Definition at line 340 of file sync.c.

◆ co_sync_set_ind()

void co_sync_set_ind ( co_sync_t sync,
co_sync_ind_t ind,
void *  data 
)

Sets the indication function invoked after a CANopen SYNC message is received or transmitted.

Parameters
synca pointer to a SYNC 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 ind.
See also
co_sync_get_ind()

Definition at line 351 of file sync.c.

◆ co_sync_get_err()

void co_sync_get_err ( const co_sync_t sync,
co_sync_err_t **  perr,
void **  pdata 
)

Retrieves the error handling function of a SYNC consumer service.

Parameters
synca pointer to a SYNC consumer service.
perrthe address at which to store a pointer to the error handling function (can be NULL).
pdatathe address at which to store a pointer to user-specified data (can be NULL).
See also
co_sync_set_err()

Definition at line 360 of file sync.c.

◆ co_sync_set_err()

void co_sync_set_err ( co_sync_t sync,
co_sync_err_t err,
void *  data 
)

Sets the error handling function of a SYNC consumer service.

Parameters
synca pointer to a SYNC consumer service.
erra pointer to the function to be invoked.
dataa pointer to user-specified data (can be NULL). data is passed as the last parameter to err.
See also
co_sync_get_err()

Definition at line 371 of file sync.c.