22#ifndef LELY_CAN_NET_HPP_
23#define LELY_CAN_NET_HPP_
26#error "include <lely/can/net.h> for the C interface"
58 typedef value_type& reference;
59 typedef const value_type& const_reference;
60 typedef value_type* pointer;
61 typedef const value_type* const_pointer;
65 return __can_net_alloc();
68 free(
void* ptr)
noexcept {
73 init(pointer p)
noexcept {
74 return __can_net_init(p);
77 fini(pointer p)
noexcept {
83class CANNet :
public incomplete_c_type<__can_net> {
84 typedef incomplete_c_type<__can_net> c_base;
87 CANNet() : c_base() {}
90 getTime(
timespec* tp)
const noexcept {
95 setTime(
const timespec& tp)
noexcept {
111 setNextFunc(F* f)
noexcept {
113 static_cast<void*
>(f));
116 template <class C, typename c_mem_fn<can_timer_func_t*, C>::type M>
118 setNextFunc(C* obj)
noexcept {
120 static_cast<void*
>(obj));
124 recv(
const can_msg& msg)
noexcept {
129 send(
const can_msg& msg)
noexcept {
145 setSendFunc(F* f)
noexcept {
147 static_cast<void*
>(f));
150 template <class C, typename c_mem_fn<can_send_func_t*, C>::type M>
152 setSendFunc(C* obj)
noexcept {
154 static_cast<void*
>(obj));
165 typedef value_type& reference;
166 typedef const value_type& const_reference;
167 typedef value_type* pointer;
168 typedef const value_type* const_pointer;
172 return __can_timer_alloc();
175 free(
void* ptr)
noexcept {
176 __can_timer_free(ptr);
180 init(pointer p)
noexcept {
181 return __can_timer_init(p);
184 fini(pointer p)
noexcept {
190class CANTimer :
public incomplete_c_type<__can_timer> {
191 typedef incomplete_c_type<__can_timer> c_base;
194 CANTimer() : c_base() {}
208 setFunc(F* f)
noexcept {
212 template <class C, typename c_mem_fn<can_timer_func_t*, C>::type M>
214 setFunc(C* obj)
noexcept {
216 static_cast<void*
>(obj));
221 const timespec* interval = 0)
noexcept {
231 timeout(
CANNet& net,
int timeout)
noexcept {
243 typedef value_type& reference;
244 typedef const value_type& const_reference;
245 typedef value_type* pointer;
246 typedef const value_type* const_pointer;
250 return __can_recv_alloc();
253 free(
void* ptr)
noexcept {
254 __can_recv_free(ptr);
258 init(pointer p)
noexcept {
259 return __can_recv_init(p);
262 fini(pointer p)
noexcept {
268class CANRecv :
public incomplete_c_type<__can_recv> {
269 typedef incomplete_c_type<__can_recv> c_base;
272 CANRecv() : c_base() {}
286 setFunc(F* f)
noexcept {
290 template <class C, typename c_mem_fn<can_recv_func_t*, C>::type M>
292 setFunc(C* obj)
noexcept {
294 static_cast<void*
>(obj));
298 start(
CANNet& net, uint_least32_t
id, uint_least8_t flags = 0)
noexcept {
This header file is part of the utilities library; it contains the C callback wrapper declarations.
This header file is part of the utilities library; it contains the C to C++ interface declarations.
An opaque CAN network interface type.
An opaque CAN frame receiver type.
An opaque CAN timer type.
Global namespace for the Lely Industries N.V. libraries.
This header file is part of the CAN library; it contains the CAN network interface declarations.
void can_timer_stop(can_timer_t *timer)
Stops a CAN timer and unregisters it with a network interface.
int can_net_send(can_net_t *net, const struct can_msg *msg)
Sends a CAN frame from a network interface.
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.
void can_net_get_time(const can_net_t *net, struct timespec *tp)
Retrieves the current time of a CAN network interface.
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.
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.
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.
void can_recv_stop(can_recv_t *recv)
Stops a CAN frame receiver from processing frames and unregisters it with the network interface.
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.
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...
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.
struct __can_net can_net_t
An opaque CAN network interface type.
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.
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...
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...
struct __can_timer can_timer_t
An opaque CAN timer type.
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.
struct __can_recv can_recv_t
An opaque CAN frame receiver type.
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.
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.
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).
int can_net_set_time(can_net_t *net, const struct timespec *tp)
Sets the current time of a CAN network interface.
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,...
A CAN or CAN FD format frame.
A class template supplying a uniform interface to certain attributes of C types.
A time type with nanosecond resolution.