Compare commits
No commits in common. "d7fc7ffa47eccb7c287582e38f1f9915d6995172" and "7cca96dcfb281c24d6a0c8819d3357a87b912c1c" have entirely different histories.
d7fc7ffa47
...
7cca96dcfb
|
|
@ -167,6 +167,7 @@ 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()";
|
||||
|
|
@ -441,6 +442,8 @@ 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:
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ 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)
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ public:
|
|||
ServdNoDataError = ServdBindError + 9,
|
||||
ServdJoinMulticastError = ServdBindError + 10,
|
||||
ServdNotReachable = ServdBindError + 11,
|
||||
ServdNoDevicesFound = ServdBindError + 12,
|
||||
|
||||
// DXX
|
||||
DXXErrorSys = 0x6100,
|
||||
|
|
|
|||
|
|
@ -190,75 +190,6 @@ 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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,64 +465,6 @@ 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)
|
||||
|
|
|
|||
|
|
@ -67,12 +67,15 @@ 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;
|
||||
}
|
||||
|
|
@ -83,6 +86,7 @@ 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);
|
||||
|
|
@ -92,6 +96,9 @@ 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) :
|
||||
|
|
|
|||
Loading…
Reference in New Issue