Compare commits

..

3 Commits

Author SHA1 Message Date
Thomas Stoddard d7fc7ffa47 RADGigastar2 & RADGalaxy2: Add PhyEnableFor support 2026-05-12 18:38:32 -04:00
Kyle Schwarz 70ad76771e Servd: Clean up unused parseError 2026-05-12 16:57:04 -04:00
Kyle Schwarz 87c10410e8 Servd: Remove no devices found event 2026-05-12 15:58:11 -04:00
6 changed files with 127 additions and 12 deletions

View File

@ -167,7 +167,6 @@ static constexpr const char* SERVD_POLL_ERROR = "Error polling on Servd socket";
static constexpr const char* SERVD_NODATA_ERROR = "No data received from Servd";
static constexpr const char* SERVD_JOIN_MULTICAST_ERROR = "Error joining Servd multicast group";
static constexpr const char* SERVD_NOT_REACHABLE = "Could not reach Servd; ensure it is installed and running";
static constexpr const char* SERVD_NO_DEVICES_FOUND = "Servd is running but no devices found";
// DXX
static constexpr const char* DXX_ERROR_SYS = "System error, check errno/GetLastError()";
@ -442,8 +441,6 @@ const char* APIEvent::DescriptionForType(Type type) {
return SERVD_JOIN_MULTICAST_ERROR;
case Type::ServdNotReachable:
return SERVD_NOT_REACHABLE;
case Type::ServdNoDevicesFound:
return SERVD_NO_DEVICES_FOUND;
// DXX
case Type::DXXErrorSys:

View File

@ -127,7 +127,6 @@ void init_event(pybind11::module_& m) {
.value("ServdNoDataError", APIEvent::Type::ServdNoDataError)
.value("ServdJoinMulticastError", APIEvent::Type::ServdJoinMulticastError)
.value("ServdNotReachable", APIEvent::Type::ServdNotReachable)
.value("ServdNoDevicesFound", APIEvent::Type::ServdNoDevicesFound)
.value("DXXErrorSys", APIEvent::Type::DXXErrorSys)
.value("DXXErrorInt", APIEvent::Type::DXXErrorInt)
.value("DXXErrorOverflow", APIEvent::Type::DXXErrorOverflow)

View File

@ -166,7 +166,6 @@ public:
ServdNoDataError = ServdBindError + 9,
ServdJoinMulticastError = ServdBindError + 10,
ServdNotReachable = ServdBindError + 11,
ServdNoDevicesFound = ServdBindError + 12,
// DXX
DXXErrorSys = 0x6100,

View File

@ -190,6 +190,75 @@ public:
return nullptr;
}
}
bool setPhyEnableFor(Network net, bool enable) override {
auto cfg = getMutableStructurePointer<radgalaxy2_settings_t>();
if(cfg == nullptr)
return false;
if(net.getType() != Network::Type::Ethernet && net.getType() != Network::Type::AutomotiveEthernet) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
auto coreMini = net.getCoreMini();
if(!coreMini.has_value()) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
const uint64_t networkID = static_cast<uint64_t>(coreMini.value());
uint64_t bitfields[2] = {
(uint64_t)cfg->network_enables | ((uint64_t)cfg->network_enables_2 << 16) |
((uint64_t)cfg->network_enables_3 << 32) | ((uint64_t)cfg->network_enables_4 << 48),
cfg->network_enables_5
};
const bool success = enable ?
SetNetworkEnabled(bitfields, 2, networkID) :
ClearNetworkEnabled(bitfields, 2, networkID);
if(!success) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
cfg->network_enables = static_cast<uint16_t>(bitfields[0]);
cfg->network_enables_2 = static_cast<uint16_t>(bitfields[0] >> 16);
cfg->network_enables_3 = static_cast<uint16_t>(bitfields[0] >> 32);
cfg->network_enables_4 = static_cast<uint16_t>(bitfields[0] >> 48);
cfg->network_enables_5 = bitfields[1];
return true;
}
std::optional<bool> getPhyEnableFor(Network net) const override {
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
if(cfg == nullptr) {
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
return std::nullopt;
}
if(net.getType() != Network::Type::Ethernet && net.getType() != Network::Type::AutomotiveEthernet) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return std::nullopt;
}
auto coreMini = net.getCoreMini();
if(!coreMini.has_value()) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return std::nullopt;
}
const uint64_t networkID = static_cast<uint64_t>(coreMini.value());
const uint64_t bitfields[2] = {
(uint64_t)cfg->network_enables | ((uint64_t)cfg->network_enables_2 << 16) |
((uint64_t)cfg->network_enables_3 << 32) | ((uint64_t)cfg->network_enables_4 << 48),
cfg->network_enables_5
};
return GetNetworkEnabled(bitfields, 2, networkID);
}
};
}

