Lely core libraries 2.3.4
ssdo.hpp
Go to the documentation of this file.
1
23#ifndef LELY_CO_SSDO_HPP_
24#define LELY_CO_SSDO_HPP_
25
26#if !defined(__cplusplus) || LELY_NO_CXX
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
49 static void
50 free(void* ptr) noexcept {
51 __co_ssdo_free(ptr);
52 }
53
54 static pointer
55 init(pointer p, CANNet* net, CODev* dev, co_unsigned8_t num) noexcept {
56 return __co_ssdo_init(p, net, dev, num);
57 }
58
59 static void
60 fini(pointer p) noexcept {
61 __co_ssdo_fini(p);
62 }
63};
64
66class COSSDO : public incomplete_c_type<__co_ssdo> {
68
69 public:
70 COSSDO(CANNet* net, CODev* dev, co_unsigned8_t num) : c_base(net, dev, num) {}
71
72 int
73 start() noexcept {
74 return co_ssdo_start(this);
75 }
76
77 void
78 stop() noexcept {
79 co_ssdo_stop(this);
80 }
81
82 CANNet*
83 getNet() const noexcept {
84 return co_ssdo_get_net(this);
85 }
86
87 CODev*
88 getDev() const noexcept {
89 return co_ssdo_get_dev(this);
90 }
91
92 co_unsigned8_t
93 getNum() const noexcept {
94 return co_ssdo_get_num(this);
95 }
96
97 const co_sdo_par&
98 getPar() const noexcept {
99 return *co_ssdo_get_par(this);
100 }
101
102 int
103 getTimeout() const noexcept {
104 return co_ssdo_get_timeout(this);
105 }
106
107 void
108 setTimeout(int timeout) noexcept {
109 co_ssdo_set_timeout(this, timeout);
110 }
111
112 protected:
113 ~COSSDO() = default;
114};
115
116} // namespace lely
117
118#endif // !LELY_CO_SSDO_HPP_
An opaque CAN network interface type.
Definition: net.hpp:85
An opaque CANopen device type.
Definition: dev.hpp:77
An opaque CANopen Server-SDO service type.
Definition: ssdo.hpp:66
The base class for a C++ interface to an incomplete C type.
Definition: c_type.hpp:249
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.
int co_ssdo_start(co_ssdo_t *sdo)
Starts a Server-SDO service.
Definition: ssdo.c:687
void co_ssdo_stop(co_ssdo_t *sdo)
Stops a Server-SDO service.
Definition: ssdo.c:721
co_unsigned8_t co_ssdo_get_num(const co_ssdo_t *sdo)
Returns the SDO number of a Server-SDO.
Definition: ssdo.c:768
void co_ssdo_set_timeout(co_ssdo_t *sdo, int timeout)
Sets the timeout of a Server-SDO.
Definition: ssdo.c:792
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:776
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:752
int co_ssdo_get_timeout(const co_ssdo_t *sdo)
Returns the timeout (in milliseconds) of a Server-SDO.
Definition: ssdo.c:784
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:760
A CANopen Server-SDO.
Definition: ssdo.c:63
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:350