RealSense Cross Platform API
RealSense Cross-platform API
Loading...
Searching...
No Matches
rs_eth_config.hpp
Go to the documentation of this file.
1// License: Apache 2.0. See LICENSE file in root directory.
2// Copyright(c) 2025 RealSense, Inc. All Rights Reserved.
3
4#ifndef LIBREALSENSE_RS2_ETH_CONFIG_HPP
5#define LIBREALSENSE_RS2_ETH_CONFIG_HPP
6
7#include "rs_types.hpp"
8#include "rs_device.hpp"
10
11#include <sstream>
12
13namespace rs2
14{
19 {
20 public:
22
24 {
25 rs2_error * e = nullptr;
26 bool extendable = rs2_is_device_extendable_to( _dev.get(), RS2_EXTENSION_ETH_CONFIG, &e ) && ! e;
27 if( ! extendable || ! rs2_supports_eth_config( _dev.get(), &e ) || e )
28 _dev.reset();
29 error::handle( e );
30 }
31
36 {
37 if( ! _dev )
38 return false; // Was reset in constructor because not supporting Ethernet configuration
39 rs2_error * e = nullptr;
40 auto result = rs2_supports_eth_config( _dev.get(), &e );
41 error::handle( e );
42 return result != 0;
43 }
44
48 uint32_t get_link_speed() const
49 {
50 rs2_error * e = nullptr;
51 auto result = rs2_get_link_speed( _dev.get(), &e );
52 error::handle( e );
53 return result;
54 }
55
60 {
61 rs2_error * e = nullptr;
62 auto result = rs2_get_link_priority( _dev.get(), &e );
63 error::handle( e );
64 return result;
65 }
66
71 {
72 rs2_error * e = nullptr;
73 rs2_set_link_priority( _dev.get(), priority, &e );
74 error::handle( e );
75 }
76
80 uint32_t get_link_timeout() const
81 {
82 rs2_error * e = nullptr;
83 auto result = rs2_get_link_timeout( _dev.get(), &e );
84 error::handle( e );
85 return result;
86 }
87
91 void set_link_timeout( uint32_t timeout ) const
92 {
93 rs2_error * e = nullptr;
94 rs2_set_link_timeout( _dev.get(), timeout, &e );
95 error::handle( e );
96 }
97
101 unsigned int get_dds_domain() const
102 {
103 rs2_error * e = nullptr;
104 auto result = rs2_get_dds_domain( _dev.get(), &e );
105 error::handle( e );
106 return result;
107 }
108
112 void set_dds_domain( unsigned int domain )
113 {
114 rs2_error * e = nullptr;
115 rs2_set_dds_domain( _dev.get(), domain, &e );
116 error::handle( e );
117 }
118
122 void get_ip_address( rs2_ip_address & configured_ip, rs2_ip_address & actual_ip) const
123 {
124 rs2_error * e = nullptr;
125 rs2_get_ip_address( _dev.get(), configured_ip, actual_ip, &e );
126 error::handle( e );
127 }
128
132 void set_ip_address( const rs2_ip_address ip ) const
133 {
134 rs2_error * e = nullptr;
135 rs2_set_ip_address( _dev.get(), ip, &e );
136 error::handle( e );
137 }
138
142 void get_netmask( rs2_ip_address & configured_netmask, rs2_ip_address & actual_netmask ) const
143 {
144 rs2_error * e = nullptr;
145 rs2_get_netmask( _dev.get(), configured_netmask, actual_netmask, &e );
146 error::handle( e );
147 }
148
152 void set_netmask( const rs2_ip_address netmask ) const
153 {
154 rs2_error * e = nullptr;
155 rs2_set_netmask( _dev.get(), netmask, &e );
156 error::handle( e );
157 }
158
162 void get_gateway( rs2_ip_address & configured_gateway, rs2_ip_address & actual_gateway ) const
163 {
164 rs2_error * e = nullptr;
165 rs2_get_gateway( _dev.get(), configured_gateway, actual_gateway, &e );
166 error::handle( e );
167 }
168
172 void set_gateway( const rs2_ip_address gateway ) const
173 {
174 rs2_error * e = nullptr;
175 rs2_set_gateway( _dev.get(), gateway, &e );
176 error::handle( e );
177 }
178
184 void get_dhcp_config( bool & enabled, uint8_t & timeout ) const
185 {
186 rs2_error * e = nullptr;
187 int enabled_as_int = 0;
188 uint32_t timeout_as_uint = 0;
189 rs2_get_dhcp_config( _dev.get(), &enabled_as_int, &timeout_as_uint, &e );
190 enabled = enabled_as_int != 0;
191 timeout = timeout_as_uint;
192 error::handle( e );
193 }
194
200 void set_dhcp_config( bool enabled, uint8_t timeout ) const
201 {
202 rs2_error * e = nullptr;
203 rs2_set_dhcp_config( _dev.get(), enabled ? 1 : 0, timeout, &e );
204 error::handle( e );
205 }
206
210 uint32_t get_mtu() const
211 {
212 rs2_error * e = nullptr;
213 auto result = rs2_get_mtu( _dev.get(), &e );
214 error::handle( e );
215 return result;
216 }
217
222 void set_mtu( uint32_t mtu ) const
223 {
224 rs2_error * e = nullptr;
225 rs2_set_mtu( _dev.get(), mtu, &e );
226 error::handle( e );
227 }
228
232 uint32_t get_transmission_delay() const
233 {
234 rs2_error * e = nullptr;
235 auto result = rs2_get_transmission_delay( _dev.get(), &e );
236 error::handle( e );
237 return result;
238 }
239
244 void set_transmission_delay( uint32_t delay ) const
245 {
246 rs2_error * e = nullptr;
247 rs2_set_transmission_delay( _dev.get(), delay, &e );
248 error::handle( e );
249 }
250
254 uint8_t get_udp_ttl() const
255 {
256 rs2_error * e = nullptr;
257 auto result = rs2_get_udp_ttl( _dev.get(), &e );
258 error::handle( e );
259 return static_cast<uint8_t>(result);
260 }
261
266 void set_udp_ttl( uint8_t ttl ) const
267 {
268 rs2_error * e = nullptr;
269 rs2_set_udp_ttl( _dev.get(), ttl, &e );
270 error::handle( e );
271 }
272
277 {
278 rs2_error * e = nullptr;
280 error::handle( e );
281 }
282 };
283
284 inline std::ostream & operator<<( std::ostream & os, rs2_eth_link_priority priority )
285 {
286 const char * str = rs2_eth_link_priority_to_string( priority );
287 return os << ( str ? str : "unknown" );
288 }
289} // namespace rs2
290
291#endif // LIBREALSENSE_RS2_ETH_CONFIG_HPP
Definition rs_device.hpp:20
const std::shared_ptr< rs2_device > & get() const
Definition rs_device.hpp:164
std::shared_ptr< rs2_device > _dev
Definition rs_device.hpp:209
device()
Definition rs_device.hpp:156
static void handle(rs2_error *e)
Definition rs_types.hpp:167
uint32_t get_link_speed() const
Definition rs_eth_config.hpp:48
void set_transmission_delay(uint32_t delay) const
Definition rs_eth_config.hpp:244
void set_dhcp_config(bool enabled, uint8_t timeout) const
Definition rs_eth_config.hpp:200
eth_config_device(rs2::device d)
Definition rs_eth_config.hpp:23
uint32_t get_transmission_delay() const
Definition rs_eth_config.hpp:232
void set_udp_ttl(uint8_t ttl) const
Definition rs_eth_config.hpp:266
uint32_t get_mtu() const
Definition rs_eth_config.hpp:210
void get_netmask(rs2_ip_address &configured_netmask, rs2_ip_address &actual_netmask) const
Definition rs_eth_config.hpp:142
void set_ip_address(const rs2_ip_address ip) const
Definition rs_eth_config.hpp:132
uint32_t get_link_timeout() const
Definition rs_eth_config.hpp:80
void restore_defaults()
Definition rs_eth_config.hpp:276
bool supports_eth_config() const
Definition rs_eth_config.hpp:35
void get_ip_address(rs2_ip_address &configured_ip, rs2_ip_address &actual_ip) const
Definition rs_eth_config.hpp:122
void set_dds_domain(unsigned int domain)
Definition rs_eth_config.hpp:112
void set_link_timeout(uint32_t timeout) const
Definition rs_eth_config.hpp:91
void get_gateway(rs2_ip_address &configured_gateway, rs2_ip_address &actual_gateway) const
Definition rs_eth_config.hpp:162
void set_netmask(const rs2_ip_address netmask) const
Definition rs_eth_config.hpp:152
uint8_t get_udp_ttl() const
Definition rs_eth_config.hpp:254
eth_config_device()
Definition rs_eth_config.hpp:21
unsigned int get_dds_domain() const
Definition rs_eth_config.hpp:101
void get_dhcp_config(bool &enabled, uint8_t &timeout) const
Definition rs_eth_config.hpp:184
rs2_eth_link_priority get_link_priority() const
Definition rs_eth_config.hpp:59
void set_gateway(const rs2_ip_address gateway) const
Definition rs_eth_config.hpp:172
void set_mtu(uint32_t mtu) const
Definition rs_eth_config.hpp:222
void set_link_priority(rs2_eth_link_priority priority) const
Definition rs_eth_config.hpp:70
Definition rs_processing_gl.hpp:13
std::ostream & operator<<(std::ostream &os, rs2_eth_link_priority priority)
Definition rs_eth_config.hpp:284
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
Exposes RealSense ethernet configuration functionality for C compilers.
rs2_eth_link_priority rs2_get_link_priority(const rs2_device *device, rs2_error **error)
void rs2_get_ip_address(const rs2_device *device, rs2_ip_address configured_ip, rs2_ip_address actual_ip, rs2_error **error)
unsigned int rs2_get_dds_domain(const rs2_device *device, rs2_error **error)
rs2_eth_link_priority
Ethernet link priority options.
Definition rs_eth_config.h:21
unsigned int rs2_get_link_speed(const rs2_device *device, rs2_error **error)
void rs2_set_udp_ttl(const rs2_device *device, unsigned int ttl, rs2_error **error)
uint8_t rs2_ip_address[4]
IP address structure for IPv4 addresses.
Definition rs_eth_config.h:36
void rs2_get_netmask(const rs2_device *device, rs2_ip_address configured_netmask, rs2_ip_address actual_netmask, rs2_error **error)
void rs2_set_transmission_delay(const rs2_device *device, unsigned int delay, rs2_error **error)
unsigned int rs2_get_transmission_delay(const rs2_device *device, rs2_error **error)
void rs2_set_gateway(const rs2_device *device, const rs2_ip_address gateway, rs2_error **error)
void rs2_set_ip_address(const rs2_device *device, const rs2_ip_address ip, rs2_error **error)
void rs2_set_link_priority(const rs2_device *device, rs2_eth_link_priority priority, rs2_error **error)
int rs2_supports_eth_config(const rs2_device *device, rs2_error **error)
void rs2_restore_default_eth_config(const rs2_device *device, rs2_error **error)
const char * rs2_eth_link_priority_to_string(rs2_eth_link_priority priority)
void rs2_get_dhcp_config(const rs2_device *device, int *enabled, unsigned int *timeout, rs2_error **error)
void rs2_set_dhcp_config(const rs2_device *device, int enabled, unsigned int timeout, rs2_error **error)
unsigned int rs2_get_udp_ttl(const rs2_device *device, rs2_error **error)
void rs2_set_link_timeout(const rs2_device *device, unsigned int timeout, rs2_error **error)
void rs2_set_netmask(const rs2_device *device, const rs2_ip_address netmask, rs2_error **error)
void rs2_set_mtu(const rs2_device *device, unsigned int mtu, rs2_error **error)
unsigned int rs2_get_link_timeout(const rs2_device *device, rs2_error **error)
void rs2_get_gateway(const rs2_device *device, rs2_ip_address configured_gateway, rs2_ip_address actual_gateway, rs2_error **error)
unsigned int rs2_get_mtu(const rs2_device *device, rs2_error **error)
void rs2_set_dds_domain(const rs2_device *device, unsigned int domain, rs2_error **error)
@ RS2_EXTENSION_ETH_CONFIG
Definition rs_types.h:199
struct rs2_error rs2_error
Definition rs_types.h:276