Lely core libraries 2.3.4
gw.hpp
Go to the documentation of this file.
1
22#ifndef LELY_CO_GW_HPP_
23#define LELY_CO_GW_HPP_
24
25#if !defined(__cplusplus) || LELY_NO_CXX
26#error "include <lely/co/gw.h> for the C interface"
27#endif
28
29#include <lely/util/c_type.hpp>
30
31namespace lely {
32class COGW;
33}
36
37#include <lely/co/gw.h>
38
39namespace lely {
40
42template <>
44 typedef __co_gw value_type;
45 typedef value_type& reference;
46 typedef const value_type& const_reference;
47 typedef value_type* pointer;
48 typedef const value_type* const_pointer;
49
50 static void*
51 alloc() noexcept {
52 return __co_gw_alloc();
53 }
54 static void
55 free(void* ptr) noexcept {
56 __co_gw_free(ptr);
57 }
58
59 static pointer
60 init(pointer p) noexcept {
61 return __co_gw_init(p);
62 }
63 static void
64 fini(pointer p) noexcept {
65 __co_gw_fini(p);
66 }
67};
68
70class COGW : public incomplete_c_type<__co_gw> {
72
73 public:
74 COGW() : c_base() {}
75
76 int
77 initNet(co_unsigned16_t id, CONMT* nmt) noexcept {
78 return co_gw_init_net(this, id, nmt);
79 }
80
81 int
82 finiNet(co_unsigned16_t id) noexcept {
83 return co_gw_fini_net(this, id);
84 }
85
86 int
87 recv(const co_gw_req* req) noexcept {
88 return co_gw_recv(this, req);
89 }
90
91 void
92 getSendFunc(co_gw_send_func_t** pfunc, void** pdata) const noexcept {
94 }
95
96 void
97 setSendFunc(co_gw_send_func_t* func, void* data) noexcept {
98 co_gw_set_send_func(this, func, data);
99 }
100
101 template <class F>
102 void
103 setSendFunc(F* f) noexcept {
105 static_cast<void*>(f));
106 }
107
109 void
110 setSendFunc(C* obj) noexcept {
112 static_cast<void*>(obj));
113 }
114
115 void
116 getRateFunc(co_gw_rate_func_t** pfunc, void** pdata) const noexcept {
118 }
119
120 void
121 setRateFunc(co_gw_rate_func_t* func, void* data) noexcept {
122 co_gw_set_rate_func(this, func, data);
123 }
124
125 template <class F>
126 void
127 setRateFunc(F* f) noexcept {
129 static_cast<void*>(f));
130 }
131
133 void
134 setRateFunc(C* obj) noexcept {
136 static_cast<void*>(obj));
137 }
138
139 protected:
140 ~COGW() = default;
141};
142
143} // namespace lely
144
145#endif // !LELY_CO_GW_HPP_
This header file is part of the utilities library; it contains the C to C++ interface declarations.
An opaque CANopen gateway type.
Definition gw.hpp:70
An opaque CANopen NMT master/slave service type.
Definition nmt.hpp:71
A CANopen value.
Definition val.hpp:42
The base class for a C++ interface to an incomplete C type.
Definition c_type.hpp:249
This header file is part of the CANopen library; it contains the gateway declarations (see CiA 309-1 ...
int co_gw_recv(co_gw_t *gw, const struct co_gw_req *req)
Receives and processes a request with a CANopen gateway.
Definition gw.c:614
void co_gw_set_rate_func(co_gw_t *gw, co_gw_rate_func_t *func, void *data)
Sets the callback function invoked when a baudrate switch is needed after an 'Initialize gateway' com...
Definition gw.c:945
int co_gw_init_net(co_gw_t *gw, co_unsigned16_t id, co_nmt_t *nmt)
Registers a CANopen network with a gateway.
Definition gw.c:583
void co_gw_get_rate_func(const co_gw_t *gw, co_gw_rate_func_t **pfunc, void **pdata)
Retrieves the callback function invoked when a baudrate switch is needed after an 'Initialize gateway...
Definition gw.c:934
int co_gw_send_func_t(const struct co_gw_srv *srv, void *data)
The type of a CANopen gateway send callback function, invoked by a gateway when an indication or conf...
Definition gw.h:976
int co_gw_fini_net(co_gw_t *gw, co_unsigned16_t id)
Unregisters a CANopen network with a gateway.
Definition gw.c:598
void co_gw_rate_func_t(co_unsigned16_t net, co_unsigned16_t rate, void *data)
The type of a CANopen gateway 'set bit timing' function, invoked when a baudrate switch is needed aft...
Definition gw.h:986
void co_gw_get_send_func(const co_gw_t *gw, co_gw_send_func_t **pfunc, void **pdata)
Retrieves the callback function used to send indications and confirmations from a CANopen gateway.
Definition gw.c:914
void co_gw_set_send_func(co_gw_t *gw, co_gw_send_func_t *func, void *data)
Sets the callback function used to send indications and confirmations from a CANopen gateway.
Definition gw.c:925
lely::COGW co_gw_t
An opaque CANopen gateway type.
Definition gw.hpp:35
A CANopen gateway.
Definition gw.c:313
The common parameters of a CANopen gateway request.
Definition gw.h:271
A class template supplying a uniform interface to certain attributes of C types.
Definition c_type.hpp:350