Compare commits
3 Commits
7cca96dcfb
...
d7fc7ffa47
| Author | SHA1 | Date |
|---|---|---|
|
|
d7fc7ffa47 | |
|
|
70ad76771e | |
|
|
87c10410e8 |
|
|
@ -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_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_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_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
|
// DXX
|
||||||
static constexpr const char* DXX_ERROR_SYS = "System error, check errno/GetLastError()";
|
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;
|
return SERVD_JOIN_MULTICAST_ERROR;
|
||||||
case Type::ServdNotReachable:
|
case Type::ServdNotReachable:
|
||||||
return SERVD_NOT_REACHABLE;
|
return SERVD_NOT_REACHABLE;
|
||||||
case Type::ServdNoDevicesFound:
|
|
||||||
return SERVD_NO_DEVICES_FOUND;
|
|
||||||
|
|
||||||
// DXX
|
// DXX
|
||||||
case Type::DXXErrorSys:
|
case Type::DXXErrorSys:
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,6 @@ void init_event(pybind11::module_& m) {
|
||||||
.value("ServdNoDataError", APIEvent::Type::ServdNoDataError)
|
.value("ServdNoDataError", APIEvent::Type::ServdNoDataError)
|
||||||
.value("ServdJoinMulticastError", APIEvent::Type::ServdJoinMulticastError)
|
.value("ServdJoinMulticastError", APIEvent::Type::ServdJoinMulticastError)
|
||||||
.value("ServdNotReachable", APIEvent::Type::ServdNotReachable)
|
.value("ServdNotReachable", APIEvent::Type::ServdNotReachable)
|
||||||
.value("ServdNoDevicesFound", APIEvent::Type::ServdNoDevicesFound)
|
|
||||||
.value("DXXErrorSys", APIEvent::Type::DXXErrorSys)
|
.value("DXXErrorSys", APIEvent::Type::DXXErrorSys)
|
||||||
.value("DXXErrorInt", APIEvent::Type::DXXErrorInt)
|
.value("DXXErrorInt", APIEvent::Type::DXXErrorInt)
|
||||||
.value("DXXErrorOverflow", APIEvent::Type::DXXErrorOverflow)
|
.value("DXXErrorOverflow", APIEvent::Type::DXXErrorOverflow)
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,6 @@ public:
|
||||||
ServdNoDataError = ServdBindError + 9,
|
ServdNoDataError = ServdBindError + 9,
|
||||||
ServdJoinMulticastError = ServdBindError + 10,
|
ServdJoinMulticastError = ServdBindError + 10,
|
||||||
ServdNotReachable = ServdBindError + 11,
|
ServdNotReachable = ServdBindError + 11,
|
||||||
ServdNoDevicesFound = ServdBindError + 12,
|
|
||||||
|
|
||||||
// DXX
|
// DXX
|
||||||
DXXErrorSys = 0x6100,
|
DXXErrorSys = 0x6100,
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,75 @@ public:
|
||||||
return nullptr;
|
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,6 +465,64 @@ namespace icsneo
|
||||||
return std::make_optional(t1sExt->multi_id[index]);
|
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 {
|
bool setT1SMultiIDFor(Network net, uint8_t index, uint8_t id) override {
|
||||||
ETHERNET10T1S_SETTINGS_EXT* t1sExt = getMutableT1SSettingsExtFor(net);
|
ETHERNET10T1S_SETTINGS_EXT* t1sExt = getMutableT1SSettingsExtFor(net);
|
||||||
if(t1sExt == nullptr)
|
if(t1sExt == nullptr)
|
||||||
|
|
|
||||||
|
|
@ -67,15 +67,12 @@ void Servd::Find(std::vector<FoundDevice>& found) {
|
||||||
EventManager::GetInstance().add(APIEvent::Type::ServdTransceiveError, APIEvent::Severity::Error);
|
EventManager::GetInstance().add(APIEvent::Type::ServdTransceiveError, APIEvent::Severity::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const size_t preCount = found.size();
|
|
||||||
bool parseError = false;
|
|
||||||
const auto lines = split(response, '\n');
|
const auto lines = split(response, '\n');
|
||||||
for(auto&& line : lines) {
|
for(auto&& line : lines) {
|
||||||
const auto cols = split(line, ' ');
|
const auto cols = split(line, ' ');
|
||||||
if(cols.size() < 3) {
|
if(cols.size() < 3) {
|
||||||
if(!line.empty()) {
|
if(!line.empty()) {
|
||||||
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
|
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
|
||||||
parseError = true;
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +83,6 @@ void Servd::Find(std::vector<FoundDevice>& found) {
|
||||||
port = static_cast<uint16_t>(std::stoi(cols[2]));
|
port = static_cast<uint16_t>(std::stoi(cols[2]));
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
|
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
|
||||||
parseError = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Address address(ip.c_str(), port);
|
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);
|
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) :
|
Servd::Servd(const device_eventhandler_t& err, neodevice_t& forDevice, const Address& address) :
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue