7 Commits
26 changed files with 236 additions and 21 deletions
+8
View File
@@ -4,6 +4,14 @@ libicsneo is the [Intrepid Control Systems](https://intrepidcs.com/) device
communication library. Installation and usage documentation can be found within communication library. Installation and usage documentation can be found within
each of the respective APIs. each of the respective APIs.
## Installation
libicsneo relies on Servd, IntrepidCS's device communication server.
Servd can be installed for all platforms from https://cdn.intrepidcs.net/servd/.
Instructions for installing each API can be found in its respective documentation.
## Documentation ## Documentation
- [C++](https://libicsneo.readthedocs.io/en/latest/icsneocpp/) - [C++](https://libicsneo.readthedocs.io/en/latest/icsneocpp/)
+5 -2
View File
@@ -63,8 +63,8 @@ static constexpr const char* NO_SERIAL_NUMBER_12V = "Communication could not be
static constexpr const char* NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered or requires a firmware update using Vehicle Spy."; static constexpr const char* NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered or requires a firmware update using Vehicle Spy.";
static constexpr const char* INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!"; static constexpr const char* INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!";
static constexpr const char* SETTINGS_READ = "The device settings could not be read."; static constexpr const char* SETTINGS_READ = "The device settings could not be read.";
static constexpr const char* SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with neoVI Explorer."; static constexpr const char* SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with ICS Device Manager.";
static constexpr const char* SETTINGS_LENGTH = "The settings length is incorrect, please update your firmware with neoVI Explorer."; static constexpr const char* SETTINGS_LENGTH = "The settings length is incorrect, please update your firmware with ICS Device Manager.";
static constexpr const char* SETTINGS_CHECKSUM = "The settings checksum is incorrect, attempting to set defaults may remedy this issue."; static constexpr const char* SETTINGS_CHECKSUM = "The settings checksum is incorrect, attempting to set defaults may remedy this issue.";
static constexpr const char* SETTINGS_NOT_AVAILABLE = "Settings are not available for this device."; static constexpr const char* SETTINGS_NOT_AVAILABLE = "Settings are not available for this device.";
static constexpr const char* SETTINGS_READONLY = "Settings are read-only for this device."; static constexpr const char* SETTINGS_READONLY = "Settings are read-only for this device.";
@@ -166,6 +166,7 @@ static constexpr const char* SERVD_RECV_ERROR = "Error receiving from Servd";
static constexpr const char* SERVD_POLL_ERROR = "Error polling on Servd socket"; 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";
// 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()";
@@ -438,6 +439,8 @@ const char* APIEvent::DescriptionForType(Type type) {
return SERVD_NODATA_ERROR; return SERVD_NODATA_ERROR;
case Type::ServdJoinMulticastError: case Type::ServdJoinMulticastError:
return SERVD_JOIN_MULTICAST_ERROR; return SERVD_JOIN_MULTICAST_ERROR;
case Type::ServdNotReachable:
return SERVD_NOT_REACHABLE;
// DXX // DXX
case Type::DXXErrorSys: case Type::DXXErrorSys:
+1
View File
@@ -126,6 +126,7 @@ void init_event(pybind11::module_& m) {
.value("ServdPollError", APIEvent::Type::ServdPollError) .value("ServdPollError", APIEvent::Type::ServdPollError)
.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("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)
+1 -1
View File
@@ -3835,7 +3835,7 @@ bool Device::formatDisk(const DiskDetails& config, const DiskFormatProgress& han
return com->sendCommand(ExtendedCommand::DiskFormatProgress, {}); return com->sendCommand(ExtendedCommand::DiskFormatProgress, {});
}, },
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::DiskFormatProgress), std::make_shared<ExtendedResponseFilter>(ExtendedCommand::DiskFormatProgress),
std::chrono::milliseconds(1000) std::chrono::milliseconds(5000)
); );
if(!response) { if(!response) {
+4 -4
View File
@@ -235,7 +235,7 @@ bool IDeviceSettings::apply(bool temporary) {
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() { std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
return com->sendCommand(Command::SetSettings, bytestream); return com->sendCommand(Command::SetSettings, bytestream);
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000))); }, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
if(!msg || msg->data[0] != 1) { // We did not receive a response if(!msg || msg->data[0] != 1) { // We did not receive a response
// Attempt to get the settings from the device so we're up to date if possible // Attempt to get the settings from the device so we're up to date if possible
@@ -261,7 +261,7 @@ bool IDeviceSettings::apply(bool temporary) {
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() { msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
return com->sendCommand(Command::SetSettings, bytestream); return com->sendCommand(Command::SetSettings, bytestream);
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000))); }, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
if(!msg || msg->data[0] != 1) { if(!msg || msg->data[0] != 1) {
// Attempt to get the settings from the device so we're up to date if possible // Attempt to get the settings from the device so we're up to date if possible
if(refresh()) { if(refresh()) {
@@ -303,7 +303,7 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() { std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
return com->sendCommand(Command::SetDefaultSettings); return com->sendCommand(Command::SetDefaultSettings);
}, std::make_shared<Main51MessageFilter>(Command::SetDefaultSettings), std::chrono::milliseconds(1000))); }, std::make_shared<Main51MessageFilter>(Command::SetDefaultSettings), std::chrono::milliseconds(5000)));
if(!msg || msg->data[0] != 1) { if(!msg || msg->data[0] != 1) {
// Attempt to get the settings from the device so we're up to date if possible // Attempt to get the settings from the device so we're up to date if possible
if(refresh()) { if(refresh()) {
@@ -338,7 +338,7 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() { msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
return com->sendCommand(Command::SetSettings, bytestream); return com->sendCommand(Command::SetSettings, bytestream);
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000))); }, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
if(!msg || msg->data[0] != 1) { if(!msg || msg->data[0] != 1) {
// Attempt to get the settings from the device so we're up to date if possible // Attempt to get the settings from the device so we're up to date if possible
if(refresh()) { if(refresh()) {
+1 -1
View File
@@ -127,7 +127,7 @@ FlexRay Coldstart Configuration
To use the Coldstart example, ensure the following: To use the Coldstart example, ensure the following:
Set the Flexray network in neoVI Explorer to Coldstart. Set the Flexray network in ICS Device Manager to Coldstart.
No other nodes should be present on the network during testing. No other nodes should be present on the network during testing.
+3
View File
@@ -406,6 +406,9 @@ int main(int argc, char** argv) {
if(it == devices.end()) { if(it == devices.end()) {
std::cerr << "Could not find RAD-A2B." << std::endl; std::cerr << "Could not find RAD-A2B." << std::endl;
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cerr << lastError << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@@ -92,6 +92,9 @@ int main(int argc, const char** argv) {
if(!device) { if(!device) {
std::cerr << "Device with serial " << serial << " not found" << std::endl; std::cerr << "Device with serial " << serial << " not found" << std::endl;
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cerr << lastError << std::endl;
return -1; return -1;
} }
} else { } else {
@@ -99,6 +102,9 @@ int main(int argc, const char** argv) {
auto devices = icsneo::FindAllDevices(); auto devices = icsneo::FindAllDevices();
if(devices.empty()) { if(devices.empty()) {
std::cerr << "No devices found" << std::endl; std::cerr << "No devices found" << std::endl;
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cerr << lastError << std::endl;
return -1; return -1;
} }
device = devices[0]; device = devices[0];
@@ -9,7 +9,7 @@
/* /*
* App errors are responses from the device indicating internal runtime errors * App errors are responses from the device indicating internal runtime errors
* NOTE: To trigger the app error in this example, disable the DW CAN 01 network on the device * NOTE: To trigger the app error in this example, disable the DW CAN 01 network on the device
* (e.g. with neoVI Explorer) * (e.g. with ICS Device Manager)
*/ */
int main() { int main() {
std::cout << "Running libicsneo " << icsneo::GetVersion() << std::endl; std::cout << "Running libicsneo " << icsneo::GetVersion() << std::endl;
@@ -17,6 +17,13 @@ int main() {
auto devices = icsneo::FindAllDevices(); auto devices = icsneo::FindAllDevices();
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 0;
}
// List off the devices // List off the devices
for(auto& device : devices) for(auto& device : devices)
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl; std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
+3
View File
@@ -33,6 +33,9 @@ int main(int argc, char** argv) {
if(it == devices.end()) { if(it == devices.end()) {
std::cout << "Failed to find device." << std::endl; std::cout << "Failed to find device." << std::endl;
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@@ -12,7 +12,9 @@ int main() {
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) { if(devices.empty()) {
std::cout << "error: no devices found" << std::endl; auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return -1; return -1;
} }
@@ -138,6 +138,12 @@ std::vector<std::shared_ptr<icsneo::FlexRayMessage>> makeDummyFlexRayMessages(si
int main() { int main() {
auto devices = icsneo::FindAllDevices(); auto devices = icsneo::FindAllDevices();
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cerr << lastError << std::endl;
return -1;
}
std::shared_ptr<icsneo::Device> flexrayDevice = nullptr; std::shared_ptr<icsneo::Device> flexrayDevice = nullptr;
for (auto&& device : devices) { for (auto&& device : devices) {
if (device->getExtension("FlexRay")) { if (device->getExtension("FlexRay")) {
+7
View File
@@ -15,6 +15,13 @@ int main() {
// You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective // You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 0;
}
// List off the devices // List off the devices
for(auto& device : devices) for(auto& device : devices)
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl; std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
@@ -14,6 +14,13 @@ int main() {
auto devices = icsneo::FindAllDevices(); // This is type std::vector<std::shared_ptr<icsneo::Device>> auto devices = icsneo::FindAllDevices(); // This is type std::vector<std::shared_ptr<icsneo::Device>>
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 0;
}
// List off the devices // List off the devices
for(auto& device : devices) for(auto& device : devices)
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl; std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
+4 -2
View File
@@ -9,8 +9,10 @@ int main(int, char**) {
auto devices = icsneo::FindAllDevices(); auto devices = icsneo::FindAllDevices();
if(devices.size() == 0) { if(devices.empty()) {
std::cout << "No device found" << std::endl; auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return -1; return -1;
} }
+7
View File
@@ -48,6 +48,13 @@ int main()
// You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective // You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 0;
}
// List off the devices // List off the devices
for (auto &device : devices) for (auto &device : devices)
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl; std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
+7
View File
@@ -76,6 +76,13 @@ int main() {
// You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective // You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 0;
}
// List off the devices // List off the devices
for(auto& device : devices) for(auto& device : devices)
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl; std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
+8 -1
View File
@@ -22,6 +22,13 @@ int main() {
// You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective // You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) {
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 0;
}
// List off the devices // List off the devices
for(auto& device : devices) for(auto& device : devices)
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl; std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
@@ -339,7 +346,7 @@ int main() {
if(val.has_value()) if(val.has_value())
std::cout << " - OK (" << val.value() << "V)" << std::endl; std::cout << " - OK (" << val.value() << "V)" << std::endl;
else else
std::cout << " - FAIL, it may need to be enabled in neoVI Explorer (" << icsneo::GetLastError() << ")" << std::endl; std::cout << " - FAIL, it may need to be enabled in ICS Device Manager (" << icsneo::GetLastError() << ")" << std::endl;
} }
} }
+3
View File
@@ -86,6 +86,9 @@ int main(int argc, const char** argv) {
} }
if(!device) { if(!device) {
std::cerr << "Failed to find device" << std::endl; std::cerr << "Failed to find device" << std::endl;
auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cerr << lastError << std::endl;
std::cerr << usage; std::cerr << usage;
return -1; return -1;
} }
+3 -1
View File
@@ -217,7 +217,9 @@ int main() {
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) { if(devices.empty()) {
std::cout << "No devices found!" << std::endl; auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return 1; return 1;
} }
@@ -261,7 +261,9 @@ int main() {
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl; std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
if(devices.empty()) { if(devices.empty()) {
std::cerr << "No devices found!" << std::endl; auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cerr << lastError << std::endl;
return 1; return 1;
} }
+3 -1
View File
@@ -106,7 +106,9 @@ int main(int argc, char* argv[]) {
auto devices = icsneo::FindAllDevices(); auto devices = icsneo::FindAllDevices();
if(devices.empty()) { if(devices.empty()) {
std::cout << "error: no devices found" << std::endl; auto lastError = icsneo::GetLastError();
if(lastError.getType() != icsneo::APIEvent::Type::NoErrorFound)
std::cout << lastError << std::endl;
return -1; return -1;
} }
+1
View File
@@ -165,6 +165,7 @@ public:
ServdPollError = ServdBindError + 8, ServdPollError = ServdBindError + 8,
ServdNoDataError = ServdBindError + 9, ServdNoDataError = ServdBindError + 9,
ServdJoinMulticastError = ServdBindError + 10, ServdJoinMulticastError = ServdBindError + 10,
ServdNotReachable = ServdBindError + 11,
// 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)
+4 -2
View File
@@ -20,7 +20,7 @@ bool Servd::Enabled() {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
return enabled ? enabled[0] == '1' : false; return enabled ? enabled[0] == '1' : true;
} }
std::vector<std::string> split(const std::string_view& str, char delim = ' ') { std::vector<std::string> split(const std::string_view& str, char delim = ' ') {
@@ -52,7 +52,7 @@ void Servd::Find(std::vector<FoundDevice>& found) {
response.resize(512); response.resize(512);
const std::string version_request = SERVD_VERSION_STR + " version"; const std::string version_request = SERVD_VERSION_STR + " version";
if(!socket.transceive(version_request, response, std::chrono::milliseconds(5000))) { if(!socket.transceive(version_request, response, std::chrono::milliseconds(5000))) {
EventManager::GetInstance().add(APIEvent::Type::ServdTransceiveError, APIEvent::Severity::Error); EventManager::GetInstance().add(APIEvent::Type::ServdNotReachable, APIEvent::Severity::Error);
return; return;
} }
@@ -71,7 +71,9 @@ void Servd::Find(std::vector<FoundDevice>& found) {
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()) {
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error); EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
}
continue; continue;
} }
const auto& serial = cols[0]; const auto& serial = cols[0];