Lely core libraries 2.3.4
net.h
Go to the documentation of this file.
1
22#ifndef LELY_CAN_NET_H_
23#define LELY_CAN_NET_H_
24
25#include <lely/can/msg.h>
26#include <lely/libc/time.h>
27
28struct __can_net;
29#if !defined(__cplusplus) || LELY_NO_CXX
31typedef struct __can_net can_net_t;
32#endif
33
34struct __can_timer;
35#if !defined(__cplusplus) || LELY_NO_CXX
37typedef struct __can_timer can_timer_t;
38#endif
39
40struct __can_recv;
41#if !defined(__cplusplus) || LELY_NO_CXX
43typedef struct __can_recv can_recv_t;
44#endif
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
61typedef int can_timer_func_t(const struct timespec *tp, void *data);
62
73typedef int can_recv_func_t(const struct can_msg *msg, void *data);
74
85typedef int can_send_func_t(const struct can_msg *msg, void *data);
86
87void *__can_net_alloc(void);
88void __can_net_free(void *ptr);
89struct __can_net *__can_net_init(struct __can_net *net);
90void __can_net_fini(struct __can_net *net);
91
94
96void can_net_destroy(can_net_t *net);
97
106void can_net_get_time(const can_net_t *net, struct timespec *tp);
107
121int can_net_set_time(can_net_t *net, const struct timespec *tp);
122
136 const can_net_t *net, can_timer_func_t **pfunc, void **pdata);
137
149void can_net_set_next_func(can_net_t *net, can_timer_func_t *func, void *data);
150
163int can_net_recv(can_net_t *net, const struct can_msg *msg);
164
175int can_net_send(can_net_t *net, const struct can_msg *msg);
176
190 const can_net_t *net, can_send_func_t **pfunc, void **pdata);
191
202void can_net_set_send_func(can_net_t *net, can_send_func_t *func, void *data);
203
204void *__can_timer_alloc(void);
205void __can_timer_free(void *ptr);
206struct __can_timer *__can_timer_init(struct __can_timer *timer);
207void __can_timer_fini(struct __can_timer *timer);
208
211
213void can_timer_destroy(can_timer_t *timer);
214
226void can_timer_get_func(const can_timer_t *timer, can_timer_func_t **pfunc,
227 void **pdata);
228
240
258 const struct timespec *start, const struct timespec *interval);
259
265void can_timer_stop(can_timer_t *timer);
266
279void can_timer_timeout(can_timer_t *timer, can_net_t *net, int timeout);
280
281void *__can_recv_alloc(void);
282void __can_recv_free(void *ptr);
283struct __can_recv *__can_recv_init(struct __can_recv *recv);
284void __can_recv_fini(struct __can_recv *recv);
285
288
290void can_recv_destroy(can_recv_t *recv);
291
304 const can_recv_t *recv, can_recv_func_t **pfunc, void **pdata);
305
317
329void can_recv_start(can_recv_t *recv, can_net_t *net, uint_least32_t id,
330 uint_least8_t flags);
331
338void can_recv_stop(can_recv_t *recv);
339
340#ifdef __cplusplus
341}
342#endif
343
344#endif // !LELY_CAN_NET_H_
This header file is part of the CAN library; it contains the CAN frame declarations.
This header file is part of the C11 and POSIX compatibility library; it includes <time....
void can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
Definition: net.c:462
int can_net_send(can_net_t *net, const struct can_msg *msg)
Sends a CAN frame from a network interface.
Definition: net.c:300
void can_timer_start(can_timer_t *timer, can_net_t *net, const struct timespec *start, const struct timespec *interval)
Starts a CAN timer and registers it with a network interface.
Definition: net.c:431
can_timer_t * can_timer_create(void)
Creates a new CAN timer.
Definition: net.c:376
void can_net_get_time(const can_net_t *net, struct timespec *tp)
Retrieves the current time of a CAN network interface.
Definition: net.c:196
void can_timer_set_func(can_timer_t *timer, can_timer_func_t *func, void *data)
Sets the callback function invoked when a CAN timer is triggered.
Definition: net.c:422
void can_timer_get_func(const can_timer_t *timer, can_timer_func_t **pfunc, void **pdata)
Retrieves the callback function invoked when a CAN timer is triggered.
Definition: net.c:410
void can_net_set_send_func(can_net_t *net, can_send_func_t *func, void *data)
Sets the callback function used to send CAN frames from a network interface.
Definition: net.c:326
void can_recv_stop(can_recv_t *recv)
Stops a CAN frame receiver from processing frames and unregisters it with the network interface.
Definition: net.c:609
void can_net_destroy(can_net_t *net)
Destroys a CAN network interface.
Definition: net.c:187
void can_net_get_send_func(const can_net_t *net, can_send_func_t **pfunc, void **pdata)
Retrieves the callback function used to send CAN frames from a network interface.
Definition: net.c:314
int can_send_func_t(const struct can_msg *msg, void *data)
The type of a CAN send callback function, invoked by a CAN network interface when a frame needs to be...
Definition: net.h:85
void can_recv_set_func(can_recv_t *recv, can_recv_func_t *func, void *data)
Sets the callback function used to process CAN frames with a receiver.
Definition: net.c:578
void can_recv_destroy(can_recv_t *recv)
Destroys a CAN frame receiver.
Definition: net.c:558
void can_timer_timeout(can_timer_t *timer, can_net_t *net, int timeout)
Starts a CAN timer and registers it with a network interface.
Definition: net.c:478
can_net_t * can_net_create(void)
Creates a new CAN network interface.
Definition: net.c:162
void can_net_get_next_func(const can_net_t *net, can_timer_func_t **pfunc, void **pdata)
Retrieves the callback function invoked when the time at which the next CAN timer triggers is updated...
Definition: net.c:249
int can_recv_func_t(const struct can_msg *msg, void *data)
The type of a CAN receive callback function, invoked by a CAN frame receiver when a frame is received...
Definition: net.h:73
void can_net_set_next_func(can_net_t *net, can_timer_func_t *func, void *data)
Sets the callback function invoked when the time at which the next CAN timer triggers is updated.
Definition: net.c:261
void can_recv_start(can_recv_t *recv, can_net_t *net, uint_least32_t id, uint_least8_t flags)
Registers a CAN frame receiver with a network interface and starts processing frames.
Definition: net.c:587
void can_recv_get_func(const can_recv_t *recv, can_recv_func_t **pfunc, void **pdata)
Retrieves the callback function used to process CAN frames with a receiver.
Definition: net.c:567
can_recv_t * can_recv_create(void)
Creates a new CAN frame receiver.
Definition: net.c:533
int can_net_recv(can_net_t *net, const struct can_msg *msg)
Receives a CAN frame with a network interface and processes it with the corresponding receiver(s).
Definition: net.c:270
int can_net_set_time(can_net_t *net, const struct timespec *tp)
Sets the current time of a CAN network interface.
Definition: net.c:205
int can_timer_func_t(const struct timespec *tp, void *data)
The type of a CAN timer callback function, invoked by a CAN timer when the time is updated,...
Definition: net.h:61
void can_timer_destroy(can_timer_t *timer)
Destroys a CAN timer.
Definition: net.c:401
A CAN network interface.
Definition: net.c:37
A CAN frame receiver.
Definition: net.c:86
void * data
A pointer to the user-specified data for func.
Definition: net.c:104
can_recv_func_t * func
A pointer to the callback function invoked by can_net_recv().
Definition: net.c:102
can_net_t * net
A pointer to the network interface with which this receiver is registered.
Definition: net.c:95
A CAN timer.
Definition: net.c:63
can_net_t * net
A pointer to the network interface with which this timer is registered.
Definition: net.c:70
can_timer_func_t * func
A pointer to the callback function invoked by can_net_set_time().
Definition: net.c:76
struct timespec interval
The interval between successive triggers.
Definition: net.c:74
struct timespec start
The time at which the timer should trigger.
Definition: net.c:72
void * data
A pointer to the user-specified data for func.
Definition: net.c:78
A CAN or CAN FD format frame.
Definition: msg.h:87