Skip to content

Commit

Permalink
ready?
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Jun 16, 2024
1 parent b51b97e commit fd8b93d
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 84 deletions.
23 changes: 23 additions & 0 deletions tools/dds/dds-config/eth-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,26 @@ bool eth_config::operator!=( eth_config const & other ) const noexcept
|| configured.gateway != other.configured.gateway || dds.domain_id != other.dds.domain_id
|| dhcp.on != other.dhcp.on || link.priority != other.link.priority || link.timeout != other.link.timeout;
}


std::vector< uint8_t > eth_config::build_command() const
{
std::vector< uint8_t > data;
data.resize( sizeof( eth_config_v3 ) );
eth_config_v3 & cfg = *reinterpret_cast< eth_config_v3 * >( data.data() );
configured.ip.get_components( cfg.config_ip );
configured.netmask.get_components( cfg.config_netmask );
configured.gateway.get_components( cfg.config_gateway );
cfg.dhcp_on = dhcp.on;
cfg.dhcp_timeout = dhcp.timeout;
cfg.domain_id = dds.domain_id;
cfg.link_check_timeout = link.timeout;
cfg.link_priority = (uint8_t)link.priority;

cfg.mtu = 9000; // R/O, but must be sest to this value

cfg.header.version = 3;
cfg.header.size = sizeof( cfg ) - sizeof( cfg.header );
cfg.header.crc = rsutils::number::calc_crc32( data.data() + sizeof( cfg.header ), cfg.header.size );
return data;
}
4 changes: 3 additions & 1 deletion tools/dds/dds-config/eth-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <rsutils/string/from.h>


enum class link_priority
enum class link_priority : uint8_t
{
usb_only = 0,
eth_only = 1,
Expand Down Expand Up @@ -65,4 +65,6 @@ struct eth_config

bool operator==( eth_config const & ) const noexcept;
bool operator!=( eth_config const & ) const noexcept;

std::vector< uint8_t > build_command() const;
};
Loading

0 comments on commit fd8b93d

Please sign in to comment.