Lely core libraries 1.9.2
ssdo.hpp
Go to the documentation of this file.
1
23#ifndef LELY_CO_SSDO_HPP_
24#define LELY_CO_SSDO_HPP_
25
26#ifndef __cplusplus
27#error "include <lely/co/ssdo.h> for the C interface"
28#endif
29
30#include <lely/can/net.hpp>
31#include <lely/co/ssdo.h>
32
33namespace lely {
34
36template <>
38 typedef __co_ssdo value_type;
39 typedef value_type& reference;
40 typedef const value_type& const_reference;
41 typedef value_type* pointer;
42 typedef const value_type* const_pointer;
43
44 static void*
45 alloc() noexcept {
46 return __co_ssdo_alloc();
47 }
48 static void
49 free(void* ptr) noexcept {
50 __co_ssdo_free(ptr);
51 }
52
53 static pointer
54 init(pointer p, CANNet* net, CODev* dev, co_unsigned8_t num) noexcept {
55 return __co_ssdo_init(p, net, dev, num);
56 }
57
58 static void
59 fini(pointer p) noexcept {
60 __co_ssdo_fini(p);
61 }
62};
63
65class COSSDO : public incomplete_c_type<__co_ssdo> {
67
68 public:
69 COSSDO(CANNet* net, CODev* dev, co_unsigned8_t num) : c_base(net, dev, num) {}
70
71 CANNet*
72 getNet() const noexcept {
73 return co_ssdo_get_net(this);
74 }
75 CODev*
76 getDev() const noexcept {
77 return co_ssdo_get_dev(this);
78 }
79 co_unsigned8_t
80 getNum() const noexcept {
81 return co_ssdo_get_num(this);
82 }
83
84 const co_sdo_par&
85 getPar() const noexcept {
86 return *co_ssdo_get_par(this);
87 }
88
89 int
90 getTimeout() const noexcept {
91 return co_ssdo_get_timeout(this);
92 }
93
94 void
95 setTimeout(int timeout) noexcept {
96 co_ssdo_set_timeout(this, timeout);
97 }
98
99 protected:
100 ~COSSDO() {}
101};
102
103} // namespace lely
104
105#endif // !LELY_CO_SSDO_HPP_
An opaque CAN network interface type.
Definition: net.hpp:83
An opaque CANopen device type.
Definition: dev.hpp:76
An opaque CANopen Server-SDO service type.
Definition: ssdo.hpp:65
The base class for a C++ interface to an incomplete C type.
Definition: c_type.hpp:245
Global namespace for the Lely Industries N.V. libraries.
Definition: buf.hpp:32
This header file is part of the CAN library; it contains the C++ interface of the CAN network interfa...
This header file is part of the CANopen library; it contains the Server-SDO declarations.
co_unsigned8_t co_ssdo_get_num(const co_ssdo_t *sdo)
Returns the SDO number of a Server-SDO.
Definition: ssdo.c:683
void co_ssdo_set_timeout(co_ssdo_t *sdo, int timeout)
Sets the timeout of a Server-SDO.
Definition: ssdo.c:707
const struct co_sdo_par * co_ssdo_get_par(const co_ssdo_t *sdo)
Returns a pointer to the SDO parameter record of a Server-SDO.
Definition: ssdo.c:691
can_net_t * co_ssdo_get_net(const co_ssdo_t *sdo)
Returns a pointer to the CAN network of a Server-SDO.
Definition: ssdo.c:667
int co_ssdo_get_timeout(const co_ssdo_t *sdo)
Returns the timeout (in milliseconds) of a Server-SDO.
Definition: ssdo.c:699
co_dev_t * co_ssdo_get_dev(const co_ssdo_t *sdo)
Returns a pointer to the CANopen device of a Server-SDO.
Definition: ssdo.c:675
A CANopen Server-SDO.
Definition: ssdo.c:43
An SDO parameter record.
Definition: sdo.h:45
A class template supplying a uniform interface to certain attributes of C types.
Definition: c_type.hpp:344