mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-09-21 00:18:38 +02:00
Compare commits
12
Commits
d682627b40
...
1.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5620c98eda | ||
|
|
c466d75dae | ||
|
|
d7fc7ffa47 | ||
|
|
70ad76771e | ||
|
|
87c10410e8 | ||
|
|
7cca96dcfb | ||
|
|
d45b72ef68 | ||
|
|
da02927da7 | ||
|
|
b5a6f6ace6 | ||
|
|
0d2bbed7d5 | ||
|
|
a68b64c641 | ||
|
|
9abd9389f4 |
@@ -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/)
|
||||||
|
|||||||
@@ -640,6 +640,46 @@ icsneoc2_error_t icsneoc2_device_supports_tc10(const icsneoc2_device_t* device,
|
|||||||
return icsneoc2_error_success;
|
return icsneoc2_error_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_device_tc10_wake_request(const icsneoc2_device_t* device, icsneoc2_netid_t netid) {
|
||||||
|
auto res = icsneoc2_device_is_valid(device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
if(!device->device->requestTC10Wake(static_cast<Network::NetID>(netid))) {
|
||||||
|
return icsneoc2_error_transmit_message_failed;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_device_tc10_sleep_request(const icsneoc2_device_t* device, icsneoc2_netid_t netid) {
|
||||||
|
auto res = icsneoc2_device_is_valid(device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
if(!device->device->requestTC10Sleep(static_cast<Network::NetID>(netid))) {
|
||||||
|
return icsneoc2_error_transmit_message_failed;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_device_tc10_status_get(const icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_tc10_sleep_status_t* sleep_status, icsneoc2_tc10_wake_status_t* wake_status) {
|
||||||
|
auto res = icsneoc2_device_is_valid(device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
auto cpp_status = device->device->getTC10Status(static_cast<Network::NetID>(netid));
|
||||||
|
if(!cpp_status.has_value()) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if (sleep_status) {
|
||||||
|
*sleep_status = static_cast<icsneoc2_tc10_sleep_status_t>(cpp_status->sleepStatus);
|
||||||
|
}
|
||||||
|
if (wake_status) {
|
||||||
|
*wake_status = static_cast<icsneoc2_tc10_wake_status_t>(cpp_status->wakeStatus);
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
icsneoc2_error_t icsneoc2_device_digital_io_get(const icsneoc2_device_t* device, icsneoc2_io_type_t type, uint32_t number, bool* value) {
|
icsneoc2_error_t icsneoc2_device_digital_io_get(const icsneoc2_device_t* device, icsneoc2_io_type_t type, uint32_t number, bool* value) {
|
||||||
auto res = icsneoc2_device_is_valid(device);
|
auto res = icsneoc2_device_is_valid(device);
|
||||||
if(res != icsneoc2_error_success) {
|
if(res != icsneoc2_error_success) {
|
||||||
|
|||||||
@@ -69,6 +69,14 @@ icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, char* value, si
|
|||||||
return safe_str_copy(value, value_length, netid_str) ? icsneoc2_error_success : icsneoc2_error_string_copy_failed;
|
return safe_str_copy(value, value_length, netid_str) ? icsneoc2_error_success : icsneoc2_error_string_copy_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_netid_network_type_get(icsneoc2_netid_t netid, icsneoc2_network_type_t* network_type) {
|
||||||
|
if(!network_type) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*network_type = static_cast<icsneoc2_network_type_t>(Network::GetTypeOfNetID(static_cast<Network::NetID>(netid), true));
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_message_t* message, icsneoc2_netid_t netid) {
|
icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_message_t* message, icsneoc2_netid_t netid) {
|
||||||
if(!message) {
|
if(!message) {
|
||||||
return icsneoc2_error_invalid_parameters;
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
|||||||
+75
-29
@@ -22,29 +22,6 @@ void APIEvent::init(Type event, APIEvent::Severity severity) {
|
|||||||
eventStruct.timestamp = EventClock::to_time_t(timepoint);
|
eventStruct.timestamp = EventClock::to_time_t(timepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string APIEvent::describe() const noexcept {
|
|
||||||
std::stringstream ss;
|
|
||||||
if(device)
|
|
||||||
ss << *device; // Makes use of device.describe()
|
|
||||||
else
|
|
||||||
ss << "API";
|
|
||||||
|
|
||||||
Severity severity = getSeverity();
|
|
||||||
if(severity == Severity::EventInfo) {
|
|
||||||
ss << " Info: ";
|
|
||||||
} else if(severity == Severity::EventWarning) {
|
|
||||||
ss << " Warning: ";
|
|
||||||
} else if(severity == Severity::Error) {
|
|
||||||
ss << " Error: ";
|
|
||||||
} else {
|
|
||||||
// Should never get here, since Severity::Any should only be used for filtering
|
|
||||||
ss << " Any: ";
|
|
||||||
}
|
|
||||||
|
|
||||||
ss << getDescription();
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void APIEvent::downgradeFromError() noexcept {
|
void APIEvent::downgradeFromError() noexcept {
|
||||||
eventStruct.severity = (uint8_t) APIEvent::Severity::EventWarning;
|
eventStruct.severity = (uint8_t) APIEvent::Severity::EventWarning;
|
||||||
}
|
}
|
||||||
@@ -86,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.";
|
||||||
@@ -118,18 +95,28 @@ static constexpr const char* ATOMIC_OPERATION_COMPLETED_NONATOMICALLY = "An idea
|
|||||||
static constexpr const char* WIVI_STACK_REFRESH_FAILED = "The Wireless neoVI stack encountered a communication error.";
|
static constexpr const char* WIVI_STACK_REFRESH_FAILED = "The Wireless neoVI stack encountered a communication error.";
|
||||||
static constexpr const char* WIVI_UPLOAD_STACK_OVERFLOW = "The Wireless neoVI upload stack has encountered an overflow condition.";
|
static constexpr const char* WIVI_UPLOAD_STACK_OVERFLOW = "The Wireless neoVI upload stack has encountered an overflow condition.";
|
||||||
static constexpr const char* A2B_MESSAGE_INCOMPLETE_FRAME = "At least one of the frames of the A2B message does not contain samples for each channel and stream.";
|
static constexpr const char* A2B_MESSAGE_INCOMPLETE_FRAME = "At least one of the frames of the A2B message does not contain samples for each channel and stream.";
|
||||||
|
static constexpr const char* I2C_MESSAGE_EXCEED_MAX_LENGTH = "The I2C message was too long.";
|
||||||
static constexpr const char* COREMINI_UPLOAD_VERSION_MISMATCH = "The version of the coremini engine on the device and the script uploaded are not the same.";
|
static constexpr const char* COREMINI_UPLOAD_VERSION_MISMATCH = "The version of the coremini engine on the device and the script uploaded are not the same.";
|
||||||
static constexpr const char* DISK_NOT_CONNECTED = "The program tried to access a disk that is not connected.";
|
static constexpr const char* DISK_NOT_CONNECTED = "The program tried to access a disk that is not connected.";
|
||||||
static constexpr const char* UNEXPECTED_RESPONSE = "Received an unexpected or invalid response from the device.";
|
static constexpr const char* UNEXPECTED_RESPONSE = "Received an unexpected or invalid response from the device.";
|
||||||
|
static constexpr const char* LIVE_DATA_INVALID_HANDLE = "The live data handle was invalid.";
|
||||||
|
static constexpr const char* LIVE_DATA_INVALID_COMMAND = "The live data command was invalid.";
|
||||||
|
static constexpr const char* LIVE_DATA_INVALID_ARGUMENT = "The live data argument was invalid.";
|
||||||
|
static constexpr const char* LIVE_DATA_VERSION_MISMATCH = "The live data version between libicsneo and firmware are not the same.";
|
||||||
|
static constexpr const char* LIVE_DATA_NO_DEVICE_RESPONSE = "Expected a response from the device for live data but none were found.";
|
||||||
|
static constexpr const char* LIVE_DATA_MAX_SIGNALS_REACHED = "The max amound of signals to subscribe to for live data has been reached.";
|
||||||
|
static constexpr const char* LIVE_DATA_COMMAND_FAILED = "The live data command failed.";
|
||||||
|
static constexpr const char* LIVE_DATA_ENCODER_ERROR = "Failure to encode live data message.";
|
||||||
|
static constexpr const char* LIVE_DATA_DECODER_ERROR = "Failure to decode live data message.";
|
||||||
|
static constexpr const char* LIVE_DATA_NOT_SUPPORTED = "Live data is not supported on this device.";
|
||||||
static constexpr const char* LIN_SETTINGS_NOT_AVAILABLE = "LIN settings are not available for this device.";
|
static constexpr const char* LIN_SETTINGS_NOT_AVAILABLE = "LIN settings are not available for this device.";
|
||||||
static constexpr const char* MODE_NOT_FOUND = "The mode was not found.";
|
static constexpr const char* MODE_NOT_FOUND = "The mode was not found.";
|
||||||
|
static constexpr const char* APP_ERROR_PARSING_FAILED = "Failure to decode app error message.";
|
||||||
static constexpr const char* GPTP_NOT_SUPPORTED = "GPTP clock synchronization is not supported on this device.";
|
static constexpr const char* GPTP_NOT_SUPPORTED = "GPTP clock synchronization is not supported on this device.";
|
||||||
static constexpr const char* SETTING_NOT_AVAILABLE = "Requested a setting that is not available on this device";
|
static constexpr const char* SETTING_NOT_AVAILABLE = "Requested a setting that is not available on this device";
|
||||||
static constexpr const char* DISK_FORMAT_NOT_SUPPORTED = "Disk formatting is not supported on this device.";
|
static constexpr const char* DISK_FORMAT_NOT_SUPPORTED = "Disk formatting is not supported on this device.";
|
||||||
static constexpr const char* DISK_FORMAT_INVALID_COUNT = "Disk format config disk count is mismatched with device disk count.";
|
static constexpr const char* DISK_FORMAT_INVALID_COUNT = "Disk format config disk count is mismatched with device disk count.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Transport Errors
|
// Transport Errors
|
||||||
static constexpr const char* FAILED_TO_READ = "A read operation failed.";
|
static constexpr const char* FAILED_TO_READ = "A read operation failed.";
|
||||||
static constexpr const char* FAILED_TO_WRITE = "A write operation failed.";
|
static constexpr const char* FAILED_TO_WRITE = "A write operation failed.";
|
||||||
@@ -146,6 +133,7 @@ static constexpr const char* FAILED_TO_BIND = "Unable to bind socket.";
|
|||||||
static constexpr const char* ERROR_SETTING_SOCKET_OPTION = "A call to setsockopt() failed.";
|
static constexpr const char* ERROR_SETTING_SOCKET_OPTION = "A call to setsockopt() failed.";
|
||||||
static constexpr const char* GETIFADDRS_ERROR = "A call to getifaddrs() failed.";
|
static constexpr const char* GETIFADDRS_ERROR = "A call to getifaddrs() failed.";
|
||||||
static constexpr const char* SEND_TO_ERROR = "A call to sendto() failed.";
|
static constexpr const char* SEND_TO_ERROR = "A call to sendto() failed.";
|
||||||
|
static constexpr const char* MDIO_MESSAGE_EXCEED_MAX_LENGTH = "The MDIO message was too long.";
|
||||||
|
|
||||||
// VSA
|
// VSA
|
||||||
static constexpr const char* VSA_BUFFER_CORRUPTED = "VSA data in record buffer is corrupted.";
|
static constexpr const char* VSA_BUFFER_CORRUPTED = "VSA data in record buffer is corrupted.";
|
||||||
@@ -178,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()";
|
||||||
@@ -186,6 +175,7 @@ static constexpr const char* DXX_ERROR_OVERFLOW = "Overflow in DXX";
|
|||||||
static constexpr const char* DXX_ERROR_IO = "I/O failure in DXX";
|
static constexpr const char* DXX_ERROR_IO = "I/O failure in DXX";
|
||||||
static constexpr const char* DXX_ERROR_ARG = "Invalid arg passed to DXX";
|
static constexpr const char* DXX_ERROR_ARG = "Invalid arg passed to DXX";
|
||||||
|
|
||||||
|
static constexpr const char* NO_ERROR_FOUND = "No errors were found.";
|
||||||
static constexpr const char* TOO_MANY_EVENTS = "Too many events have occurred. The list has been truncated.";
|
static constexpr const char* TOO_MANY_EVENTS = "Too many events have occurred. The list has been truncated.";
|
||||||
static constexpr const char* UNKNOWN = "An unknown internal error occurred.";
|
static constexpr const char* UNKNOWN = "An unknown internal error occurred.";
|
||||||
static constexpr const char* INVALID = "An invalid internal error occurred.";
|
static constexpr const char* INVALID = "An invalid internal error occurred.";
|
||||||
@@ -313,6 +303,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return WIVI_STACK_REFRESH_FAILED;
|
return WIVI_STACK_REFRESH_FAILED;
|
||||||
case Type::WiVIUploadStackOverflow:
|
case Type::WiVIUploadStackOverflow:
|
||||||
return WIVI_UPLOAD_STACK_OVERFLOW;
|
return WIVI_UPLOAD_STACK_OVERFLOW;
|
||||||
|
case Type::I2CMessageExceedsMaxLength:
|
||||||
|
return I2C_MESSAGE_EXCEED_MAX_LENGTH;
|
||||||
case Type::A2BMessageIncompleteFrame:
|
case Type::A2BMessageIncompleteFrame:
|
||||||
return A2B_MESSAGE_INCOMPLETE_FRAME;
|
return A2B_MESSAGE_INCOMPLETE_FRAME;
|
||||||
case Type::CoreminiUploadVersionMismatch:
|
case Type::CoreminiUploadVersionMismatch:
|
||||||
@@ -321,10 +313,32 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return DISK_NOT_CONNECTED;
|
return DISK_NOT_CONNECTED;
|
||||||
case Type::UnexpectedResponse:
|
case Type::UnexpectedResponse:
|
||||||
return UNEXPECTED_RESPONSE;
|
return UNEXPECTED_RESPONSE;
|
||||||
|
case Type::LiveDataInvalidHandle:
|
||||||
|
return LIVE_DATA_INVALID_HANDLE;
|
||||||
|
case Type::LiveDataInvalidCommand:
|
||||||
|
return LIVE_DATA_INVALID_COMMAND;
|
||||||
|
case Type::LiveDataInvalidArgument:
|
||||||
|
return LIVE_DATA_INVALID_ARGUMENT;
|
||||||
|
case Type::LiveDataVersionMismatch:
|
||||||
|
return LIVE_DATA_VERSION_MISMATCH;
|
||||||
|
case Type::LiveDataNoDeviceResponse:
|
||||||
|
return LIVE_DATA_NO_DEVICE_RESPONSE;
|
||||||
|
case Type::LiveDataMaxSignalsReached:
|
||||||
|
return LIVE_DATA_MAX_SIGNALS_REACHED;
|
||||||
|
case Type::LiveDataCommandFailed:
|
||||||
|
return LIVE_DATA_COMMAND_FAILED;
|
||||||
|
case Type::LiveDataEncoderError:
|
||||||
|
return LIVE_DATA_ENCODER_ERROR;
|
||||||
|
case Type::LiveDataDecoderError:
|
||||||
|
return LIVE_DATA_DECODER_ERROR;
|
||||||
|
case Type::LiveDataNotSupported:
|
||||||
|
return LIVE_DATA_NOT_SUPPORTED;
|
||||||
case Type::LINSettingsNotAvailable:
|
case Type::LINSettingsNotAvailable:
|
||||||
return LIN_SETTINGS_NOT_AVAILABLE;
|
return LIN_SETTINGS_NOT_AVAILABLE;
|
||||||
case Type::ModeNotFound:
|
case Type::ModeNotFound:
|
||||||
return MODE_NOT_FOUND;
|
return MODE_NOT_FOUND;
|
||||||
|
case Type::AppErrorParsingFailed:
|
||||||
|
return APP_ERROR_PARSING_FAILED;
|
||||||
case Type::SettingNotAvaiableDevice:
|
case Type::SettingNotAvaiableDevice:
|
||||||
return SETTING_NOT_AVAILABLE;
|
return SETTING_NOT_AVAILABLE;
|
||||||
// Transport Errors
|
// Transport Errors
|
||||||
@@ -358,6 +372,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return GETIFADDRS_ERROR;
|
return GETIFADDRS_ERROR;
|
||||||
case Type::SendToError:
|
case Type::SendToError:
|
||||||
return SEND_TO_ERROR;
|
return SEND_TO_ERROR;
|
||||||
|
case Type::MDIOMessageExceedsMaxLength:
|
||||||
|
return MDIO_MESSAGE_EXCEED_MAX_LENGTH;
|
||||||
case Type::GPTPNotSupported:
|
case Type::GPTPNotSupported:
|
||||||
return GPTP_NOT_SUPPORTED;
|
return GPTP_NOT_SUPPORTED;
|
||||||
case Type::DiskFormatNotSupported:
|
case Type::DiskFormatNotSupported:
|
||||||
@@ -423,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:
|
||||||
@@ -437,13 +455,41 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return DXX_ERROR_ARG;
|
return DXX_ERROR_ARG;
|
||||||
|
|
||||||
// Other Errors
|
// Other Errors
|
||||||
|
case Type::NoErrorFound:
|
||||||
|
return NO_ERROR_FOUND;
|
||||||
case Type::TooManyEvents:
|
case Type::TooManyEvents:
|
||||||
return TOO_MANY_EVENTS;
|
return TOO_MANY_EVENTS;
|
||||||
case Type::Unknown:
|
case Type::Unknown:
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
default:
|
|
||||||
return INVALID;
|
|
||||||
}
|
}
|
||||||
|
return INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string APIEvent::describe() const noexcept {
|
||||||
|
std::stringstream ss;
|
||||||
|
if(device)
|
||||||
|
ss << *device; // Makes use of device.describe()
|
||||||
|
else
|
||||||
|
ss << "API";
|
||||||
|
|
||||||
|
Severity severity = getSeverity();
|
||||||
|
if(severity == Severity::EventInfo) {
|
||||||
|
ss << " Info: ";
|
||||||
|
} else if(severity == Severity::EventWarning) {
|
||||||
|
ss << " Warning: ";
|
||||||
|
} else if(severity == Severity::Error) {
|
||||||
|
ss << " Error: ";
|
||||||
|
} else {
|
||||||
|
// Should never get here, since Severity::Any should only be used for filtering
|
||||||
|
ss << " Any: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* description = DescriptionForType(getType());
|
||||||
|
if(description == INVALID)
|
||||||
|
ss << description << " (0x" << std::hex << eventStruct.eventNumber << ")";
|
||||||
|
else
|
||||||
|
ss << description;
|
||||||
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventFilter::match(const APIEvent& event) const noexcept {
|
bool EventFilter::match(const APIEvent& event) const noexcept {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
+36
-9
@@ -285,14 +285,29 @@ int MACsecConfig::addTxSecY(const MACsecTxSecY& secY, uint8_t saIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MACsecConfig::addRxSa(const MACsecRxSa& sa) {
|
int MACsecConfig::addRxSa(const MACsecRxSa& sa) {
|
||||||
|
// Validate AN is in valid range
|
||||||
|
if(sa.an > 3) {
|
||||||
|
ReportEvent(APIEvent::Type::MACsecSaLimit, APIEvent::Severity::Error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we've exceeded the maximum SA count
|
||||||
if(rxSa.size() >= maxSa) {
|
if(rxSa.size() >= maxSa) {
|
||||||
ReportEvent(APIEvent::Type::MACsecSaLimit, APIEvent::Severity::Error);
|
ReportEvent(APIEvent::Type::MACsecSaLimit, APIEvent::Severity::Error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = static_cast<int>(rxSa.size());
|
// Ensure vector is large enough to hold index sa.an (sparse array)
|
||||||
rxSa.emplace_back(sa);
|
// This allows SA index to match the AN value from the MACsec SecTAG
|
||||||
return ret;
|
if(rxSa.size() <= sa.an) {
|
||||||
|
rxSa.resize(sa.an + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark it enabled; padding slots created by resize() above default to enabled=false.
|
||||||
|
rxSa[sa.an] = sa;
|
||||||
|
rxSa[sa.an].enabled = true;
|
||||||
|
|
||||||
|
return sa.an;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MACsecConfig::addTxSa(const MACsecTxSa& sa) {
|
int MACsecConfig::addTxSa(const MACsecTxSa& sa) {
|
||||||
@@ -603,13 +618,23 @@ static void SetHardwareRxSecY(
|
|||||||
hwSc->enable = 0x1u;
|
hwSc->enable = 0x1u;
|
||||||
hwSc->secYIndex = index;
|
hwSc->secYIndex = index;
|
||||||
hwSc->enable_auto_rekey = rekeyEnabled ? 0x1u : 0x0u;
|
hwSc->enable_auto_rekey = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
hwSc->sa_index0 = saIndices.first;
|
|
||||||
hwSc->sa_index1 = saIndices.second;
|
|
||||||
hwSc->sa_index0_in_use = 0x1u;
|
|
||||||
hwSc->sa_index1_in_use = rekeyEnabled ? 0x1u : 0x0u;
|
|
||||||
hwSc->isActiveSA1 = rekeyEnabled ? 0x1u : 0x0u;
|
|
||||||
hwSc->sci = secY.sci;
|
hwSc->sci = secY.sci;
|
||||||
|
|
||||||
|
|
||||||
|
if(saIndices.first & 0x1u) {
|
||||||
|
hwSc->sa_index0 = rekeyEnabled ? saIndices.second : saIndices.first;
|
||||||
|
hwSc->sa_index1 = saIndices.first;
|
||||||
|
hwSc->sa_index0_in_use = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
|
hwSc->sa_index1_in_use = 0x1u;
|
||||||
|
hwSc->isActiveSA1 = rekeyEnabled ? 0x0u : 0x1u;
|
||||||
|
} else {
|
||||||
|
hwSc->sa_index0 = saIndices.first;
|
||||||
|
hwSc->sa_index1 = saIndices.second;
|
||||||
|
hwSc->sa_index0_in_use = 0x1u;
|
||||||
|
hwSc->sa_index1_in_use = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
|
hwSc->isActiveSA1 = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
|
}
|
||||||
|
|
||||||
hwMap->index = index;
|
hwMap->index = index;
|
||||||
hwMap->enable = 0x1u;
|
hwMap->enable = 0x1u;
|
||||||
hwMap->secYIndex = index;
|
hwMap->secYIndex = index;
|
||||||
@@ -638,7 +663,9 @@ static void SetHardwareRxSa(MACSEC_SETTINGS_W_HDR* hwSettings, const MACsecRxSa&
|
|||||||
MACSecSa_t* hwSa = &hwSettings->macsec.rx.sa[index];
|
MACSecSa_t* hwSa = &hwSettings->macsec.rx.sa[index];
|
||||||
|
|
||||||
hwSa->index = index;
|
hwSa->index = index;
|
||||||
hwSa->enable = 0x1u;
|
hwSa->enable = sa.enabled ? 0x1u : 0x0u;
|
||||||
|
if(!sa.enabled)
|
||||||
|
return;
|
||||||
memcpy(hwSa->sak, sa.sak.data(), 32);
|
memcpy(hwSa->sak, sa.sak.data(), 32);
|
||||||
memcpy(hwSa->hashKey, sa.hashKey.data(), 16);
|
memcpy(hwSa->hashKey, sa.hashKey.data(), 16);
|
||||||
memcpy(hwSa->salt, sa.salt.data(), 12);
|
memcpy(hwSa->salt, sa.salt.data(), 12);
|
||||||
|
|||||||
+7
-7
@@ -560,7 +560,7 @@ bool Device::goOnline() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(supportsNetworkMutex()) {
|
if(supportsNetworkMutex) {
|
||||||
assignedClientId = com->getClientIDSync();
|
assignedClientId = com->getClientIDSync();
|
||||||
if(assignedClientId) {
|
if(assignedClientId) {
|
||||||
std::set<Network::NetID> nets;
|
std::set<Network::NetID> nets;
|
||||||
@@ -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) {
|
||||||
@@ -3927,7 +3927,7 @@ std::shared_ptr<DiskDetails> Device::getDiskDetails(std::chrono::milliseconds ti
|
|||||||
|
|
||||||
[[nodiscard]] std::optional<int> Device::lockNetworks(const std::set<Network::NetID>& networks, uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
[[nodiscard]] std::optional<int> Device::lockNetworks(const std::set<Network::NetID>& networks, uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -3977,7 +3977,7 @@ std::shared_ptr<DiskDetails> Device::getDiskDetails(std::chrono::milliseconds ti
|
|||||||
|
|
||||||
bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4017,7 +4017,7 @@ bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
|||||||
|
|
||||||
std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetID network)
|
std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetID network)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -4039,7 +4039,7 @@ std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetI
|
|||||||
|
|
||||||
[[nodiscard]] std::optional<int> Device::lockAllNetworks(uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
[[nodiscard]] std::optional<int> Device::lockAllNetworks(uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -4086,7 +4086,7 @@ std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetI
|
|||||||
|
|
||||||
bool Device::unlockAllNetworks()
|
bool Device::unlockAllNetworks()
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()) {
|
||||||
|
|||||||
@@ -73,3 +73,12 @@ T1S Loopback
|
|||||||
|
|
||||||
.. literalinclude:: ../../examples/c2/t1s_loopback/src/main.c
|
.. literalinclude:: ../../examples/c2/t1s_loopback/src/main.c
|
||||||
:language: c
|
:language: c
|
||||||
|
|
||||||
|
TC10
|
||||||
|
====
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/tc10/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/tc10/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
|||||||
@@ -14,3 +14,18 @@ communication library. The source code for libicsneo can be found on GitHub:
|
|||||||
icsneopy/index
|
icsneopy/index
|
||||||
icsneoc/index
|
icsneoc/index
|
||||||
icsneoc2/index
|
icsneoc2/index
|
||||||
|
|
||||||
|
Linux Installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Applications that use raw Ethernet device discovery, such as PCAP-backed
|
||||||
|
discovery, need permission to open raw network sockets. Instead of running your
|
||||||
|
application with ``sudo``, grant the installed executable the required Linux
|
||||||
|
capabilities:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/your-app
|
||||||
|
|
||||||
|
Replace ``/usr/bin/your-app`` with the full path to the application executable.
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ option(LIBICSNEO_BUILD_C2_LIN_TRANSMIT_EXAMPLE "Build the C2 LIN transmit exampl
|
|||||||
option(LIBICSNEO_BUILD_C2_ETHERNET_TRANSMIT_EXAMPLE "Build the C2 ethernet transmit example." ON)
|
option(LIBICSNEO_BUILD_C2_ETHERNET_TRANSMIT_EXAMPLE "Build the C2 ethernet transmit example." ON)
|
||||||
option(LIBICSNEO_BUILD_C2_ETHERNET_RECEIVE_EXAMPLE "Build the C2 ethernet receive example." ON)
|
option(LIBICSNEO_BUILD_C2_ETHERNET_RECEIVE_EXAMPLE "Build the C2 ethernet receive example." ON)
|
||||||
option(LIBICSNEO_BUILD_C2_T1S_LOOPBACK_EXAMPLE "Build the C2 RAD-Comet3 T1S loopback example." ON)
|
option(LIBICSNEO_BUILD_C2_T1S_LOOPBACK_EXAMPLE "Build the C2 RAD-Comet3 T1S loopback example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_TC10_EXAMPLE "Build the C2 TC10 example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE "Build the simple C++ example." ON)
|
option(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE "Build the simple C++ example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_INTERACTIVE_EXAMPLE "Build the command-line interactive C++ example." ON)
|
option(LIBICSNEO_BUILD_CPP_INTERACTIVE_EXAMPLE "Build the command-line interactive C++ example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_A2B_EXAMPLE "Build the A2B example." ON)
|
option(LIBICSNEO_BUILD_CPP_A2B_EXAMPLE "Build the A2B example." ON)
|
||||||
@@ -82,6 +83,10 @@ if(LIBICSNEO_BUILD_C2_T1S_LOOPBACK_EXAMPLE)
|
|||||||
add_subdirectory(c2/t1s_loopback)
|
add_subdirectory(c2/t1s_loopback)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_TC10_EXAMPLE)
|
||||||
|
add_subdirectory(c2/tc10)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE)
|
if(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE)
|
||||||
add_subdirectory(cpp/simple)
|
add_subdirectory(cpp/simple)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
add_executable(libicsneoc2-tc10-example src/main.c)
|
||||||
|
target_link_libraries(libicsneoc2-tc10-example icsneoc2-static)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(libicsneoc2-tc10-example PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,393 @@
|
|||||||
|
/*
|
||||||
|
* TC10 example.
|
||||||
|
*
|
||||||
|
* Sends TC10 wake/sleep requests, queries TC10 status, or lists connected
|
||||||
|
* devices and the Automotive Ethernet networks they support. Loosely based
|
||||||
|
* on examples/python/tc10/tc10.py. If --serial is omitted, the first
|
||||||
|
* available device is used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <icsneo/icsneoc2.h>
|
||||||
|
#include <icsneo/icsneoc2messages.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char* serial; /* may be NULL */
|
||||||
|
const char** networks; /* points into argv */
|
||||||
|
size_t networks_count;
|
||||||
|
bool send_wake;
|
||||||
|
bool send_sleep;
|
||||||
|
bool status;
|
||||||
|
bool list;
|
||||||
|
} args_t;
|
||||||
|
|
||||||
|
static int print_error_code(const char* message, icsneoc2_error_t error);
|
||||||
|
static void str_tolower(char* s);
|
||||||
|
static bool resolve_netid(const char* name, icsneoc2_netid_t* out);
|
||||||
|
static void print_usage(const char* prog);
|
||||||
|
static int parse_args(int argc, char** argv, args_t* out);
|
||||||
|
static icsneoc2_device_info_t* find_device(icsneoc2_device_info_t* list, const char* serial);
|
||||||
|
static int list_devices(icsneoc2_device_info_t* list);
|
||||||
|
static const char* tc10_wake_status_str(icsneoc2_tc10_wake_status_t s);
|
||||||
|
static const char* tc10_sleep_status_str(icsneoc2_tc10_sleep_status_t s);
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
args_t args;
|
||||||
|
if(parse_args(argc, argv, &args) != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_device_info_t* found_devices = NULL;
|
||||||
|
icsneoc2_error_t res = icsneoc2_device_enumerate(0, &found_devices);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
return print_error_code("Failed to enumerate devices", res);
|
||||||
|
}
|
||||||
|
if(found_devices == NULL) {
|
||||||
|
fprintf(stderr, "error: no devices found\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.list) {
|
||||||
|
int rc = list_devices(found_devices);
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_device_info_t* info = find_device(found_devices, args.serial);
|
||||||
|
if(info == NULL) {
|
||||||
|
fprintf(stderr, "error: unable to find device %s\n", args.serial ? args.serial : "(any)");
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char description[256] = {0};
|
||||||
|
size_t description_len = sizeof(description);
|
||||||
|
res = icsneoc2_device_info_description_get(info, description, &description_len);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return print_error_code("Failed to get device description", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_device_t* device = NULL;
|
||||||
|
res = icsneoc2_device_create(info, &device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return print_error_code("Failed to create device", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Opening device %s\n", description);
|
||||||
|
res = icsneoc2_device_open(device, icsneoc2_open_options_default);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return print_error_code("Failed to open device", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool supports_tc10 = false;
|
||||||
|
res = icsneoc2_device_supports_tc10(device, &supports_tc10);
|
||||||
|
if(res != icsneoc2_error_success || !supports_tc10) {
|
||||||
|
fprintf(stderr, "error: device does not support TC10 (%s)\n", description);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rc = 0;
|
||||||
|
for(size_t i = 0; i < args.networks_count; ++i) {
|
||||||
|
const char* name = args.networks[i];
|
||||||
|
icsneoc2_netid_t netid = icsneoc2_netid_invalid;
|
||||||
|
if(!resolve_netid(name, &netid)) {
|
||||||
|
fprintf(stderr, "error: unknown network '%s'\n", name);
|
||||||
|
rc = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.send_wake) {
|
||||||
|
printf("requesting TC10 wake on network %s\n", name);
|
||||||
|
res = icsneoc2_device_tc10_wake_request(device, netid);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
rc = print_error_code("Failed to send TC10 wake", res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if(args.send_sleep) {
|
||||||
|
printf("requesting TC10 sleep on network %s\n", name);
|
||||||
|
res = icsneoc2_device_tc10_sleep_request(device, netid);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
rc = print_error_code("Failed to send TC10 sleep", res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else { /* args.status */
|
||||||
|
icsneoc2_tc10_sleep_status_t sleep_s = icsneoc2_tc10_sleep_status_no_sleep_received;
|
||||||
|
icsneoc2_tc10_wake_status_t wake_s = icsneoc2_tc10_wake_status_no_wake_received;
|
||||||
|
res = icsneoc2_device_tc10_status_get(device, netid, &sleep_s, &wake_s);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
rc = print_error_code("Failed to get TC10 status", res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("TC10 status on network %s: wake=%s sleep=%s\n", name,
|
||||||
|
tc10_wake_status_str(wake_s), tc10_sleep_status_str(sleep_s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Closing device %s\n", description);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int print_error_code(const char* message, icsneoc2_error_t error) {
|
||||||
|
char error_str[64];
|
||||||
|
size_t error_str_len = sizeof(error_str);
|
||||||
|
icsneoc2_error_t res = icsneoc2_error_code_get(error, error_str, &error_str_len);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
printf("%s: Failed to get string for error code %d with error code %d\n", message, error, res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
printf("%s: \"%s\" (%u)\n", message, error_str, error);
|
||||||
|
return (int)error;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void str_tolower(char* s) {
|
||||||
|
for(; *s; ++s) {
|
||||||
|
*s = (char)tolower((unsigned char)*s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resolve a network name (e.g. "ETHERNET_01", "ae_01") to its icsneoc2_netid_t
|
||||||
|
* by iterating over all known netids and comparing names case-insensitively.
|
||||||
|
*/
|
||||||
|
static bool resolve_netid(const char* name, icsneoc2_netid_t* out) {
|
||||||
|
char want[64];
|
||||||
|
strncpy(want, name, sizeof(want) - 1);
|
||||||
|
want[sizeof(want) - 1] = '\0';
|
||||||
|
str_tolower(want);
|
||||||
|
|
||||||
|
for(uint16_t i = 0; i < icsneoc2_netid_maxsize; ++i) {
|
||||||
|
char buf[64];
|
||||||
|
size_t buf_len = sizeof(buf);
|
||||||
|
if(icsneoc2_netid_name_get((icsneoc2_netid_t)i, buf, &buf_len) != icsneoc2_error_success) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
str_tolower(buf);
|
||||||
|
if(strcmp(buf, want) == 0) {
|
||||||
|
*out = (icsneoc2_netid_t)i;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_usage(const char* prog) {
|
||||||
|
printf("Usage:\n");
|
||||||
|
printf(" %s --list\n", prog);
|
||||||
|
printf(" %s [--serial SERIAL] --networks NET1 [NET2 ...] (--send-wake | --send-sleep | --status)\n", prog);
|
||||||
|
printf("\n");
|
||||||
|
printf(" --list List connected devices and the Automotive Ethernet networks they support.\n");
|
||||||
|
printf(" --serial SERIAL Serial number of the device. If omitted, the first available device is used.\n");
|
||||||
|
printf(" --networks NET ... One or more network names (e.g. ETHERNET_01 AE_01). Consumes args until the next flag.\n");
|
||||||
|
printf(" --send-wake Trigger TC10 wake on the selected networks.\n");
|
||||||
|
printf(" --send-sleep Trigger TC10 sleep on the selected networks.\n");
|
||||||
|
printf(" --status Query TC10 wake/sleep status on the selected networks.\n");
|
||||||
|
printf(" -h, --help Show this message.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_args(int argc, char** argv, args_t* out) {
|
||||||
|
memset(out, 0, sizeof(*out));
|
||||||
|
for(int i = 1; i < argc; ++i) {
|
||||||
|
const char* a = argv[i];
|
||||||
|
if(strcmp(a, "-h") == 0 || strcmp(a, "--help") == 0) {
|
||||||
|
print_usage(argv[0]);
|
||||||
|
exit(0);
|
||||||
|
} else if(strcmp(a, "--serial") == 0) {
|
||||||
|
if(i + 1 >= argc) {
|
||||||
|
fprintf(stderr, "error: --serial requires a value\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
out->serial = argv[++i];
|
||||||
|
} else if(strcmp(a, "--send-wake") == 0) {
|
||||||
|
out->send_wake = true;
|
||||||
|
} else if(strcmp(a, "--send-sleep") == 0) {
|
||||||
|
out->send_sleep = true;
|
||||||
|
} else if(strcmp(a, "--status") == 0) {
|
||||||
|
out->status = true;
|
||||||
|
} else if(strcmp(a, "--list") == 0) {
|
||||||
|
out->list = true;
|
||||||
|
} else if(strcmp(a, "--networks") == 0) {
|
||||||
|
if(i + 1 >= argc || argv[i + 1][0] == '-') {
|
||||||
|
fprintf(stderr, "error: --networks requires at least one network name\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
out->networks = (const char**)&argv[i + 1];
|
||||||
|
size_t count = 0;
|
||||||
|
while(i + 1 < argc && argv[i + 1][0] != '-') {
|
||||||
|
++count;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
out->networks_count = count;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "error: unknown argument '%s'\n", a);
|
||||||
|
print_usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(out->list) {
|
||||||
|
if(out->send_wake || out->send_sleep || out->status || out->networks_count > 0 || out->serial) {
|
||||||
|
fprintf(stderr, "error: --list cannot be combined with other options\n");
|
||||||
|
print_usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(out->networks_count == 0) {
|
||||||
|
fprintf(stderr, "error: --networks is required\n");
|
||||||
|
print_usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int action_count = (out->send_wake ? 1 : 0) + (out->send_sleep ? 1 : 0) + (out->status ? 1 : 0);
|
||||||
|
if(action_count != 1) {
|
||||||
|
fprintf(stderr, "error: exactly one of --send-wake, --send-sleep, or --status is required\n");
|
||||||
|
print_usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* tc10_wake_status_str(icsneoc2_tc10_wake_status_t s) {
|
||||||
|
switch(s) {
|
||||||
|
case icsneoc2_tc10_wake_status_no_wake_received: return "no_wake_received";
|
||||||
|
case icsneoc2_tc10_wake_status_wake_received: return "wake_received";
|
||||||
|
default: return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* tc10_sleep_status_str(icsneoc2_tc10_sleep_status_t s) {
|
||||||
|
switch(s) {
|
||||||
|
case icsneoc2_tc10_sleep_status_no_sleep_received: return "no_sleep_received";
|
||||||
|
case icsneoc2_tc10_sleep_status_sleep_received: return "sleep_received";
|
||||||
|
case icsneoc2_tc10_sleep_status_sleep_failed: return "sleep_failed";
|
||||||
|
case icsneoc2_tc10_sleep_status_sleep_aborted: return "sleep_aborted";
|
||||||
|
default: return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find a device matching the provided serial, or the first available device if serial is NULL.
|
||||||
|
* Returns NULL on failure (caller is responsible for the enumeration list).
|
||||||
|
*/
|
||||||
|
static icsneoc2_device_info_t* find_device(icsneoc2_device_info_t* list, const char* serial) {
|
||||||
|
if(serial == NULL) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
for(icsneoc2_device_info_t* cur = list; cur != NULL; cur = icsneoc2_device_info_next(cur)) {
|
||||||
|
char dev_serial[64] = {0};
|
||||||
|
size_t dev_serial_len = sizeof(dev_serial);
|
||||||
|
if(icsneoc2_device_info_serial_get(cur, dev_serial, &dev_serial_len) != icsneoc2_error_success) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(strcmp(dev_serial, serial) == 0) {
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List connected devices and the Automotive Ethernet networks each one supports.
|
||||||
|
*/
|
||||||
|
static int list_devices(icsneoc2_device_info_t* list) {
|
||||||
|
size_t index = 0;
|
||||||
|
for(icsneoc2_device_info_t* cur = list; cur != NULL; cur = icsneoc2_device_info_next(cur)) {
|
||||||
|
char serial[64] = {0};
|
||||||
|
size_t serial_len = sizeof(serial);
|
||||||
|
(void)icsneoc2_device_info_serial_get(cur, serial, &serial_len);
|
||||||
|
|
||||||
|
char description[256] = {0};
|
||||||
|
size_t description_len = sizeof(description);
|
||||||
|
(void)icsneoc2_device_info_description_get(cur, description, &description_len);
|
||||||
|
|
||||||
|
printf("[%zu] %s (%s)\n", index++, description, serial);
|
||||||
|
|
||||||
|
icsneoc2_device_t* device = NULL;
|
||||||
|
icsneoc2_error_t res = icsneoc2_device_create(cur, &device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
print_error_code(" Failed to create device", res);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_open_options_t options = icsneoc2_open_options_default;
|
||||||
|
options &= ~ICSNEOC2_OPEN_OPTIONS_SYNC_RTC;
|
||||||
|
options &= ~ICSNEOC2_OPEN_OPTIONS_GO_ONLINE;
|
||||||
|
res = icsneoc2_device_open(device, options);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
print_error_code(" Failed to open device", res);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool supports_tc10 = false;
|
||||||
|
(void)icsneoc2_device_supports_tc10(device, &supports_tc10);
|
||||||
|
printf(" TC10 supported: %s\n", supports_tc10 ? "yes" : "no");
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
res = icsneoc2_device_supported_tx_networks_get(device, NULL, &count);
|
||||||
|
if(res != icsneoc2_error_success || count == 0) {
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_netid_t* nets = (icsneoc2_netid_t*)calloc(count, sizeof(icsneoc2_netid_t));
|
||||||
|
if(nets == NULL) {
|
||||||
|
fprintf(stderr, " error: out of memory\n");
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = icsneoc2_device_supported_tx_networks_get(device, nets, &count);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
print_error_code(" Failed to get supported networks", res);
|
||||||
|
free(nets);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" Automotive Ethernet networks:\n");
|
||||||
|
bool any = false;
|
||||||
|
for(size_t i = 0; i < count; ++i) {
|
||||||
|
icsneoc2_network_type_t type = icsneoc2_network_type_invalid;
|
||||||
|
if(icsneoc2_netid_network_type_get(nets[i], &type) != icsneoc2_error_success) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(type != icsneoc2_network_type_automotive_ethernet) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char name[64] = {0};
|
||||||
|
size_t name_len = sizeof(name);
|
||||||
|
if(icsneoc2_netid_name_get(nets[i], name, &name_len) != icsneoc2_error_success) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
printf(" %s\n", name);
|
||||||
|
any = true;
|
||||||
|
}
|
||||||
|
if(!any) {
|
||||||
|
printf(" (none)\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
free(nets);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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")) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,8 +216,10 @@ 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()) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,8 +260,10 @@ 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()) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -4,19 +4,20 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include "icsneo/icsneoc2types.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
enum class TC10WakeStatus : uint8_t {
|
enum class TC10WakeStatus : icsneoc2_tc10_wake_status_t {
|
||||||
NoWakeReceived,
|
NoWakeReceived = icsneoc2_tc10_wake_status_no_wake_received,
|
||||||
WakeReceived,
|
WakeReceived = icsneoc2_tc10_wake_status_wake_received,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TC10SleepStatus : uint8_t {
|
enum class TC10SleepStatus : icsneoc2_tc10_sleep_status_t {
|
||||||
NoSleepReceived,
|
NoSleepReceived = icsneoc2_tc10_sleep_status_no_sleep_received,
|
||||||
SleepReceived,
|
SleepReceived = icsneoc2_tc10_sleep_status_sleep_received,
|
||||||
SleepFailed,
|
SleepFailed = icsneoc2_tc10_sleep_status_sleep_failed,
|
||||||
SleepAborted,
|
SleepAborted = icsneoc2_tc10_sleep_status_sleep_aborted,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ struct MACsecRxSa {
|
|||||||
std::array<uint8_t, 16> hashKey = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; /*!< 128b Hash Key: Key used for authentication. */
|
std::array<uint8_t, 16> hashKey = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; /*!< 128b Hash Key: Key used for authentication. */
|
||||||
std::array<uint8_t, 12> salt = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; /*!< 96b Salt value: Salt value used in XPN ciphers. */
|
std::array<uint8_t, 12> salt = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; /*!< 96b Salt value: Salt value used in XPN ciphers. */
|
||||||
uint32_t ssci = 0x01u; /*!< 32b SSCI value: Short Secure Channel Identifier, used in XPN ciphers. */
|
uint32_t ssci = 0x01u; /*!< 32b SSCI value: Short Secure Channel Identifier, used in XPN ciphers. */
|
||||||
|
uint8_t an = 0x00u; /*!< 2b SecTag Association Number (AN). SA will be placed at this index (0-3). */
|
||||||
uint64_t nextPn = 0x01u; /*!< 64b next_pn value: Next packet number to insert into outgoing packet on a particular SA. */
|
uint64_t nextPn = 0x01u; /*!< 64b next_pn value: Next packet number to insert into outgoing packet on a particular SA. */
|
||||||
|
bool enabled = false; /*!< Set by addRxSa(); slots created by internal padding during sparse placement are left disabled. Do not set this directly. */
|
||||||
};
|
};
|
||||||
|
|
||||||
class MACsecConfig {
|
class MACsecConfig {
|
||||||
|
|||||||
@@ -878,8 +878,6 @@ public:
|
|||||||
bool unlockNetworks(const std::set<Network::NetID>& networks);
|
bool unlockNetworks(const std::set<Network::NetID>& networks);
|
||||||
bool unlockAllNetworks();
|
bool unlockAllNetworks();
|
||||||
std::shared_ptr<NetworkMutexMessage> getNetworkMutexStatus(Network::NetID network);
|
std::shared_ptr<NetworkMutexMessage> getNetworkMutexStatus(Network::NetID network);
|
||||||
|
|
||||||
virtual bool supportsNetworkMutex() const { return false; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool online = false;
|
bool online = false;
|
||||||
@@ -998,6 +996,8 @@ protected:
|
|||||||
|
|
||||||
std::optional<HardwareInfo::Version> bootloaderVersion = std::nullopt;
|
std::optional<HardwareInfo::Version> bootloaderVersion = std::nullopt;
|
||||||
|
|
||||||
|
bool supportsNetworkMutex = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
neodevice_t data;
|
neodevice_t data;
|
||||||
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public:
|
|||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
NeoVIFIRE3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
NeoVIFIRE3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||||
|
supportsNetworkMutex = true;
|
||||||
initialize<NeoVIFIRE3Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
initialize<NeoVIFIRE3Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +124,6 @@ protected:
|
|||||||
size_t getDiskCount() const override {
|
size_t getDiskCount() const override {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supportsNetworkMutex() const override { return true; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
NeoVIFIRE3FlexRay(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
NeoVIFIRE3FlexRay(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||||
|
supportsNetworkMutex = true;
|
||||||
initialize<NeoVIFIRE3FlexRaySettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
initialize<NeoVIFIRE3FlexRaySettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +151,6 @@ protected:
|
|||||||
size_t getDiskCount() const override {
|
size_t getDiskCount() const override {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supportsNetworkMutex() const override { return true; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public:
|
|||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
NeoVIFIRE3T1SLIN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
NeoVIFIRE3T1SLIN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||||
|
supportsNetworkMutex = true;
|
||||||
initialize<NeoVIFIRE3T1SLINSettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
initialize<NeoVIFIRE3T1SLINSettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,10 +133,6 @@ protected:
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supportsNetworkMutex() const override {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
NeoVIRED2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
NeoVIRED2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||||
|
supportsNetworkMutex = true;
|
||||||
initialize<NeoVIRED2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
initialize<NeoVIRED2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +105,6 @@ protected:
|
|||||||
size_t getDiskCount() const override {
|
size_t getDiskCount() const override {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supportsNetworkMutex() const override { return true; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -473,6 +473,37 @@ icsneoc2_error_t icsneoc2_device_rtc_set(const icsneoc2_device_t* device, int64_
|
|||||||
*/
|
*/
|
||||||
icsneoc2_error_t icsneoc2_device_supports_tc10(const icsneoc2_device_t* device, bool* supported);
|
icsneoc2_error_t icsneoc2_device_supports_tc10(const icsneoc2_device_t* device, bool* supported);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a TC10 wake request to the device on a specific network. This is used to wake up ECUs that support TC10 wake on the specified network.
|
||||||
|
*
|
||||||
|
* @param[in] device The device to send the wake request from.
|
||||||
|
* @param[in] netid The network to send the wake request on.
|
||||||
|
*
|
||||||
|
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_transmit_message_failed otherwise.
|
||||||
|
*/
|
||||||
|
icsneoc2_error_t icsneoc2_device_tc10_wake_request(const icsneoc2_device_t* device, icsneoc2_netid_t netid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a TC10 sleep request to the device on a specific network. This is used to put ECUs that support TC10 sleep on the specified network to sleep.
|
||||||
|
*
|
||||||
|
* @param[in] device The device to send the sleep request from.
|
||||||
|
* @param[in] netid The network to send the sleep request on.
|
||||||
|
*
|
||||||
|
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_transmit_message_failed otherwise.
|
||||||
|
*/
|
||||||
|
icsneoc2_error_t icsneoc2_device_tc10_sleep_request(const icsneoc2_device_t* device, icsneoc2_netid_t netid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current TC10 sleep/wake status of a specific network.
|
||||||
|
*
|
||||||
|
* @param[in] device The device to query.
|
||||||
|
* @param[in] netid The network to query the TC10 status of.
|
||||||
|
* @param[out] sleep_status Pointer to a icsneoc2_tc10_sleep_status_t to copy the sleep status into. May be NULL if sleep status is not needed.
|
||||||
|
* @param[out] wake_status Pointer to a icsneoc2_tc10_wake_status_t to copy the wake status into. May be NULL if wake status is not needed.
|
||||||
|
*
|
||||||
|
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||||
|
*/
|
||||||
|
icsneoc2_error_t icsneoc2_device_tc10_status_get(const icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_tc10_sleep_status_t* sleep_status, icsneoc2_tc10_wake_status_t* wake_status);
|
||||||
/**
|
/**
|
||||||
* Get the current state of a digital I/O pin.
|
* Get the current state of a digital I/O pin.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -75,6 +75,18 @@ icsneoc2_error_t icsneoc2_message_netid_get(icsneoc2_message_t* message, icsneoc
|
|||||||
*/
|
*/
|
||||||
icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, char* value, size_t* value_length);
|
icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, char* value, size_t* value_length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the network type for a icsneoc2_netid_t.
|
||||||
|
*
|
||||||
|
* @param[in] netid The network id to get the type of.
|
||||||
|
* @param[out] network_type Pointer to a icsneoc2_network_type_t to copy the network type into.
|
||||||
|
*
|
||||||
|
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||||
|
*
|
||||||
|
* @see icsneoc2_network_type_t, icsneoc2_network_type_name_get
|
||||||
|
*/
|
||||||
|
icsneoc2_error_t icsneoc2_netid_network_type_get(icsneoc2_netid_t netid, icsneoc2_network_type_t* network_type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Network ID (netid) of a bus message
|
* Set the Network ID (netid) of a bus message
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -422,6 +422,28 @@ typedef uint8_t icsneoc2_can_error_code_t;
|
|||||||
|
|
||||||
typedef uint64_t icsneoc2_message_can_error_flags_t;
|
typedef uint64_t icsneoc2_message_can_error_flags_t;
|
||||||
|
|
||||||
|
typedef enum _icsneoc2_tc10_wake_status_t {
|
||||||
|
icsneoc2_tc10_wake_status_no_wake_received = 0, // No wake signal received
|
||||||
|
icsneoc2_tc10_wake_status_wake_received = 1, // Wake signal received
|
||||||
|
|
||||||
|
// Must be last entry. Don't use as a TC10 wake status.
|
||||||
|
icsneoc2_tc10_wake_status_maxsize
|
||||||
|
} _icsneoc2_tc10_wake_status_t;
|
||||||
|
|
||||||
|
typedef uint8_t icsneoc2_tc10_wake_status_t;
|
||||||
|
|
||||||
|
typedef enum _icsneoc2_tc10_sleep_status_t {
|
||||||
|
icsneoc2_tc10_sleep_status_no_sleep_received = 0, // No sleep signal received
|
||||||
|
icsneoc2_tc10_sleep_status_sleep_received = 1, // Sleep signal received
|
||||||
|
icsneoc2_tc10_sleep_status_sleep_failed = 2, // Sleep attempt failed
|
||||||
|
icsneoc2_tc10_sleep_status_sleep_aborted = 3, // Sleep attempt aborted
|
||||||
|
|
||||||
|
// Must be last entry. Don't use as a TC10 sleep status.
|
||||||
|
icsneoc2_tc10_sleep_status_maxsize
|
||||||
|
} _icsneoc2_tc10_sleep_status_t;
|
||||||
|
|
||||||
|
typedef uint8_t icsneoc2_tc10_sleep_status_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+5
-3
@@ -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) {
|
||||||
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
|
if(!line.empty()) {
|
||||||
|
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto& serial = cols[0];
|
const auto& serial = cols[0];
|
||||||
|
|||||||
@@ -180,6 +180,15 @@ TEST(icsneoc2, test_icsneoc2_error_invalid_parameters_and_invalid_device)
|
|||||||
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_pcb_serial_get(NULL, &placeholderInteger8, &placeholderSizeT));
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_pcb_serial_get(NULL, &placeholderInteger8, &placeholderSizeT));
|
||||||
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_mac_address_get(NULL, &placeholderInteger8, &placeholderSizeT));
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_mac_address_get(NULL, &placeholderInteger8, &placeholderSizeT));
|
||||||
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supports_tc10(NULL, &placeholderBool));
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supports_tc10(NULL, &placeholderBool));
|
||||||
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_tc10_wake_request(NULL, icsneoc2_netid_dwcan_01));
|
||||||
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_tc10_sleep_request(NULL, icsneoc2_netid_dwcan_01));
|
||||||
|
{
|
||||||
|
icsneoc2_tc10_sleep_status_t sleep_s = icsneoc2_tc10_sleep_status_no_sleep_received;
|
||||||
|
icsneoc2_tc10_wake_status_t wake_s = icsneoc2_tc10_wake_status_no_wake_received;
|
||||||
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_tc10_status_get(NULL, icsneoc2_netid_dwcan_01, &sleep_s, &wake_s));
|
||||||
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_tc10_status_get(NULL, icsneoc2_netid_dwcan_01, NULL, NULL));
|
||||||
|
}
|
||||||
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_netid_network_type_get(icsneoc2_netid_dwcan_01, NULL));
|
||||||
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_timestamp_resolution_get(NULL, &placeholderInteger32));
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_timestamp_resolution_get(NULL, &placeholderInteger32));
|
||||||
|
|
||||||
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_digital_io_get(NULL, 0, 0, &placeholderBool));
|
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_digital_io_get(NULL, 0, 0, &placeholderBool));
|
||||||
@@ -477,6 +486,60 @@ TEST(icsneoc2, icsneoc2_network_type_t)
|
|||||||
ASSERT_EQ(sizeof(icsneoc2_network_type_t), sizeof(uint8_t));
|
ASSERT_EQ(sizeof(icsneoc2_network_type_t), sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(icsneoc2, test_icsneoc2_netid_network_type_get)
|
||||||
|
{
|
||||||
|
icsneoc2_network_type_t type = icsneoc2_network_type_invalid;
|
||||||
|
|
||||||
|
// CAN
|
||||||
|
ASSERT_EQ(icsneoc2_error_success, icsneoc2_netid_network_type_get(icsneoc2_netid_dwcan_01, &type));
|
||||||
|
ASSERT_EQ(icsneoc2_network_type_can, type);
|
||||||
|
|
||||||
|
// LIN
|
||||||
|
type = icsneoc2_network_type_invalid;
|
||||||
|
ASSERT_EQ(icsneoc2_error_success, icsneoc2_netid_network_type_get(icsneoc2_netid_lin_01, &type));
|
||||||
|
ASSERT_EQ(icsneoc2_network_type_lin, type);
|
||||||
|
|
||||||
|
// Ethernet
|
||||||
|
type = icsneoc2_network_type_invalid;
|
||||||
|
ASSERT_EQ(icsneoc2_error_success, icsneoc2_netid_network_type_get(icsneoc2_netid_ethernet_01, &type));
|
||||||
|
ASSERT_EQ(icsneoc2_network_type_ethernet, type);
|
||||||
|
|
||||||
|
// Automotive Ethernet
|
||||||
|
type = icsneoc2_network_type_invalid;
|
||||||
|
ASSERT_EQ(icsneoc2_error_success, icsneoc2_netid_network_type_get(icsneoc2_netid_ae_01, &type));
|
||||||
|
ASSERT_EQ(icsneoc2_network_type_automotive_ethernet, type);
|
||||||
|
|
||||||
|
// SWCAN
|
||||||
|
type = icsneoc2_network_type_invalid;
|
||||||
|
ASSERT_EQ(icsneoc2_error_success, icsneoc2_netid_network_type_get(icsneoc2_netid_swcan_01, &type));
|
||||||
|
ASSERT_EQ(icsneoc2_network_type_swcan, type);
|
||||||
|
|
||||||
|
// LSFTCAN
|
||||||
|
type = icsneoc2_network_type_invalid;
|
||||||
|
ASSERT_EQ(icsneoc2_error_success, icsneoc2_netid_network_type_get(icsneoc2_netid_lsftcan_01, &type));
|
||||||
|
ASSERT_EQ(icsneoc2_network_type_lsftcan, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(icsneoc2, test_icsneoc2_tc10_wake_status_t)
|
||||||
|
{
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_wake_status_no_wake_received, 0);
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_wake_status_wake_received, 1);
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_wake_status_maxsize, 2);
|
||||||
|
|
||||||
|
ASSERT_EQ(sizeof(icsneoc2_tc10_wake_status_t), sizeof(uint8_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(icsneoc2, test_icsneoc2_tc10_sleep_status_t)
|
||||||
|
{
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_sleep_status_no_sleep_received, 0);
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_sleep_status_sleep_received, 1);
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_sleep_status_sleep_failed, 2);
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_sleep_status_sleep_aborted, 3);
|
||||||
|
ASSERT_EQ(icsneoc2_tc10_sleep_status_maxsize, 4);
|
||||||
|
|
||||||
|
ASSERT_EQ(sizeof(icsneoc2_tc10_sleep_status_t), sizeof(uint8_t));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(icsneoc2, test_icsneoc2_io_type_t)
|
TEST(icsneoc2, test_icsneoc2_io_type_t)
|
||||||
{
|
{
|
||||||
ASSERT_EQ(icsneoc2_io_type_eth_activation, 0);
|
ASSERT_EQ(icsneoc2_io_type_eth_activation, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user