View File

@ -465,6 +465,64 @@ namespace icsneo
return std::make_optional(t1sExt->multi_id[index]);
}
bool setPhyEnableFor(Network net, bool enable) override {
auto cfg = getMutableStructurePointer<radgigastar2_settings_t>();
if(cfg == nullptr)
return false;
if(net.getType() != Network::Type::Ethernet && net.getType() != Network::Type::AutomotiveEthernet) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
auto coreMini = net.getCoreMini();
if(!coreMini.has_value()) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
const uint64_t networkID = static_cast<uint64_t>(coreMini.value());
uint64_t bitfields[2] = { cfg->network_enables, cfg->network_enables_2 };
const bool success = enable ?
SetNetworkEnabled(bitfields, 2, networkID) :
ClearNetworkEnabled(bitfields, 2, networkID);
if(!success) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return false;
}
cfg->network_enables = bitfields[0];
cfg->network_enables_2 = bitfields[1];
return true;
}
std::optional<bool> getPhyEnableFor(Network net) const override {
auto cfg = getStructurePointer<radgigastar2_settings_t>();
if(cfg == nullptr) {
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
return std::nullopt;
}
if(net.getType() != Network::Type::Ethernet && net.getType() != Network::Type::AutomotiveEthernet) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return std::nullopt;
}
auto coreMini = net.getCoreMini();
if(!coreMini.has_value()) {
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
return std::nullopt;
}
const uint64_t networkID = static_cast<uint64_t>(coreMini.value());
const uint64_t bitfields[2] = { cfg->network_enables, cfg->network_enables_2 };
return GetNetworkEnabled(bitfields, 2, networkID);
}
bool setT1SMultiIDFor(Network net, uint8_t index, uint8_t id) override {
ETHERNET10T1S_SETTINGS_EXT* t1sExt = getMutableT1SSettingsExtFor(net);
if(t1sExt == nullptr)

View File

@ -67,15 +67,12 @@ void Servd::Find(std::vector<FoundDevice>& found) {
EventManager::GetInstance().add(APIEvent::Type::ServdTransceiveError, APIEvent::Severity::Error);
return;
}
const size_t preCount = found.size();
bool parseError = false;
const auto lines = split(response, '\n');
for(auto&& line : lines) {
const auto cols = split(line, ' ');
if(cols.size() < 3) {
if(!line.empty()) {
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
parseError = true;
}
continue;
}
@ -86,7 +83,6 @@ void Servd::Find(std::vector<FoundDevice>& found) {
port = static_cast<uint16_t>(std::stoi(cols[2]));
} catch (const std::exception&) {
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
parseError = true;
continue;
}
Address address(ip.c_str(), port);
@ -96,9 +92,6 @@ void Servd::Find(std::vector<FoundDevice>& found) {
return std::make_unique<Servd>(err, forDevice, address);
};
}
if(!parseError && found.size() == preCount) {
EventManager::GetInstance().add(APIEvent::Type::ServdNoDevicesFound, APIEvent::Severity::EventInfo);
}
}
Servd::Servd(const device_eventhandler_t& err, neodevice_t& forDevice, const Address& address) :