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

Go to the source code of this file.

Macros

#define CO_TIME_COBID_CONSUMER   UINT32_C(0x80000000)
 The bit in the TIME COB-ID specifying whether the device is a consumer.
 
#define CO_TIME_COBID_PRODUCER   UINT32_C(0x40000000)
 The bit in the TIME COB-ID specifying whether the device is a producer.
 
#define CO_TIME_COBID_FRAME   UINT32_C(0x20000000)
 The bit in the TIME COB-ID specifying whether to use an 11-bit (0) or 29-bit (1) CAN-ID.
 

Typedefs

typedef void co_time_ind_t(co_time_t *time, const struct timespec *tp, void *data)
 The type of a CANopen TIME indication function, invoked when a time stamp is received. More...
 

Functions

void co_time_of_day_get (const co_time_of_day_t *tod, struct timespec *tp)
 Loads the absolute time from a CANopen TIME_OF_DAY value. More...
 
void co_time_of_day_set (co_time_of_day_t *tod, const struct timespec *tp)
 Stores the absolute time into a CANopen TIME_OF_DAY value. More...
 
void co_time_diff_get (const co_time_diff_t *td, struct timespec *tp)
 Loads a time difference from a CANopen TIME_DIFFERENCE value. More...
 
void co_time_diff_set (co_time_diff_t *td, const struct timespec *tp)
 Stores a time difference into a CANopen TIME_DIFFERENCE value. More...
 
co_time_tco_time_create (can_net_t *net, co_dev_t *dev)
 Creates a new CANopen TIME producer/consumer service. More...
 
void co_time_destroy (co_time_t *time)
 Destroys a CANopen TIME producer/consumer service. More...
 
int co_time_start (co_time_t *time)
 Starts a TIME service. More...
 
void co_time_stop (co_time_t *time)
 Stops a TIME service. More...
 
int co_time_is_stopped (const co_time_t *time)
 Retuns 1 if the specified TIME service is stopped, and 0 if not. More...
 
can_net_tco_time_get_net (const co_time_t *time)
 Returns a pointer to the CAN network of a TIME producer/consumer service.
 
co_dev_tco_time_get_dev (const co_time_t *time)
 Returns a pointer to the CANopen device of a TIME producer/consumer service.
 
void co_time_get_ind (const co_time_t *time, co_time_ind_t **pind, void **pdata)
 Retrieves the indication function invoked when a CANopen time stamp is received. More...
 
void co_time_set_ind (co_time_t *time, co_time_ind_t *ind, void *data)
 Sets the indication function invoked when a CANopen time stamp is received. More...
 
void co_time_start_prod (co_time_t *time, const struct timespec *start, const struct timespec *interval)
 Starts a CANopen TIME producer. More...
 
void co_time_stop_prod (co_time_t *time)
 Stops a CANopen TIME producer. More...
 

Detailed Description

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

Typedef Documentation

◆ co_time_ind_t

typedef void co_time_ind_t(co_time_t *time, const struct timespec *tp, void *data)

The type of a CANopen TIME indication function, invoked when a time stamp is received.

Parameters
timea pointer to a TIME consumer service.
tpa pointer to the absolute time.
dataa pointer to user-specified data.

Definition at line 52 of file time.h.

Function Documentation

◆ co_time_of_day_get()

void co_time_of_day_get ( const co_time_of_day_t *  tod,
struct timespec *  tp 
)

Loads the absolute time from a CANopen TIME_OF_DAY value.

See also
co_time_of_day_set()

Definition at line 95 of file time.c.

◆ co_time_of_day_set()

void co_time_of_day_set ( co_time_of_day_t *  tod,
const struct timespec *  tp 
)

Stores the absolute time into a CANopen TIME_OF_DAY value.

See also
co_time_of_day_get()

Definition at line 109 of file time.c.

◆ co_time_diff_get()

void co_time_diff_get ( const co_time_diff_t *  td,
struct timespec *  tp 
)

Loads a time difference from a CANopen TIME_DIFFERENCE value.

See also
co_time_diff_set()

Definition at line 128 of file time.c.

◆ co_time_diff_set()

void co_time_diff_set ( co_time_diff_t *  td,
const struct timespec *  tp 
)

Stores a time difference into a CANopen TIME_DIFFERENCE value.

See also
co_time_diff_get()

Definition at line 138 of file time.c.

◆ co_time_create()

co_time_t* co_time_create ( can_net_t net,
co_dev_t dev 
)

Creates a new CANopen TIME producer/consumer service.

The service is started as if by co_time_start().

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

Definition at line 240 of file time.c.

◆ co_time_destroy()

void co_time_destroy ( co_time_t time)

Destroys a CANopen TIME producer/consumer service.

See also
co_time_create()

Definition at line 267 of file time.c.

◆ co_time_start()

int co_time_start ( co_time_t time)

Starts a TIME service.

Postcondition
on success, co_time_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_time_stop()

Definition at line 277 of file time.c.

◆ co_time_stop()

void co_time_stop ( co_time_t time)

Stops a TIME service.

This function invokes co_time_stop_prod() to stop the TIME producer, if necessary.

Postcondition
co_time_is_stopped() returns 1.
See also
co_time_start()

Definition at line 300 of file time.c.

◆ co_time_is_stopped()

int co_time_is_stopped ( const co_time_t time)

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

See also
co_time_start, co_time_stop()

Definition at line 320 of file time.c.

◆ co_time_get_ind()

void co_time_get_ind ( const co_time_t time,
co_time_ind_t **  pind,
void **  pdata 
)

Retrieves the indication function invoked when a CANopen time stamp is received.

Parameters
timea pointer to a TIME 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_time_set_ind()

Definition at line 344 of file time.c.

◆ co_time_set_ind()

void co_time_set_ind ( co_time_t time,
co_time_ind_t ind,
void *  data 
)

Sets the indication function invoked when a CANopen time stamp is received.

Parameters
timea pointer to a TIME 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_time_get_ind()

Definition at line 355 of file time.c.

◆ co_time_start_prod()

void co_time_start_prod ( co_time_t time,
const struct timespec *  start,
const struct timespec *  interval 
)

Starts a CANopen TIME producer.

This function has no effect if the TIME service is not a producer.

Parameters
timea pointer to a TIME producer service.
starta pointer to the absolute time when the next time stamp is to be sent. If start is NULL, this time is given by interval with respect to the current time as obtained with can_net_get_time(). If interval is also NULL, the producer is stopped.
intervala pointer to the interval between successive time stamps. If interval is NULL, only a single time stamp is sent, at the time given by start.
See also
co_time_stop_prod()

Definition at line 364 of file time.c.

◆ co_time_stop_prod()

void co_time_stop_prod ( co_time_t time)

Stops a CANopen TIME producer.

See also
co_time_start_prod()

Definition at line 374 of file time.c.