API: Add icsneoc2

master
Thomas Stoddard 2026-03-25 01:08:40 +00:00 committed by Kyle Schwarz
parent 294e707924
commit 682299cb8c
40 changed files with 9015 additions and 369 deletions

View File

@ -11,6 +11,8 @@ option(LIBICSNEO_BUILD_DOCS "Build documentation. Don't use in Visual Studio." O
option(LIBICSNEO_BUILD_EXAMPLES "Build examples." ON) option(LIBICSNEO_BUILD_EXAMPLES "Build examples." ON)
option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON) option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON)
option(LIBICSNEO_BUILD_ICSNEOC_STATIC "Build static C library" ON) option(LIBICSNEO_BUILD_ICSNEOC_STATIC "Build static C library" ON)
option(LIBICSNEO_BUILD_ICSNEOC2 "Build dynamic C2 library" ON)
option(LIBICSNEO_BUILD_ICSNEOC2_STATIC "Build static C2 library" ON)
option(LIBICSNEO_BUILD_ICSNEOLEGACY "Build icsnVC40 compatibility library" ON) option(LIBICSNEO_BUILD_ICSNEOLEGACY "Build icsnVC40 compatibility library" ON)
option(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC "Build static icsnVC40 compatibility library" ON) option(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC "Build static icsnVC40 compatibility library" ON)
set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to build with Npcap") set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to build with Npcap")
@ -170,10 +172,6 @@ if(LIBICSNEO_ENABLE_TCP)
) )
endif() endif()
if(LIBICSNEO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Extensions # Extensions
set(LIBICSNEO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBICSNEO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
foreach(EXT_PATH ${LIBICSNEO_EXTENSION_DIRS}) foreach(EXT_PATH ${LIBICSNEO_EXTENSION_DIRS})
@ -289,6 +287,7 @@ endif()
configure_file(api/icsneocpp/buildinfo.h.template ${CMAKE_CURRENT_BINARY_DIR}/generated/buildinfo.h) configure_file(api/icsneocpp/buildinfo.h.template ${CMAKE_CURRENT_BINARY_DIR}/generated/buildinfo.h)
configure_file(api/icsneoc/version.rc.template ${CMAKE_CURRENT_BINARY_DIR}/generated/icsneoc/version.rc) configure_file(api/icsneoc/version.rc.template ${CMAKE_CURRENT_BINARY_DIR}/generated/icsneoc/version.rc)
configure_file(api/icsneoc2/version.rc.template ${CMAKE_CURRENT_BINARY_DIR}/generated/icsneoc2/version.rc)
foreach(EXTINC ${LIBICSNEO_EXTENSION_INCLUDES}) foreach(EXTINC ${LIBICSNEO_EXTENSION_INCLUDES})
message("Including " ${EXTINC}) message("Including " ${EXTINC})
@ -426,6 +425,38 @@ if(LIBICSNEO_BUILD_ICSNEOC_STATIC)
target_compile_options(icsneoc-static PRIVATE ${LIBICSNEO_COMPILER_WARNINGS}) target_compile_options(icsneoc-static PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
endif() endif()
if(LIBICSNEO_BUILD_ICSNEOC2)
add_library(icsneoc2 SHARED api/icsneoc2/icsneoc2.cpp api/icsneoc2/icsneoc2settings.cpp api/icsneoc2/icsneoc2messages.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated/icsneoc2/version.rc)
target_include_directories(icsneoc2
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(icsneoc2 PRIVATE icsneocpp)
target_compile_features(icsneoc2 PRIVATE cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums)
target_compile_options(icsneoc2 PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
if(WIN32)
set_target_properties(icsneoc2 PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
endif()
if(LIBICSNEO_BUILD_ICSNEOC2_STATIC)
add_library(icsneoc2-static STATIC api/icsneoc2/icsneoc2.cpp api/icsneoc2/icsneoc2settings.cpp api/icsneoc2/icsneoc2messages.cpp)
target_include_directories(icsneoc2-static
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(icsneoc2-static PUBLIC icsneocpp)
target_compile_features(icsneoc2-static PUBLIC cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums)
target_compile_definitions(icsneoc2-static PUBLIC ICSNEOC2_BUILD_STATIC)
target_compile_options(icsneoc2-static PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
endif()
if(LIBICSNEO_BUILD_ICSNEOLEGACY) if(LIBICSNEO_BUILD_ICSNEOLEGACY)
add_library(icsneolegacy SHARED add_library(icsneolegacy SHARED
api/icsneolegacy/icsneolegacy.cpp api/icsneolegacy/icsneolegacy.cpp
@ -467,6 +498,10 @@ endif()
add_subdirectory(bindings) add_subdirectory(bindings)
if(LIBICSNEO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# googletest # googletest
if(LIBICSNEO_BUILD_UNIT_TESTS) if(LIBICSNEO_BUILD_UNIT_TESTS)
include(FetchContent) include(FetchContent)
@ -475,6 +510,7 @@ if(LIBICSNEO_BUILD_UNIT_TESTS)
GIT_TAG 6986c2b575f77135401a4e1c65a7a42f20e18fef GIT_TAG 6986c2b575f77135401a4e1c65a7a42f20e18fef
) )
FetchContent_MakeAvailable(googletest) FetchContent_MakeAvailable(googletest)
include(GoogleTest)
add_executable(libicsneo-unit-tests add_executable(libicsneo-unit-tests
test/unit/main.cpp test/unit/main.cpp
@ -489,6 +525,7 @@ if(LIBICSNEO_BUILD_UNIT_TESTS)
test/unit/livedataencoderdecodertest.cpp test/unit/livedataencoderdecodertest.cpp
test/unit/ringbuffertest.cpp test/unit/ringbuffertest.cpp
test/unit/apperrordecodertest.cpp test/unit/apperrordecodertest.cpp
test/unit/icsneoc2.cpp
test/unit/windowsstrings.cpp test/unit/windowsstrings.cpp
test/unit/periodictest.cpp test/unit/periodictest.cpp
) )
@ -497,12 +534,13 @@ if(LIBICSNEO_BUILD_UNIT_TESTS)
target_link_libraries(libicsneo-unit-tests gtest gtest_main) target_link_libraries(libicsneo-unit-tests gtest gtest_main)
target_link_libraries(libicsneo-unit-tests icsneocpp) target_link_libraries(libicsneo-unit-tests icsneocpp)
target_link_libraries(libicsneo-unit-tests icsneoc2-static)
target_include_directories(libicsneo-unit-tests PUBLIC ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) target_include_directories(libicsneo-unit-tests PUBLIC ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
enable_testing() enable_testing()
add_test(NAME libicsneo-unit-test-suite COMMAND libicsneo-unit-tests) gtest_discover_tests(libicsneo-unit-tests TEST_PREFIX "unit/" PROPERTIES LABELS "unit")
endif() endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_NAME ${PROJECT_NAME})

View File

@ -8,7 +8,8 @@ each of the respective APIs.
- [C++](https://libicsneo.readthedocs.io/en/latest/icsneocpp/) - [C++](https://libicsneo.readthedocs.io/en/latest/icsneocpp/)
- [Python](https://libicsneo.readthedocs.io/en/latest/icsneopy/) - [Python](https://libicsneo.readthedocs.io/en/latest/icsneopy/)
- [C](https://libicsneo.readthedocs.io/en/latest/icsneoc/) - [C](https://libicsneo.readthedocs.io/en/latest/icsneoc/) (deprecated, use C2)
- [C2](https://libicsneo.readthedocs.io/en/latest/icsneoc2/)
## Hardware Support ## Hardware Support

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
// This header is for internal icsneoc2 use only, it should not be included by users of the API.
#pragma once
#include "icsneo/icsneoc2.h"
#include "icsneo/device/device.h"
#include "icsneo/communication/message/message.h"
#include "icsneo/communication/message/scriptstatusmessage.h"
#include "icsneo/api/event.h"
#include "icsneo/disk/diskdetails.h"
#include <memory>
#include <vector>
using namespace icsneo;
typedef struct icsneoc2_message_t {
std::shared_ptr<Message> message;
} icsneoc2_message_t;
typedef struct icsneoc2_event_t {
APIEvent event;
} icsneoc2_event_t;
typedef struct icsneoc2_device_info_t {
std::shared_ptr<Device> device;
icsneoc2_device_info_t* next;
} icsneoc2_device_info_t;
typedef struct icsneoc2_device_t {
std::shared_ptr<Device> device;
} icsneoc2_device_t;
typedef struct icsneoc2_disk_details_t {
std::shared_ptr<DiskDetails> details;
} icsneoc2_disk_details_t;
typedef struct icsneoc2_script_status_t {
std::shared_ptr<ScriptStatusMessage> status;
} icsneoc2_script_status_t;
/**
* Safely copies a std::string to a char array.
*
* @param dest The buffer to copy the string into
* @param dest_size* The size of the buffer. Will be modified to the length of the string without the null terminator.
* @param src The string to copy
*
* @return true if the string was successfully copied, false otherwise
*
* @note This function always null terminates the buffer, even if the string is too long.
* In the case of truncation, dest_size will reflect the truncated length (not including the null terminator).
*/
bool safe_str_copy(char* dest, size_t* dest_size, std::string_view src);

View File

@ -0,0 +1,218 @@
#include "icsneo/icsneoc2messages.h" // TODO: Remove this after the complete refactor
#include "icsneo/icsneoc2.h"
#include "icsneoc2_internal.h"
#include "icsneo/icsneocpp.h"
#include "icsneo/communication/message/message.h"
#include "icsneo/communication/message/canmessage.h"
#include "icsneo/communication/message/linmessage.h"
#include "icsneo/communication/message/ethernetmessage.h"
#include "icsneo/communication/packet/canpacket.h"
icsneoc2_error_t icsneoc2_message_is_valid(icsneoc2_message_t* message, bool* is_valid) {
if(!message || !is_valid) {
return icsneoc2_error_invalid_parameters;
}
*is_valid = (bool)message->message;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_is_transmit(icsneoc2_message_t* message, bool* value) {
if(!message || !value) {
return icsneoc2_error_invalid_parameters;
}
// We can static cast here because we are relying on the type being correct at this point
auto frame = std::dynamic_pointer_cast<Frame>(message->message);
if(!frame) {
return icsneoc2_error_invalid_type;
}
*value = frame->transmitted;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_netid_get(icsneoc2_message_t* message, icsneoc2_netid_t* netid) {
if(!message || !netid) {
return icsneoc2_error_invalid_parameters;
}
auto raw = std::dynamic_pointer_cast<RawMessage>(message->message);
if(!raw) {
return icsneoc2_error_invalid_type;
}
*netid = static_cast<icsneoc2_netid_t>(raw->network.getNetID());
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, char* value, size_t* value_length) {
if(!value || !value_length) {
return icsneoc2_error_invalid_parameters;
}
auto netid_str = std::string(Network::GetNetIDString(static_cast<Network::NetID>(netid), true));
// Copy the string into value
return safe_str_copy(value, value_length, netid_str) ? icsneoc2_error_success : icsneoc2_error_string_copy_failed;
}
icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_message_t* message, icsneoc2_netid_t netid) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
auto raw = std::dynamic_pointer_cast<RawMessage>(message->message);
if(!raw) {
return icsneoc2_error_invalid_type;
}
raw->network = Network(static_cast<neonetid_t>(netid), true);
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_data_set(icsneoc2_message_t* message, uint8_t* data, size_t data_length) {
if(!message || !data) {
return icsneoc2_error_invalid_parameters;
}
// Make sure the message has the data field (RawMessage or Frame)
auto raw_message = std::dynamic_pointer_cast<RawMessage>(message->message);
if(!raw_message) {
return icsneoc2_error_invalid_type;
}
raw_message->data.resize(data_length);
std::copy(data, data + data_length, raw_message->data.begin());
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_data_get(icsneoc2_message_t* message, uint8_t* data, size_t* data_length) {
if(!message || !data_length) {
return icsneoc2_error_invalid_parameters;
}
// Make sure the message has the data field (RawMessage or Frame)
auto raw_message = std::dynamic_pointer_cast<RawMessage>(message->message);
if(!raw_message) {
return icsneoc2_error_invalid_type;
}
if(!data) {
*data_length = raw_message->data.size();
return icsneoc2_error_success;
}
if(*data_length < raw_message->data.size()) {
return icsneoc2_error_invalid_parameters;
}
std::copy(raw_message->data.begin(), raw_message->data.begin() + raw_message->data.size(), data);
*data_length = raw_message->data.size();
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_can_create(icsneoc2_message_t** message) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
try {
*message = new icsneoc2_message_t;
// Initialize the internal message as a CANMessage so that all icsneoc2_message_can_*_set
// functions work correctly on user-created transmit messages.
(*message)->message = std::make_shared<CANMessage>();
} catch(const std::bad_alloc&) {
return icsneoc2_error_out_of_memory;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_free(icsneoc2_message_t* message) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
delete message;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_can_props_set(icsneoc2_message_t* message, const uint64_t* arb_id, const uint64_t* flags) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
auto can_msg = std::dynamic_pointer_cast<CANMessage>(message->message);
if(!can_msg) {
return icsneoc2_error_invalid_type;
}
if(arb_id) {
can_msg->arbid = static_cast<uint32_t>(*arb_id);
}
if(flags) {
can_msg->isRemote = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_RTR);
can_msg->isExtended = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_IDE);
can_msg->isCANFD = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_FDF);
can_msg->baudrateSwitch = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_BRS);
can_msg->errorStateIndicator = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_ESI);
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_can_props_get(icsneoc2_message_t* message, uint64_t* arb_id, uint64_t* flags) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
auto can_msg = std::dynamic_pointer_cast<CANMessage>(message->message);
if(!can_msg) {
return icsneoc2_error_invalid_type;
}
if(arb_id) {
*arb_id = can_msg->arbid;
}
if(flags) {
*flags = 0;
if(can_msg->isRemote) {
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_RTR;
}
if(can_msg->isExtended) {
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_IDE;
}
if(can_msg->isCANFD) {
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_FDF;
}
if(can_msg->baudrateSwitch) {
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_BRS;
}
if(can_msg->errorStateIndicator) {
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_ESI;
}
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_network_type_get(icsneoc2_message_t* message, icsneoc2_network_type_t* network_type) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
auto raw = std::dynamic_pointer_cast<RawMessage>(message->message);
if(!raw) {
return icsneoc2_error_invalid_type;
}
*network_type = (icsneoc2_network_type_t)raw->network.getType();
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_is_raw(icsneoc2_message_t* message, bool* is_raw) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
*is_raw = std::dynamic_pointer_cast<RawMessage>(message->message) != nullptr;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_is_frame(icsneoc2_message_t* message, bool* is_frame) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
*is_frame = std::dynamic_pointer_cast<Frame>(message->message) != nullptr;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_message_is_can(icsneoc2_message_t* message, bool* is_can) {
if(!message) {
return icsneoc2_error_invalid_parameters;
}
*is_can = std::dynamic_pointer_cast<CANMessage>(message->message) != nullptr;
return icsneoc2_error_success;
}

View File

@ -0,0 +1,684 @@
#include "icsneo/icsneoc2.h"
#include "icsneo/icsneoc2settings.h"
#include "icsneo/device/device.h"
#include "icsneo/device/devicefinder.h"
#include "icsneo/icsneocpp.h"
#include "icsneo/communication/message/message.h"
#include "icsneo/communication/message/canmessage.h"
#include "icsneo/communication/message/linmessage.h"
#include "icsneo/communication/message/ethernetmessage.h"
#include "icsneo/communication/packet/canpacket.h"
#include "icsneo/communication/io.h"
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <optional>
#include <sstream>
using namespace icsneo;
#include "icsneoc2_internal.h"
icsneoc2_error_t icsneoc2_settings_apply_defaults(icsneoc2_device_t* device, bool save) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->applyDefaults(!save)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_apply(icsneoc2_device_t* device) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->apply()) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_refresh(icsneoc2_device_t* device) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->refresh()) {
return icsneoc2_error_get_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t* baudrate) {
if(!baudrate) {
return icsneoc2_error_invalid_parameters;
}
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto baudrate_value = device->device->settings->getBaudrateFor(Network(netid));
if(baudrate_value < 0) {
*baudrate = 0;
return icsneoc2_error_invalid_type;
}
*baudrate = baudrate_value;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t baudrate) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setBaudrateFor(Network(netid), baudrate)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_canfd_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t* baudrate) {
if(!baudrate) {
return icsneoc2_error_invalid_parameters;
}
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
*baudrate = device->device->settings->getFDBaudrateFor(Network(netid));
if(*baudrate < 0) {
*baudrate = 0;
return icsneoc2_error_invalid_type;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_canfd_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t baudrate) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setFDBaudrateFor(Network(netid), baudrate)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_termination_is_supported(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* supported) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!supported) {
return icsneoc2_error_invalid_parameters;
}
*supported = device->device->settings->isTerminationSupportedFor(Network(static_cast<Network::NetID>(netid)));
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_termination_can_enable(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* can_enable) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!can_enable) {
return icsneoc2_error_invalid_parameters;
}
*can_enable = device->device->settings->canTerminationBeEnabledFor(Network(static_cast<Network::NetID>(netid)));
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_termination_is_enabled(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* enabled) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!enabled) {
return icsneoc2_error_invalid_parameters;
}
*enabled = device->device->settings->isTerminationEnabledFor(Network(static_cast<Network::NetID>(netid))).value_or(false);
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_termination_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool enable) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setTerminationFor(Network(static_cast<Network::NetID>(netid)), enable)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_commander_resistor_enabled(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* enabled) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!enabled) {
return icsneoc2_error_invalid_parameters;
}
*enabled = device->device->settings->isCommanderResistorEnabledFor(Network(static_cast<Network::NetID>(netid))).value_or(false);
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_commander_resistor_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool enable) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setCommanderResistorFor(Network(static_cast<Network::NetID>(netid)), enable)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_lin_mode_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_lin_mode_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getLINModeFor(network); result.has_value()) {
*value = static_cast<icsneoc2_lin_mode_t>(result.value());
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_lin_mode_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_lin_mode_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setLINModeFor(network, static_cast<LINMode>(value))) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_lin_commander_response_time_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getLINCommanderResponseTimeFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_lin_commander_response_time_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setLINCommanderResponseTimeFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_phy_enable_get(icsneoc2_device_t* device, uint8_t index, bool* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
if(auto result = device->device->settings->getPhyEnable(index); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = false;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_phy_enable_set(icsneoc2_device_t* device, uint8_t index, bool value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setPhyEnable(index, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_phy_mode_get(icsneoc2_device_t* device, uint8_t index, icsneoc2_ae_link_mode_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
if(auto result = device->device->settings->getPhyMode(index); result.has_value()) {
*value = static_cast<icsneoc2_ae_link_mode_t>(result.value());
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_phy_mode_set(icsneoc2_device_t* device, uint8_t index, icsneoc2_ae_link_mode_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setPhyMode(index, static_cast<AELinkMode>(value))) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_phy_speed_get(icsneoc2_device_t* device, uint8_t index, icsneoc2_eth_phy_link_mode_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
if(auto result = device->device->settings->getPhySpeed(index); result.has_value()) {
*value = static_cast<icsneoc2_eth_phy_link_mode_t>(result.value());
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_phy_speed_set(icsneoc2_device_t* device, uint8_t index, icsneoc2_eth_phy_link_mode_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setPhySpeed(index, static_cast<EthPhyLinkMode>(value))) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_phy_role_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_ae_link_mode_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getPhyRoleFor(network); result.has_value()) {
*value = static_cast<icsneoc2_ae_link_mode_t>(result.value());
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_phy_role_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_ae_link_mode_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setPhyRoleFor(network, static_cast<AELinkMode>(value))) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_phy_link_mode_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getPhyLinkModeFor(network); result.has_value()) {
*value = static_cast<icsneoc2_eth_phy_link_mode_t>(result.value());
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_phy_link_mode_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setPhyLinkModeFor(network, static_cast<EthPhyLinkMode>(value))) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_phy_enable_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getPhyEnableFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = false;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_phy_enable_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setPhyEnableFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_supported_phy_link_modes_for(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t** link_modes, size_t* link_modes_count) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!link_modes || !link_modes_count) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
auto modes = device->device->settings->getSupportedPhyLinkModesFor(network);
*link_modes_count = std::minmax(modes.size(), *link_modes_count).first;
memcpy(*link_modes, modes.data(), *link_modes_count * sizeof(icsneoc2_eth_phy_link_mode_t));
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_t1s_is_plca_enabled_for(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->isT1SPLCAEnabledFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = false;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_t1s_plca_enabled_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setT1SPLCAFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_t1s_local_id_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value){
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getT1SLocalIDFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_t1s_local_id_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value){
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setT1SLocalIDFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_t1s_max_nodes_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getT1SMaxNodesFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_t1s_max_nodes_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setT1SMaxNodesFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_t1s_tx_opp_timer_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getT1STxOppTimerFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_t1s_tx_opp_timer_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setT1STxOppTimerFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_t1s_max_burst_timer_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!value) {
return icsneoc2_error_invalid_parameters;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(auto result = device->device->settings->getT1SMaxBurstFor(network); result.has_value()) {
*value = result.value();
return icsneoc2_error_success;
} else {
*value = 0;
return icsneoc2_error_get_settings_failure;
}
}
icsneoc2_error_t icsneoc2_settings_t1s_max_burst_timer_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
auto network = Network(static_cast<Network::NetID>(netid));
if(!device->device->settings->setT1SMaxBurstFor(network, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_misc_io_analog_output_enabled_set(icsneoc2_device_t* device, uint8_t pin, uint8_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setMiscIOAnalogOutputEnabled(pin, value)) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_misc_io_analog_output_set(icsneoc2_device_t* device, uint8_t pin, icsneoc2_misc_io_analog_voltage_t value) {
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
if(!device->device->settings->setMiscIOAnalogOutput(pin, static_cast<MiscIOAnalogVoltage>(value))) {
return icsneoc2_error_set_settings_failure;
}
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_disabled_get(icsneoc2_device_t* device, bool* value) {
if(!value) {
return icsneoc2_error_invalid_parameters;
}
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
*value = device->device->settings->disabled;
return icsneoc2_error_success;
}
icsneoc2_error_t icsneoc2_settings_readonly_get(icsneoc2_device_t* device, bool* value) {
if(!value) {
return icsneoc2_error_invalid_parameters;
}
// Make sure the device is valid
auto res = icsneoc2_device_is_valid(device);
if(res != icsneoc2_error_success) {
return res;
}
*value = device->device->settings->readonly;
return icsneoc2_error_success;
}

View File

@ -0,0 +1,51 @@
#define VER_FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@
#define VER_FILEVERSION_STR "v@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@@BUILD_METADATA_PLUS@ @BUILD_GIT_INFO@"
#define VER_PRODUCTVERSION VER_FILEVERSION
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK (VS_FF_DEBUG)
FILEFLAGS (VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Intrepid Control Systems, Inc."
VALUE "FileDescription", "Intrepid Control Systems Open Device Communication C API"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "icsneoc2.dll"
VALUE "LegalCopyright", "Intrepid Control Systems, Inc. (C) 2018-2026"
VALUE "OriginalFilename", "icsneoc2.dll"
VALUE "ProductName", "libicsneo"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
VALUE "Translation", 0x409, 1252
END
END

View File

@ -7,31 +7,6 @@
using namespace icsneo; using namespace icsneo;
// copied.. TODO
static std::optional<uint8_t> CAN_LengthToDLC(size_t dataLength, bool fd) {
if(dataLength <= 8)
return uint8_t(dataLength);
if(fd) {
if(dataLength <= 12)
return uint8_t(0x9);
if(dataLength <= 16)
return uint8_t(0xA);
if(dataLength <= 20)
return uint8_t(0xB);
if(dataLength <= 24)
return uint8_t(0xC);
if(dataLength <= 32)
return uint8_t(0xD);
if(dataLength <= 48)
return uint8_t(0xE);
if(dataLength <= 64)
return uint8_t(0xF);
}
return std::nullopt;
}
static std::vector<uint8_t> EncodeFromMessageEthernet(std::shared_ptr<Frame> frame, const device_eventhandler_t& report) { static std::vector<uint8_t> EncodeFromMessageEthernet(std::shared_ptr<Frame> frame, const device_eventhandler_t& report) {
auto ethmsg = std::dynamic_pointer_cast<EthernetMessage>(frame); auto ethmsg = std::dynamic_pointer_cast<EthernetMessage>(frame);
if(!ethmsg) { if(!ethmsg) {

View File

@ -29,8 +29,7 @@ static std::optional<uint8_t> CAN_DLCToLength(uint8_t length, bool fd) {
return std::nullopt; return std::nullopt;
} }
static std::optional<uint8_t> CAN_LengthToDLC(size_t dataLength, bool fd) std::optional<uint8_t> icsneo::CAN_LengthToDLC(size_t dataLength, bool fd) {
{
if (dataLength <= 8) if (dataLength <= 8)
return uint8_t(dataLength); return uint8_t(dataLength);

View File

@ -181,12 +181,11 @@ bool Device::getMessages(std::vector<std::shared_ptr<Message>>& container, size_
if(container.size() < limit) if(container.size() < limit)
container.resize(limit); container.resize(limit);
size_t actuallyRead; size_t actuallyRead = 0;
if(timeout != std::chrono::milliseconds(0)) if(pollingContainer.wait_dequeue_timed(container.front(), timeout)) {
actuallyRead = pollingContainer.wait_dequeue_bulk_timed(container.data(), limit, timeout); actuallyRead = 1; // Account for the first message we already dequeued
else actuallyRead += pollingContainer.try_dequeue_bulk(container.data() + 1, limit - 1);
actuallyRead = pollingContainer.try_dequeue_bulk(container.data(), limit); }
if(container.size() > actuallyRead) if(container.size() > actuallyRead)
container.resize(actuallyRead); container.resize(actuallyRead);

View File

@ -7,6 +7,7 @@ import subprocess
subprocess.call('cd ..; doxygen docs/icsneocpp/Doxyfile', shell=True) subprocess.call('cd ..; doxygen docs/icsneocpp/Doxyfile', shell=True)
subprocess.call('cd ..; doxygen docs/icsneoc/Doxyfile', shell=True) subprocess.call('cd ..; doxygen docs/icsneoc/Doxyfile', shell=True)
subprocess.call('cd ..; doxygen docs/icsneoc2/Doxyfile', shell=True)
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@ -26,6 +27,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
breathe_projects = { breathe_projects = {
'icsneocpp': 'icsneocpp/doxygen/xml', 'icsneocpp': 'icsneocpp/doxygen/xml',
'icsneoc': 'icsneoc/doxygen/xml', 'icsneoc': 'icsneoc/doxygen/xml',
'icsneoc2': 'icsneoc2/doxygen/xml',
} }
breathe_default_project = 'icsneocpp' breathe_default_project = 'icsneocpp'

1
docs/icsneoc/.gitignore vendored 100644
View File

@ -0,0 +1 @@
doxygen

View File

@ -1,5 +1,5 @@
icsneoc icsneoc (deprecated, use icsneoc2)
======= ============================
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2

1
docs/icsneoc2/.gitignore vendored 100644
View File

@ -0,0 +1 @@
doxygen

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
======
C2 API
======
.. doxygenfile:: icsneoc2.h
:project: icsneoc2
.. doxygenfile:: icsneoc2messages.h
:project: icsneoc2
.. doxygenfile:: icsneoc2settings.h
:project: icsneoc2
.. doxygenfile:: icsneoc2types.h
:project: icsneoc2

View File

@ -0,0 +1,27 @@
=================
icsneoc2 Examples
=================
Simple
======
:download:`Download example <../../examples/c2/simple/src/main.c>`
.. literalinclude:: ../../examples/c2/simple/src/main.c
:language: c
Disk Format
===========
:download:`Download example <../../examples/c2/diskformat/src/main.c>`
.. literalinclude:: ../../examples/c2/diskformat/src/main.c
:language: c
Read Messages
=============
:download:`Download example <../../examples/c2/read_messages/src/main.c>`
.. literalinclude:: ../../examples/c2/read_messages/src/main.c
:language: c

View File

@ -0,0 +1,9 @@
icsneoc2
========
.. toctree::
:maxdepth: 2
installation
examples
api

View File

@ -0,0 +1,7 @@
============
Installation
============
The installation steps for the C2 API are the same as the C++ API as the C2 API is
a wrapper for the C++ library. The ``LIBICSNEO_BUILD_ICSNEOC2`` CMake option is
default ``ON`` but note that the C2 API depends on this flag to build.

1
docs/icsneocpp/.gitignore vendored 100644
View File

@ -0,0 +1 @@
doxygen

View File

@ -13,3 +13,4 @@ communication library. The source code for libicsneo can be found on GitHub:
icsneocpp/index icsneocpp/index
icsneopy/index icsneopy/index
icsneoc/index icsneoc/index
icsneoc2/index

View File

@ -1,6 +1,9 @@
option(LIBICSNEO_BUILD_C_INTERACTIVE_EXAMPLE "Build the command-line interactive C example." ON) option(LIBICSNEO_BUILD_C_INTERACTIVE_EXAMPLE "Build the command-line interactive C example." ON)
option(LIBICSNEO_BUILD_C_SIMPLE_EXAMPLE "Build the command-line simple C example." ON) option(LIBICSNEO_BUILD_C_SIMPLE_EXAMPLE "Build the command-line simple C example." ON)
option(LIBICSNEO_BUILD_C_LEGACY_EXAMPLE "Build the command-line simple C example." ON) option(LIBICSNEO_BUILD_C_LEGACY_EXAMPLE "Build the command-line simple C example." ON)
option(LIBICSNEO_BUILD_C2_SIMPLE_EXAMPLE "Build the simple C2 example." ON)
option(LIBICSNEO_BUILD_C2_READ_MESSAGES_EXAMPLE "Build the C2 read messages example." ON)
option(LIBICSNEO_BUILD_C2_DISKFORMAT_EXAMPLE "Build the C2 disk format 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)
@ -31,6 +34,18 @@ if(LIBICSNEO_BUILD_C_LEGACY_EXAMPLE)
add_subdirectory(c/legacy) add_subdirectory(c/legacy)
endif() endif()
if(LIBICSNEO_BUILD_C2_SIMPLE_EXAMPLE)
add_subdirectory(c2/simple)
endif()
if(LIBICSNEO_BUILD_C2_READ_MESSAGES_EXAMPLE)
add_subdirectory(c2/read_messages)
endif()
if(LIBICSNEO_BUILD_C2_DISKFORMAT_EXAMPLE)
add_subdirectory(c2/diskformat)
endif()
if(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE) if(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE)
add_subdirectory(cpp/simple) add_subdirectory(cpp/simple)
endif() endif()

View File

@ -0,0 +1,6 @@
add_executable(libicsneoc2-diskformat-example src/main.c)
target_link_libraries(libicsneoc2-diskformat-example icsneoc2-static)
if(WIN32)
target_compile_definitions(libicsneoc2-diskformat-example PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()

View File

@ -0,0 +1,175 @@
#include <icsneo/icsneoc2.h>
#include <stdio.h>
#include <inttypes.h>
/**
* Prints an error message with the given string and error code.
*
* @param message The message to print.
* @param error The error code to print.
* @return error as int
*/
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_code_get(error, error_str, &error_str_len);
printf("%s: \"%s\" (%u)\n", message, error_str, error);
return (int)error;
}
/**
* Progress callback invoked periodically during disk formatting.
*
* @param sectors_formatted Number of sectors formatted so far.
* @param total_sectors Total number of sectors to format.
* @param user_data Unused opaque pointer.
* @return icsneoc2_disk_format_directive_continue to keep formatting.
*/
static icsneoc2_disk_format_directive_t format_progress(uint64_t sectors_formatted, uint64_t total_sectors, void* user_data) {
(void)user_data;
double pct = total_sectors > 0 ? (100.0 * (double)sectors_formatted / (double)total_sectors) : 0.0;
printf("\r Progress: %" PRIu64 " / %" PRIu64 " sectors (%d%%)", sectors_formatted, total_sectors, (int)pct);
fflush(stdout);
return icsneoc2_disk_format_directive_continue;
}
int main() {
/* Open the first available device (no online needed for formatting) */
printf("Opening first available device...\n");
icsneoc2_device_t* device = NULL;
icsneoc2_error_t res = icsneoc2_device_open_first(0, ICSNEOC2_OPEN_OPTIONS_NONE, &device);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to open first device", res);
}
/* Get a description of the opened device */
char description[255] = {0};
size_t description_length = sizeof(description);
res = icsneoc2_device_description_get(device, description, &description_length);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get device description", res);
}
printf("\tOpened device: %s\n", description);
/* Check disk formatting support */
bool supported = false;
res = icsneoc2_device_supports_disk_formatting(device, &supported);
if(res != icsneoc2_error_success) {
print_error_code("\tFailed to check disk formatting support", res);
icsneoc2_device_close(device);
return -1;
}
if(!supported) {
printf("\terror: %s does not support disk formatting\n", description);
icsneoc2_device_close(device);
return -1;
}
size_t disk_count = 0;
icsneoc2_device_disk_count_get(device, &disk_count);
printf("\tDisk count: %zu\n", disk_count);
/* Query disk details */
printf("\tQuerying disk details... ");
fflush(stdout);
icsneoc2_disk_details_t* details = NULL;
res = icsneoc2_device_disk_details_get(device, &details);
if(res != icsneoc2_error_success) {
printf("FAIL\n");
print_error_code("\tFailed to get disk details", res);
icsneoc2_device_close(device);
return -1;
}
printf("OK\n");
/* Display current state */
icsneoc2_disk_layout_t layout = 0;
icsneoc2_disk_details_layout_get(details, &layout);
printf("\t Layout : %s\n", layout == icsneoc2_disk_layout_raid0 ? "RAID0" : "Spanned");
size_t detail_count = 0;
icsneoc2_disk_details_count_get(details, &detail_count);
for(size_t i = 0; i < detail_count; i++) {
icsneoc2_disk_format_flags_t flags = 0;
icsneoc2_disk_details_flags_get(details, i, &flags);
printf("\t Disk [%zu]:\n", i);
printf("\t Present : %s\n", (flags & ICSNEOC2_DISK_FORMAT_FLAGS_PRESENT) ? "yes" : "no");
printf("\t Initialized : %s\n", (flags & ICSNEOC2_DISK_FORMAT_FLAGS_INITIALIZED) ? "yes" : "no");
printf("\t Formatted : %s\n", (flags & ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED) ? "yes" : "no");
if(flags & ICSNEOC2_DISK_FORMAT_FLAGS_PRESENT) {
uint64_t sectors = 0, bps = 0;
icsneoc2_disk_details_size_get(details, i, &sectors, &bps);
printf("\t Size : %" PRIu64 " MB (%" PRIu64 " sectors x %" PRIu64 " bytes)\n",
(sectors * bps) / (1024 * 1024), sectors, bps);
}
}
/* Build format config: mark present disks for formatting */
bool any_present = false;
for(size_t i = 0; i < detail_count; i++) {
icsneoc2_disk_format_flags_t flags = 0;
icsneoc2_disk_details_flags_get(details, i, &flags);
if(flags & ICSNEOC2_DISK_FORMAT_FLAGS_PRESENT) {
flags |= ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED;
icsneoc2_disk_details_flags_set(details, i, flags);
any_present = true;
}
}
icsneoc2_disk_details_full_format_set(details, false); /* Quick format */
if(!any_present) {
printf("\n\terror: no disks are present in the device\n");
icsneoc2_disk_details_free(details);
icsneoc2_device_close(device);
return -1;
}
/* Confirm */
printf("\n\tThis will format the disk(s) in %s.\n", description);
printf("\tAll existing data will be lost. Continue? [y/N]: ");
char confirm[8] = {0};
if(scanf("%7s", confirm) != 1 || (confirm[0] != 'y' && confirm[0] != 'Y')) {
printf("\tAborted.\n");
icsneoc2_disk_details_free(details);
icsneoc2_device_close(device);
return 0;
}
/* Format */
printf("\n\tStarting format...\n");
res = icsneoc2_device_format_disk(device, details, format_progress, NULL);
printf("\n"); /* newline after progress line */
if(res != icsneoc2_error_success) {
print_error_code("\tFormat failed", res);
icsneoc2_disk_details_free(details);
icsneoc2_device_close(device);
return -1;
}
printf("\tFormat complete!\n");
icsneoc2_disk_details_free(details);
/* Verify */
printf("\n\tVerifying disk state after format... ");
fflush(stdout);
icsneoc2_disk_details_t* post_details = NULL;
res = icsneoc2_device_disk_details_get(device, &post_details);
if(res != icsneoc2_error_success) {
printf("FAIL (could not re-query disk details)\n");
} else {
printf("OK\n");
size_t post_count = 0;
icsneoc2_disk_details_count_get(post_details, &post_count);
for(size_t i = 0; i < post_count; i++) {
icsneoc2_disk_format_flags_t flags = 0;
icsneoc2_disk_details_flags_get(post_details, i, &flags);
printf("\t Disk [%zu] formatted: %s\n", i, (flags & ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED) ? "yes" : "no");
}
icsneoc2_disk_details_free(post_details);
}
printf("\tClosing device: %s...\n", description);
icsneoc2_device_close(device);
return 0;
}

View File

@ -0,0 +1,6 @@
add_executable(libicsneoc2-read_messages-example src/main.c)
target_link_libraries(libicsneoc2-read_messages-example icsneoc2-static)
if(WIN32)
target_compile_definitions(libicsneoc2-read_messages-example PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()

View File

@ -0,0 +1,258 @@
#include <icsneo/icsneoc2.h>
#include <icsneo/icsneoc2settings.h>
#include <icsneo/icsneoc2messages.h>
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
/**
* Sleeps for a specified number of milliseconds using Sleep() on Windows and sleep() on *nix.
*
* @param ms The number of milliseconds to sleep.
*/
void sleep_ms(uint32_t ms) {
#ifdef _WIN32
Sleep(ms);
#else
sleep(ms / 1000);
#endif
}
/**
* Prints all events
*
* @param device_description A description of the device used in the output.
*/
void print_events(const char* device_description);
/**
* Prints an error message with the given string and error code.
*
* If the error code is not icsneoc2_error_success, prints the error string for the given error code
* and returns the error code.
*
* @param message The message to print.
* @param error The error code to print.
* @return error as int
*/
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;
}
/**
* Processes a list of messages from a device.
*
* This function iterates over a given array of messages received from a specified device.
* For each message in the array, it retrieves and prints the message type and bus type.
* If an error occurs while retrieving these details, an error message is printed.
*
* @param messages An array of pointers to icsneoc2_message_t structures containing the messages to process.
* @param messages_count The number of messages in the messages array.
*
* @return An icsneoc2_error_t value indicating success or failure of the message processing.
*/
int process_message(icsneoc2_message_t** messages, size_t messages_count);
int main() {
// Open the first available device with default options
printf("Opening first available device...\n");
icsneoc2_device_t* open_device = NULL;
icsneoc2_error_t res = icsneoc2_device_open_first(0, icsneoc2_open_options_default, &open_device);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to open first device", res);
};
// Get a description of the opened device
char description[255] = {0};
size_t description_length = 255;
res = icsneoc2_device_description_get(open_device, description, &description_length);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get device description", res);
};
printf("\tOpened device: %s\n", description);
// Get the messages
icsneoc2_message_t* messages[20000] = {0};
size_t message_count = 20000;
time_t start_time = time(NULL);
printf("\tGetting messages from device with timeout of 3000ms on %s...\n", description);
for(size_t i = 0; i < message_count; ++i) {
res = icsneoc2_device_message_get(open_device, &messages[i], 0);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get messages from device", res);
};
if(messages[i] == NULL) {
// no more messages
message_count = i;
break;
}
}
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get messages from device", res);
}
time_t end_time = time(NULL);
printf("\tGot %zu messages in %lld seconds\n", message_count, (long long)(end_time - start_time));
// Process the messages
res = process_message(messages, message_count);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to process messages", res);
}
// Finally, close the device.
printf("\tClosing device: %s...\n", description);
res = icsneoc2_device_close(open_device);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to close device", res);
};
printf("\n");
return 0;
}
void print_events(const char* device_description) {
icsneoc2_event_t* events[1024] = {0};
size_t events_count = 1024;
for(size_t i = 0; i < events_count; ++i) {
// no device filter, get all events
icsneoc2_error_t res = icsneoc2_event_get(&events[i], NULL);
if(res != icsneoc2_error_success) {
(void)print_error_code("\tFailed to get device events", res);
return;
}
if(events[i] == NULL) {
events_count = i;
break;
}
}
// Loop over each event and describe it.
for(size_t i = 0; i < events_count; i++) {
char event_description[255] = {0};
size_t event_description_length = 255;
icsneoc2_error_t res = icsneoc2_event_description_get(events[i], event_description, &event_description_length);
if(res != icsneoc2_error_success) {
print_error_code("\tFailed to get event description", res);
continue;
}
printf("\t%s: Event %zu: %s\n", device_description, i, event_description);
}
for(size_t i = 0; i < events_count; i++) {
icsneoc2_event_free(events[i]);
}
printf("\t%s: Received %zu events\n", device_description, events_count);
}
int process_message(icsneoc2_message_t** messages, size_t messages_count) {
// Print the type and bus type of each message
size_t tx_count = 0;
for(size_t i = 0; i < messages_count; i++) {
icsneoc2_message_t* message = messages[i];
bool is_frame = false;
icsneoc2_error_t res = icsneoc2_message_is_frame(message, &is_frame);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to check if message is a frame", res);
}
if(!is_frame) {
printf("Ignoring non-frame message at index %zu\n", i);
continue;
}
icsneoc2_network_type_t network_type;
res = icsneoc2_message_network_type_get(message, &network_type);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get message network type", res);
}
char network_type_name[128] = {0};
size_t network_type_name_length = 128;
res = icsneoc2_network_type_name_get(network_type, network_type_name, &network_type_name_length);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get message bus type name", res);
}
bool is_tx = false;
res = icsneoc2_message_is_transmit(message, &is_tx);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get message is transmit", res);
}
if(is_tx) {
tx_count++;
continue;
}
printf("\t%zd) network type: %s (%u)\n", i, network_type_name, network_type);
if(network_type == icsneoc2_network_type_can) {
uint32_t arbid = 0;
int32_t dlc = 0;
icsneoc2_netid_t netid = 0;
bool is_remote = false;
bool is_canfd = false;
bool is_extended = false;
uint8_t data[64] = {0};
size_t data_length = 64;
char netid_name[128] = {0};
size_t netid_name_length = 128;
icsneoc2_error_t result = icsneoc2_message_netid_get(message, &netid);
result += icsneoc2_netid_name_get(netid, netid_name, &netid_name_length);
result += icsneoc2_message_data_get(message, data, &data_length);
if(result != icsneoc2_error_success) {
printf("\tFailed get get CAN parameters (error: %u) for index %zu\n", result, i);
continue;
}
printf("\t NetID: %s (0x%x)\tArbID: 0x%x\t DLC: %u\t Remote: %d\t CANFD: %d\t Extended: %d\t Data length: %zu\n", netid_name, netid, arbid, dlc, is_remote, is_canfd, is_extended, data_length);
printf("\t Data: [");
for(size_t x = 0; x < data_length; x++) {
printf(" 0x%x", data[x]);
}
printf(" ]\n");
}
}
printf("\tReceived %zu messages total, %zu were TX messages\n", messages_count, tx_count);
return icsneoc2_error_success;
}
int transmit_can_messages(icsneoc2_device_t* device) {
uint64_t counter = 0;
const size_t msg_count = 100;
printf("\tTransmitting %zd messages...\n", msg_count);
for(size_t i = 0; i < msg_count; i++) {
// Create the message
icsneoc2_message_t* message = NULL;
icsneoc2_error_t res = icsneoc2_message_can_create(&message);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to create messages", res);
}
// Set the message attributes
res = icsneoc2_message_netid_set(message, icsneoc2_netid_dwcan_01);
res += icsneoc2_message_data_set(message, (uint8_t*)&counter, sizeof(counter));
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to modify message", res);
}
res = icsneoc2_device_message_transmit(device, message);
res += icsneoc2_message_free(message);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to transmit message", res);
}
counter++;
}
return icsneoc2_error_success;
}

View File

@ -0,0 +1,6 @@
add_executable(libicsneoc2-simple-example src/main.c)
target_link_libraries(libicsneoc2-simple-example icsneoc2-static)
if(WIN32)
target_compile_definitions(libicsneoc2-simple-example PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()

View File

@ -0,0 +1,411 @@
#include <icsneo/icsneoc2.h>
#include <icsneo/icsneoc2messages.h>
#include <icsneo/icsneoc2settings.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
/**
* Sleeps for a specified number of milliseconds using Sleep() on Windows and sleep() on *nix.
*
* @param ms The number of milliseconds to sleep.
*/
void sleep_ms(uint32_t ms) {
#ifdef _WIN32
Sleep(ms);
#else
sleep(ms / 1000);
#endif
}
/**
* Prints an error message with the given string and error code.
*
* If the error code is not icsneoc2_error_success, prints the error string for the given error code
* and returns the error code.
*
* @param message The message to print.
* @param error The error code to print.
* @return error as int
*/
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;
}
/**
* Processes a list of messages from a device.
*
* This function iterates over a given array of messages received from a specified device.
* For each message in the array, it retrieves and prints the message type and bus type.
* If an error occurs while retrieving these details, an error message is printed.
*
* @param messages An array of pointers to icsneoc2_message_t structures containing the messages to process.
* @param messages_count The number of messages in the messages array.
*
* @return An icsneoc2_error_t value indicating success or failure of the message processing.
*/
int process_messages(icsneoc2_message_t** messages, size_t messages_count);
/**
* Prints all events
*
* @param device_description A description of the device used in the output.
*/
void print_events(const char* device_description);
/**
* Transmits a series of CAN messages from a device.
*
* This function creates and transmits 100 CAN messages with incrementing payload data.
* Each message is configured with specific attributes such as network ID, arbitration
* ID, CANFD status, extended status, and baudrate switch. After successfully transmitting
* each message, it is freed from memory.
*
* @param device A pointer to the icsneoc2_device_t structure representing the device to transmit messages from.
*
* @return An icsneoc2_error_t value indicating success or failure of the message transmission process.
*/
int transmit_can_messages(icsneoc2_device_t* device);
/**
* Get the RTC (Real time clock) of a device and print it.
*
* @param[in] device The device to get the RTC of.
* @param[in] description A description of the device for printing purpose.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t get_and_print_rtc(icsneoc2_device_t* device);
int main() {
icsneoc2_device_info_t* found_devices = NULL;
printf("Finding devices...\n");
icsneoc2_error_t res = icsneoc2_device_enumerate(0, &found_devices);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to find devices", res);
}
if(found_devices == NULL) {
printf("No devices found, exiting\n");
return 0;
}
// Count and list off the devices
size_t devices_count = 0;
for(icsneoc2_device_info_t* cur = found_devices; cur != NULL; cur = icsneoc2_device_info_next(cur)) {
devices_count++;
}
printf("OK, %zu device%s found\n", devices_count, devices_count == 1 ? "" : "s");
for(icsneoc2_device_info_t* cur = found_devices; cur != NULL; cur = icsneoc2_device_info_next(cur)) {
// Get description of the device
char description[255] = {0};
size_t description_length = 255;
res = icsneoc2_device_info_description_get(cur, description, &description_length);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get device description", res);
};
printf("%.*s\n", (int)description_length, description);
// Open the device without RTC sync and going online
icsneoc2_open_options_t options = icsneoc2_open_options_default;
options &= ~ICSNEOC2_OPEN_OPTIONS_SYNC_RTC;
options &= ~ICSNEOC2_OPEN_OPTIONS_GO_ONLINE;
printf("\tDevice open options: 0x%x\n", options);
printf("\tOpening device: %s...\n", description);
icsneoc2_device_t* open_device = NULL;
res = icsneoc2_device_open(cur, options, &open_device);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to open device", res);
};
// Get timestamp resolution of the device
printf("\tGetting timestamp resolution... ");
uint32_t timestamp_resolution = 0;
res = icsneoc2_device_timestamp_resolution_get(open_device, &timestamp_resolution);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get timestamp resolution", res);
}
printf("%uns\n", timestamp_resolution);
// Get baudrates for HSCAN
printf("\tGetting DW CAN 01 Baudrate... ");
int64_t baudrate = 0;
res = icsneoc2_settings_baudrate_get(open_device, icsneoc2_netid_dwcan_01, &baudrate);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get baudrate", res);
};
printf("%" PRIu64 "mbit/s\n", baudrate);
// Get FDbaudrates for HSCAN
printf("\tGetting FD DW CAN 01 Baudrate... ");
int64_t fd_baudrate = 0;
res = icsneoc2_settings_canfd_baudrate_get(open_device, icsneoc2_netid_dwcan_01, &fd_baudrate);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get FD baudrate", res);
};
printf("%" PRIu64 "mbit/s\n", fd_baudrate);
// Set baudrates for HSCAN
// save_to_device: If this is set to true, the baudrate will be saved on the device
// and will persist through a power cycle
printf("\tSetting DW CAN 01 Baudrate... ");
res = icsneoc2_settings_baudrate_set(open_device, icsneoc2_netid_dwcan_01, baudrate);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to set baudrate", res);
};
printf("Ok\n");
// Set FDbaudrates for HSCAN
printf("\tSetting FD DW CAN 01 Baudrate... ");
res = icsneoc2_settings_canfd_baudrate_set(open_device, icsneoc2_netid_dwcan_01, fd_baudrate);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to set FD baudrate", res);
};
printf("Ok\n");
// Get RTC
printf("\tGetting RTC... ");
res = get_and_print_rtc(open_device);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get RTC", res);
}
// Set RTC
printf("\tSetting RTC to current time... ");
time_t current_time = time(NULL);
res = icsneoc2_device_rtc_set(open_device, current_time);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to set RTC", res);
}
printf("Ok\n");
// Get RTC
printf("\tGetting RTC... ");
res = get_and_print_rtc(open_device);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get RTC", res);
}
// Go online, start acking traffic
printf("\tGoing online... ");
res = icsneoc2_device_go_online(open_device, true);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to go online", res);
}
// Redundant check to show how to check if the device is online, if the previous
// icsneoc2_device_go_online call was successful we can assume we are online already
bool is_online = false;
res = icsneoc2_device_is_online(open_device, &is_online);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to check if online", res);
}
printf("%s\n", is_online ? "Online" : "Offline");
// Transmit CAN messages
res = transmit_can_messages(open_device);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to transmit CAN messages", res);
}
// Wait for the bus to collect some messages, requires an active bus to get messages
printf("\tWaiting 1 second for messages...\n");
sleep_ms(1000);
// Get the messages
icsneoc2_message_t* messages[20000] = {0};
size_t message_count = 20000;
printf("\tGetting messages from device with timeout of 3000ms on %s...\n", description);
for(size_t i = 0; i < message_count; ++i) {
res = icsneoc2_device_message_get(open_device, &messages[i], 0);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to get messages from device", res);
};
if(messages[i] == NULL) {
// no more messages
message_count = i;
break;
}
}
// Process the messages
res = process_messages(messages, message_count);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to process messages", res);
}
for(size_t i = 0; i < message_count; ++i) {
icsneoc2_message_free(messages[i]);
}
// Finally, close the device.
printf("\tClosing device: %s...\n", description);
res = icsneoc2_device_close(open_device);
if(res != icsneoc2_error_success) {
print_events(description);
return print_error_code("\tFailed to close device", res);
};
// Print device events
print_events(description);
}
icsneoc2_enumeration_free(found_devices);
printf("\n");
return 0;
}
icsneoc2_error_t get_and_print_rtc(icsneoc2_device_t* device) {
time_t unix_epoch = 0;
icsneoc2_error_t res = icsneoc2_device_rtc_get(device, &unix_epoch);
if(res != icsneoc2_error_success) {
return res;
}
char rtc_time[32] = {0};
strftime(rtc_time, sizeof(rtc_time), "%Y-%m-%d %H:%M:%S", localtime(&unix_epoch));
printf("RTC: %lld %s\n", (long long)unix_epoch, rtc_time);
return icsneoc2_error_success;
}
void print_events(const char* device_description) {
icsneoc2_event_t* events[1024] = {0};
size_t events_count = 1024;
for(size_t i = 0; i < events_count; ++i) {
// no device filter, get all events
icsneoc2_error_t res = icsneoc2_event_get(&events[i], NULL);
if(res != icsneoc2_error_success) {
(void)print_error_code("\tFailed to get device events", res);
return;
}
if(events[i] == NULL) {
events_count = i;
break;
}
}
// Loop over each event and describe it.
for(size_t i = 0; i < events_count; i++) {
char event_description[255] = {0};
size_t event_description_length = 255;
icsneoc2_error_t res = icsneoc2_event_description_get(events[i], event_description, &event_description_length);
if(res != icsneoc2_error_success) {
print_error_code("\tFailed to get event description", res);
continue;
}
printf("\t%s: Event %zu: %s\n", device_description, i, event_description);
}
for(size_t i = 0; i < events_count; i++) {
icsneoc2_event_free(events[i]);
}
printf("\t%s: Received %zu events\n", device_description, events_count);
}
int process_messages(icsneoc2_message_t** messages, size_t messages_count) {
// Print the type and bus type of each message
size_t tx_count = 0;
for(size_t i = 0; i < messages_count; i++) {
icsneoc2_message_t* message = messages[i];
bool is_frame = false;
icsneoc2_error_t res = icsneoc2_message_is_frame(message, &is_frame);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to check if message is a frame", res);
}
if(!is_frame) {
printf("Ignoring non-frame message at index %zu\n", i);
continue;
}
icsneoc2_network_type_t network_type;
res = icsneoc2_message_network_type_get(message, &network_type);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get message network type", res);
}
char network_type_name[128] = {0};
size_t network_type_name_length = 128;
res = icsneoc2_network_type_name_get(network_type, network_type_name, &network_type_name_length);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get network type name", res);
}
bool is_tx = false;
res = icsneoc2_message_is_transmit(message, &is_tx);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to get message is transmit", res);
}
if(is_tx) {
tx_count++;
continue;
}
printf("\t%zd) network type: %s (%u)\n", i, network_type_name, network_type);
if(network_type == icsneoc2_network_type_can) {
uint32_t arbid = 0;
int32_t dlc = 0;
icsneoc2_netid_t netid = 0;
bool is_remote = false;
bool is_canfd = false;
bool is_extended = false;
uint8_t data[64] = {0};
size_t data_length = 64;
char netid_name[128] = {0};
size_t netid_name_length = 128;
icsneoc2_error_t result = icsneoc2_message_netid_get(message, &netid);
result += icsneoc2_netid_name_get(netid, netid_name, &netid_name_length);
result += icsneoc2_message_data_get(message, data, &data_length);
if(result != icsneoc2_error_success) {
printf("\tFailed get get CAN parameters (error: %u) for index %zu\n", result, i);
continue;
}
printf("\t NetID: %s (0x%x)\tArbID: 0x%x\t DLC: %u\t Remote: %d\t CANFD: %d\t Extended: %d\t Data length: %zu\n", netid_name, netid, arbid, dlc, is_remote, is_canfd, is_extended, data_length);
printf("\t Data: [");
for(size_t x = 0; x < data_length; x++) {
printf(" 0x%x", data[x]);
}
printf(" ]\n");
}
}
printf("\tReceived %zu messages total, %zu were TX messages\n", messages_count, tx_count);
return icsneoc2_error_success;
}
int transmit_can_messages(icsneoc2_device_t* device) {
uint64_t counter = 0;
const size_t msg_count = 100;
printf("\tTransmitting %zd messages...\n", msg_count);
for(size_t i = 0; i < msg_count; i++) {
// Create the message
icsneoc2_message_t* message = NULL;
icsneoc2_error_t res = icsneoc2_message_can_create(&message);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to create messages", res);
}
// Set the message attributes
res = icsneoc2_message_netid_set(message, icsneoc2_netid_dwcan_01);
uint64_t arb_id = 0x10;
uint64_t flags = ICSNEOC2_MESSAGE_CAN_FLAGS_BRS | ICSNEOC2_MESSAGE_CAN_FLAGS_IDE | ICSNEOC2_MESSAGE_CAN_FLAGS_FDF;
res += icsneoc2_message_can_props_set(message, &arb_id, &flags);
res += icsneoc2_message_data_set(message, (uint8_t*)&counter, sizeof(counter));
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to modify message", res);
}
res = icsneoc2_device_message_transmit(device, message);
res += icsneoc2_message_free(message);
if(res != icsneoc2_error_success) {
return print_error_code("\tFailed to transmit message", res);
}
counter++;
}
return icsneoc2_error_success;
}

View File

@ -1,6 +1,8 @@
#ifndef __ICSNEO_IO_H_ #ifndef __ICSNEO_IO_H_
#define __ICSNEO_IO_H_ #define __ICSNEO_IO_H_
#include <icsneo/icsneoc2types.h>
typedef struct _neomiscio_t { typedef struct _neomiscio_t {
size_t number; size_t number;
bool supportsDigitalIn; bool supportsDigitalIn;
@ -19,12 +21,12 @@ namespace icsneo {
using MiscIO = neomiscio_t; using MiscIO = neomiscio_t;
enum class IO { enum class IO {
EthernetActivation = 0, // The DoIP activation line, 0 is HiZ and 1 is pulled up to VBAT EthernetActivation = icsneoc2_io_type_eth_activation, // The DoIP activation line, 0 is HiZ and 1 is pulled up to VBAT
USBHostPower = 1, USBHostPower = icsneoc2_io_type_usb_host_power,
BackupPowerEnabled = 2, // The FIRE 2's backup super capacitor BackupPowerEnabled = icsneoc2_io_type_backup_power_en, // The FIRE 2's backup super capacitor
BackupPowerGood = 3, // Whether or not the FIRE 2's backup super capacitor is charged (read only) BackupPowerGood = icsneoc2_io_type_backup_power_good, // Whether or not the FIRE 2's backup super capacitor is charged (read only)
Misc = 4, // General purpose IO on the device Misc = icsneoc2_io_type_misc, // General purpose IO on the device
EMisc = 5, // Extended general purpose IO on the device EMisc = icsneoc2_io_type_emisc, // Extended general purpose IO on the device
}; };
// Note that the C API does a static cast between this and neoio_t so keep them in sync! // Note that the C API does a static cast between this and neoio_t so keep them in sync!

View File

@ -2,6 +2,7 @@
#define __NETWORKID_H_ #define __NETWORKID_H_
#include <stdint.h> #include <stdint.h>
#include <icsneo/icsneoc2types.h>
typedef uint16_t neonetid_t; typedef uint16_t neonetid_t;
typedef uint8_t neonettype_t; typedef uint8_t neonettype_t;
@ -24,188 +25,192 @@ class Network {
public: public:
enum class NetID : neonetid_t { enum class NetID : neonetid_t {
Device = 0, Device = icsneoc2_netid_device,
DWCAN_01 = 1, // previously HSCAN DWCAN_01 = icsneoc2_netid_dwcan_01, // previously HSCAN
DWCAN_08 = 2, // previously MSCAN DWCAN_08 = icsneoc2_netid_dwcan_08, // previously MSCAN
SWCAN_01 = 3, // previously SWCAN SWCAN_01 = icsneoc2_netid_swcan_01, // previously SWCAN
LSFTCAN_01 = 4, // previously LSFTCAN LSFTCAN_01 = icsneoc2_netid_lsftcan_01, // previously LSFTCAN
FordSCP = 5, FordSCP = icsneoc2_netid_fordscp,
J1708 = 6, J1708 = icsneoc2_netid_j1708,
Aux = 7, Aux = icsneoc2_netid_aux,
J1850VPW = 8, J1850VPW = icsneoc2_netid_j1850vpw,
ISO9141_01 = 9, // previously ISO9141 ISO9141_01 = icsneoc2_netid_iso9141, // previously ISO9141
DiskData = 10, DiskData = icsneoc2_netid_disk_data,
Main51 = 11, Main51 = icsneoc2_netid_main51,
RED = 12, RED = icsneoc2_netid_red,
SCI = 13, SCI = icsneoc2_netid_sci,
ISO9141_02 = 14, // previously ISO9141_2 ISO9141_02 = icsneoc2_netid_iso9141_02, // previously ISO9141_2
ISO14230 = 15, ISO14230 = icsneoc2_netid_iso14230,
LIN_01 = 16, // previously LIN LIN_01 = icsneoc2_netid_lin_01, // previously LIN
AE_01 = 17, // previously OP_Ethernet1 AE_01 = icsneoc2_netid_ae_01, // previously OP_Ethernet1
AE_02 = 18, // previously OP_Ethernet2 AE_02 = icsneoc2_netid_ae_02, // previously OP_Ethernet2
AE_03 = 19, // previously OP_Ethernet3 AE_03 = icsneoc2_netid_ae_03, // previously OP_Ethernet3
// START Device Command Returns // START Device Command Returns
// When we send a command, the device returns on one of these, depending on command // When we send a command, the device returns on one of these, depending on command
RED_EXT_MEMORYREAD = 20, RED_EXT_MEMORYREAD = icsneoc2_netid_red_ext_memoryread,
RED_INT_MEMORYREAD = 21, RED_INT_MEMORYREAD = icsneoc2_netid_red_int_memoryread,
RED_DFLASH_READ = 22, RED_DFLASH_READ = icsneoc2_netid_red_dflash_read,
NeoMemorySDRead = 23, // Response from NeoMemory (MemoryTypeSD) NeoMemorySDRead = icsneoc2_netid_neo_memory_sdread, // Response from NeoMemory (MemoryTypeSD)
CAN_ERRBITS = 24, CAN_ERRBITS = icsneoc2_netid_can_errbits,
NeoMemoryWriteDone = 25, NeoMemoryWriteDone = icsneoc2_netid_neo_memory_write_done,
RED_WAVE_CAN1_LOGICAL = 26, RED_WAVE_CAN1_LOGICAL = icsneoc2_netid_red_wave_can1_logical,
RED_WAVE_CAN2_LOGICAL = 27, RED_WAVE_CAN2_LOGICAL = icsneoc2_netid_red_wave_can2_logical,
RED_WAVE_LIN1_LOGICAL = 28, RED_WAVE_LIN1_LOGICAL = icsneoc2_netid_red_wave_lin1_logical,
RED_WAVE_LIN2_LOGICAL = 29, RED_WAVE_LIN2_LOGICAL = icsneoc2_netid_red_wave_lin2_logical,
RED_WAVE_LIN1_ANALOG = 30, RED_WAVE_LIN1_ANALOG = icsneoc2_netid_red_wave_lin1_analog,
RED_WAVE_LIN2_ANALOG = 31, RED_WAVE_LIN2_ANALOG = icsneoc2_netid_red_wave_lin2_analog,
RED_WAVE_MISC_ANALOG = 32, RED_WAVE_MISC_ANALOG = icsneoc2_netid_red_wave_misc_analog,
RED_WAVE_MISCDIO2_LOGICAL = 33, RED_WAVE_MISCDIO2_LOGICAL = icsneoc2_netid_red_wave_miscdio2_logical,
RED_NETWORK_COM_ENABLE_EX = 34, RED_NETWORK_COM_ENABLE_EX = icsneoc2_netid_red_network_com_enable_ex,
RED_NEOVI_NETWORK = 35, RED_NEOVI_NETWORK = icsneoc2_netid_red_neovi_network,
RED_READ_BAUD_SETTINGS = 36, RED_READ_BAUD_SETTINGS = icsneoc2_netid_red_read_baud_settings,
RED_OLDFORMAT = 37, RED_OLDFORMAT = icsneoc2_netid_red_oldformat,
RED_SCOPE_CAPTURE = 38, RED_SCOPE_CAPTURE = icsneoc2_netid_red_scope_capture,
RED_HARDWARE_EXCEP = 39, RED_HARDWARE_EXCEP = icsneoc2_netid_red_hardware_excep,
RED_GET_RTC = 40, RED_GET_RTC = icsneoc2_netid_red_get_rtc,
// END Device Command Returns // END Device Command Returns
ISO9141_03 = 41, // previously ISO9141_3 ISO9141_03 = icsneoc2_netid_iso9141_03, // previously ISO9141_3
DWCAN_02 = 42, // previously HSCAN2 DWCAN_02 = icsneoc2_netid_dwcan_02, // previously HSCAN2
DWCAN_03 = 44, // previously HSCAN3 DWCAN_03 = icsneoc2_netid_dwcan_03, // previously HSCAN3
AE_04 = 45, // previously OP_Ethernet4 AE_04 = icsneoc2_netid_ae_04, // previously OP_Ethernet4
AE_05 = 46, // previously OP_Ethernet5 AE_05 = icsneoc2_netid_ae_05, // previously OP_Ethernet5
ISO9141_04 = 47, // previously ISO9141_4 ISO9141_04 = icsneoc2_netid_iso9141_04, // previously ISO9141_4
LIN_02 = 48, // previously LIN2 LIN_02 = icsneoc2_netid_lin_02, // previously LIN2
LIN_03 = 49, // previously LIN3 LIN_03 = icsneoc2_netid_lin_03, // previously LIN3
LIN_04 = 50, // previously LIN4 LIN_04 = icsneoc2_netid_lin_04, // previously LIN4
// MOST = 51, Old and unused // MOST = 51, Old and unused
RED_App_Error = 52, RED_App_Error = icsneoc2_netid_red_app_error,
CGI = 53, CGI = icsneoc2_netid_cgi,
Reset_Status = 54, Reset_Status = icsneoc2_netid_reset_status,
FB_Status = 55, FB_Status = icsneoc2_netid_fb_status,
App_Signal_Status = 56, App_Signal_Status = icsneoc2_netid_app_signal_status,
Read_Datalink_Cm_Tx_Msg = 57, Read_Datalink_Cm_Tx_Msg = icsneoc2_netid_read_datalink_cm_tx_msg,
Read_Datalink_Cm_Rx_Msg = 58, Read_Datalink_Cm_Rx_Msg = icsneoc2_netid_read_datalink_cm_rx_msg,
Logging_Overflow = 59, Logging_Overflow = icsneoc2_netid_logging_overflow,
ReadSettings = 60, ReadSettings = icsneoc2_netid_read_settings,
DWCAN_04 = 61, // previously HSCAN4 DWCAN_04 = icsneoc2_netid_dwcan_04, // previously HSCAN4
DWCAN_05 = 62, // previously HSCAN5 DWCAN_05 = icsneoc2_netid_dwcan_05, // previously HSCAN5
RS232 = 63, RS232 = icsneoc2_netid_rs232,
UART_01 = 64, // previously UART UART_01 = icsneoc2_netid_uart_01, // previously UART
UART_02 = 65, // previously UART2 UART_02 = icsneoc2_netid_uart_02, // previously UART2
UART_03 = 66, // previously UART3 UART_03 = icsneoc2_netid_uart_03, // previously UART3
UART_04 = 67, // previously UART4 UART_04 = icsneoc2_netid_uart_04, // previously UART4
SWCAN_02 = 68, // previously SWCAN2 SWCAN_02 = icsneoc2_netid_swcan_02, // previously SWCAN2
ETHERNET_DAQ = 69, // previously Ethernet_DAQ ETHERNET_DAQ = icsneoc2_netid_ethernet_daq, // previously Ethernet_DAQ
Data_To_Host = 70, Data_To_Host = icsneoc2_netid_data_to_host,
TextAPI_To_Host = 71, TextAPI_To_Host = icsneoc2_netid_textapi_to_host,
SPI_01 = 72, // previously SPI1 SPI_01 = icsneoc2_netid_spi_01, // previously SPI1
AE_06 = 73, // previously OP_Ethernet6 AE_06 = icsneoc2_netid_ae_06, // previously OP_Ethernet6
Red_VBat = 74, Red_VBat = icsneoc2_netid_red_vbat,
AE_07 = 75, // previously OP_Ethernet7 AE_07 = icsneoc2_netid_ae_07, // previously OP_Ethernet7
AE_08 = 76, // previously OP_Ethernet8 AE_08 = icsneoc2_netid_ae_08, // previously OP_Ethernet8
AE_09 = 77, // previously OP_Ethernet9 AE_09 = icsneoc2_netid_ae_09, // previously OP_Ethernet9
AE_10 = 78, // previously OP_Ethernet10 AE_10 = icsneoc2_netid_ae_10, // previously OP_Ethernet10
AE_11 = 79, // previously OP_Ethernet11 AE_11 = icsneoc2_netid_ae_11, // previously OP_Ethernet11
FLEXRAY_01A = 80, // previously FlexRay1a FLEXRAY_01A = icsneoc2_netid_flexray_01a, // previously FlexRay1a
FLEXRAY_01B = 81, // previously FlexRay1b FLEXRAY_01B = icsneoc2_netid_flexray_01b, // previously FlexRay1b
FLEXRAY_02A = 82, // previously FlexRay2a FLEXRAY_02A = icsneoc2_netid_flexray_02a, // previously FlexRay2a
FLEXRAY_02B = 83, // previously FlexRay2b FLEXRAY_02B = icsneoc2_netid_flexray_02b, // previously FlexRay2b
LIN_05 = 84, // previously LIN5 LIN_05 = icsneoc2_netid_lin_05, // previously LIN5
FLEXRAY_01 = 85, // previously FlexRay FLEXRAY_01 = icsneoc2_netid_flexray_01, // previously FlexRay
FLEXRAY_02 = 86, // previously FlexRay2 FLEXRAY_02 = icsneoc2_netid_flexray_02, // previously FlexRay2
AE_12 = 87, // previously OP_Ethernet12 AE_12 = icsneoc2_netid_ae_12, // previously OP_Ethernet12
I2C_01 = 88, // previously I2C I2C_01 = icsneoc2_netid_i2c_01, // previously I2C
MOST_25 = 90, // previously MOST25 MOST_25 = icsneoc2_netid_most_25, // previously MOST25
MOST_50 = 91, // previously MOST50 MOST_50 = icsneoc2_netid_most_50, // previously MOST50
MOST_150 = 92, // previously MOST150 MOST_150 = icsneoc2_netid_most_150, // previously MOST150
ETHERNET_01 = 93, // previously Ethernet ETHERNET_01 = icsneoc2_netid_ethernet_01, // previously Ethernet
GMFSA = 94, GMFSA = icsneoc2_netid_gmfsa,
TCP = 95, TCP = icsneoc2_netid_tcp,
DWCAN_06 = 96, // previously HSCAN6 DWCAN_06 = icsneoc2_netid_dwcan_06, // previously HSCAN6
DWCAN_07 = 97, // previously HSCAN7 DWCAN_07 = icsneoc2_netid_dwcan_07, // previously HSCAN7
LIN_06 = 98, // previously LIN6 LIN_06 = icsneoc2_netid_lin_06, // previously LIN6
LSFTCAN_02 = 99, // previously LSFTCAN2 LSFTCAN_02 = icsneoc2_netid_lsftcan_02, // previously LSFTCAN2
LogicalDiskInfo = 187, LogicalDiskInfo = icsneoc2_netid_logical_disk_info,
WiVICommand = 221, WiVICommand = icsneoc2_netid_wivi_command,
ScriptStatus = 224, ScriptStatus = icsneoc2_netid_script_status,
EthPHYControl = 239, EthPHYControl = icsneoc2_netid_eth_phy_control,
ExtendedCommand = 240, ExtendedCommand = icsneoc2_netid_extended_command,
ExtendedData = 242, ExtendedData = icsneoc2_netid_extended_data,
FlexRayControl = 243, FlexRayControl = icsneoc2_netid_flexray_control,
CoreMiniPreLoad = 244, CoreMiniPreLoad = icsneoc2_netid_coremini_preload,
HW_COM_Latency_Test = 512, HW_COM_Latency_Test = icsneoc2_netid_hw_com_latency_test,
DeviceStatus = 513, DeviceStatus = icsneoc2_netid_device_status,
UDP = 514, UDP = icsneoc2_netid_udp,
ForwardedMessage = 516, ForwardedMessage = icsneoc2_netid_forwarded_message,
I2C_02 = 517, // previously I2C2 I2C_02 = icsneoc2_netid_i2c_02, // previously I2C2
I2C_03 = 518, // previously I2C3 I2C_03 = icsneoc2_netid_i2c_03, // previously I2C3
I2C_04 = 519, // previously I2C4 I2C_04 = icsneoc2_netid_i2c_04, // previously I2C4
ETHERNET_02 = 520, // previously Ethernet2 ETHERNET_02 = icsneoc2_netid_ethernet_02, // previously Ethernet2
ETHERNET_TX_WRAP = 521, ETHERNET_TX_WRAP = icsneoc2_netid_ethernet_tx_wrap,
A2B_01 = 522, // previously A2B1 A2B_01 = icsneoc2_netid_a2b_01, // previously A2B1
A2B_02 = 523, // previously A2B2 A2B_02 = icsneoc2_netid_a2b_02, // previously A2B2
ETHERNET_03 = 524, // previously Ethernet3 ETHERNET_03 = icsneoc2_netid_ethernet_03, // previously Ethernet3
WBMS_01 = 532, // previously WBMS WBMS_01 = icsneoc2_netid_wbms_01, // previously WBMS
DWCAN_09 = 534, // previously DWCAN9 DWCAN_09 = icsneoc2_netid_dwcan_09, // previously DWCAN9
DWCAN_10 = 535, // previously DWCAN10 DWCAN_10 = icsneoc2_netid_dwcan_10, // previously DWCAN10
DWCAN_11 = 536, // previously DWCAN11 DWCAN_11 = icsneoc2_netid_dwcan_11, // previously DWCAN11
DWCAN_12 = 537, // previously DWCAN12 DWCAN_12 = icsneoc2_netid_dwcan_12, // previously DWCAN12
DWCAN_13 = 538, // previously DWCAN13 DWCAN_13 = icsneoc2_netid_dwcan_13, // previously DWCAN13
DWCAN_14 = 539, // previously DWCAN14 DWCAN_14 = icsneoc2_netid_dwcan_14, // previously DWCAN14
DWCAN_15 = 540, // previously DWCAN15 DWCAN_15 = icsneoc2_netid_dwcan_15, // previously DWCAN15
DWCAN_16 = 541, // previously DWCAN16 DWCAN_16 = icsneoc2_netid_dwcan_16, // previously DWCAN16
LIN_07 = 542, // previously LIN7 LIN_07 = icsneoc2_netid_lin_07, // previously LIN7
LIN_08 = 543, // previously LIN8 LIN_08 = icsneoc2_netid_lin_08, // previously LIN8
SPI_02 = 544, // previously SPI2 SPI_02 = icsneoc2_netid_spi_02, // previously SPI2
MDIO_01 = 545, // previously MDIO1 MDIO_01 = icsneoc2_netid_mdio_01, // previously MDIO1
MDIO_02 = 546, // previously MDIO2 MDIO_02 = icsneoc2_netid_mdio_02, // previously MDIO2
MDIO_03 = 547, // previously MDIO3 MDIO_03 = icsneoc2_netid_mdio_03, // previously MDIO3
MDIO_04 = 548, // previously MDIO4 MDIO_04 = icsneoc2_netid_mdio_04, // previously MDIO4
MDIO_05 = 549, // previously MDIO5 MDIO_05 = icsneoc2_netid_mdio_05, // previously MDIO5
MDIO_06 = 550, // previously MDIO6 MDIO_06 = icsneoc2_netid_mdio_06, // previously MDIO6
MDIO_07 = 551, // previously MDIO7 MDIO_07 = icsneoc2_netid_mdio_07, // previously MDIO7
MDIO_08 = 552, // previously MDIO8 MDIO_08 = icsneoc2_netid_mdio_08, // previously MDIO8
AE_13 = 553, // previously OP_Ethernet13 AE_13 = icsneoc2_netid_ae_13, // previously OP_Ethernet13
AE_14 = 554, // previously OP_Ethernet14 AE_14 = icsneoc2_netid_ae_14, // previously OP_Ethernet14
AE_15 = 555, // previously OP_Ethernet15 AE_15 = icsneoc2_netid_ae_15, // previously OP_Ethernet15
AE_16 = 556, // previously OP_Ethernet16 AE_16 = icsneoc2_netid_ae_16, // previously OP_Ethernet16
SPI_03 = 557, // previously SPI3 SPI_03 = icsneoc2_netid_spi_03, // previously SPI3
SPI_04 = 558, // previously SPI4 SPI_04 = icsneoc2_netid_spi_04, // previously SPI4
SPI_05 = 559, // previously SPI5 SPI_05 = icsneoc2_netid_spi_05, // previously SPI5
SPI_06 = 560, // previously SPI6 SPI_06 = icsneoc2_netid_spi_06, // previously SPI6
SPI_07 = 561, // previously SPI7 SPI_07 = icsneoc2_netid_spi_07, // previously SPI7
SPI_08 = 562, // previously SPI8 SPI_08 = icsneoc2_netid_spi_08, // previously SPI8
LIN_09 = 563, // previously LIN9 LIN_09 = icsneoc2_netid_lin_09, // previously LIN9
LIN_10 = 564, // previously LIN10 LIN_10 = icsneoc2_netid_lin_10, // previously LIN10
LIN_11 = 565, // previously LIN11 LIN_11 = icsneoc2_netid_lin_11, // previously LIN11
LIN_12 = 566, // previously LIN12 LIN_12 = icsneoc2_netid_lin_12, // previously LIN12
LIN_13 = 567, // previously LIN13 LIN_13 = icsneoc2_netid_lin_13, // previously LIN13
LIN_14 = 568, // previously LIN14 LIN_14 = icsneoc2_netid_lin_14, // previously LIN14
LIN_15 = 569, // previously LIN15 LIN_15 = icsneoc2_netid_lin_15, // previously LIN15
LIN_16 = 570, // previously LIN16 LIN_16 = icsneoc2_netid_lin_16, // previously LIN16
Any = 0xfffe, // Never actually set as type, but used as flag for filtering Any = icsneoc2_netid_any, // Never actually set as type, but used as flag for filtering
Invalid = 0xffff Invalid = icsneoc2_netid_invalid
}; };
enum class Type : neonettype_t { enum class Type : neonettype_t {
Invalid = 0, Invalid = icsneoc2_network_type_invalid,
Internal = 1, // Used for statuses that don't actually need to be transferred to the client application Internal = icsneoc2_network_type_internal, // Used for statuses that don't actually need to be transferred to the client application
CAN = 2, CAN = icsneoc2_network_type_can,
LIN = 3, LIN = icsneoc2_network_type_lin,
FlexRay = 4, FlexRay = icsneoc2_network_type_flexray,
MOST = 5, MOST = icsneoc2_network_type_most,
Ethernet = 6, Ethernet = icsneoc2_network_type_ethernet,
LSFTCAN = 7, LSFTCAN = icsneoc2_network_type_lsftcan,
SWCAN = 8, SWCAN = icsneoc2_network_type_swcan,
ISO9141 = 9, ISO9141 = icsneoc2_network_type_iso9141,
I2C = 10, I2C = icsneoc2_network_type_i2c,
A2B = 11, A2B = icsneoc2_network_type_a2b,
SPI = 12, SPI = icsneoc2_network_type_spi,
MDIO = 13, MDIO = icsneoc2_network_type_mdio,
AutomotiveEthernet = 14, AutomotiveEthernet = icsneoc2_network_type_automotive_ethernet,
Any = 0xFE, // Never actually set as type, but used as flag for filtering
Other = 0xFF // This must always be last entry
Maxsize = icsneoc2_network_type_maxsize,
Any = icsneoc2_network_type_any, // Never actually set as type, but used as flag for filtering
Other = icsneoc2_network_type_other
}; };
enum class CoreMini : uint8_t { enum class CoreMini : uint8_t {
DWCAN_01 = 0, DWCAN_01 = 0,

View File

@ -5,12 +5,15 @@
#include "icsneo/communication/message/canmessage.h" #include "icsneo/communication/message/canmessage.h"
#include "icsneo/api/eventmanager.h" #include "icsneo/api/eventmanager.h"
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include <optional> #include <optional>
namespace icsneo { namespace icsneo {
std::optional<uint8_t> CAN_LengthToDLC(size_t dataLength, bool fd);
typedef uint16_t icscm_bitfield; typedef uint16_t icscm_bitfield;
#pragma pack(push,2) #pragma pack(push,2)

View File

@ -735,8 +735,8 @@ public:
bool setValueLiveData(std::shared_ptr<LiveDataSetValueMessage> message); bool setValueLiveData(std::shared_ptr<LiveDataSetValueMessage> message);
enum class DiskFormatDirective : uint8_t { enum class DiskFormatDirective : uint8_t {
Continue, Continue = icsneoc2_disk_format_directive_continue,
Stop Stop = icsneoc2_disk_format_directive_stop,
}; };
using DiskFormatProgress = std::function<DiskFormatDirective(uint64_t sectorsFormatted, uint64_t sectorsTotal)>; using DiskFormatProgress = std::function<DiskFormatDirective(uint64_t sectorsFormatted, uint64_t sectorsTotal)>;

View File

@ -1,11 +1,14 @@
#ifndef __DEVICETYPE_H_ #ifndef __DEVICETYPE_H_
#define __DEVICETYPE_H_ #define __DEVICETYPE_H_
#include "icsneo/icsneoc2types.h"
// Hold the length of the longest name, so that C applications can allocate memory accordingly // Hold the length of the longest name, so that C applications can allocate memory accordingly
// Currently the longest is "Intrepid Ethernet Evaluation Board" // Currently the longest is "Intrepid Ethernet Evaluation Board"
#define ICSNEO_DEVICETYPE_LONGEST_NAME (35 + 1) // Add 1 so that if someone forgets, they still have space for null terminator #define ICSNEO_DEVICETYPE_LONGEST_NAME (35 + 1) // Add 1 so that if someone forgets, they still have space for null terminator
#define ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION (ICSNEO_DEVICETYPE_LONGEST_NAME + 7) // 6 character serial, plus space #define ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION (ICSNEO_DEVICETYPE_LONGEST_NAME + 7) // 6 character serial, plus space
#ifndef __cplusplus #ifndef __cplusplus
#include <stdint.h> #include <stdint.h>
@ -23,68 +26,68 @@ public:
// This enum used to be a bitfield, but has since become an enum as we have more than 32 devices // This enum used to be a bitfield, but has since become an enum as we have more than 32 devices
// Adding something? Make sure you update the type string and C-compatible defines below! // Adding something? Make sure you update the type string and C-compatible defines below!
enum Enum : devicetype_t { enum Enum : devicetype_t {
Unknown = (0x00000000), Unknown = icsneoc2_devicetype_unknown,
BLUE = (0x00000001), BLUE = icsneoc2_devicetype_blue,
ECU_AVB = (0x00000002), ECU_AVB = icsneoc2_devicetype_ecu_avb,
RADSupermoon = (0x00000003), RADSupermoon = icsneoc2_devicetype_rad_supermoon,
DW_VCAN = (0x00000004), DW_VCAN = icsneoc2_devicetype_dw_vcan,
RADMoon2 = (0x00000005), RADMoon2 = icsneoc2_devicetype_rad_moon2,
RADMars = (0x00000006), RADMars = icsneoc2_devicetype_rad_mars,
VCAN4_1 = (0x00000007), VCAN4_1 = icsneoc2_devicetype_vcan41,
FIRE = (0x00000008), FIRE = icsneoc2_devicetype_fire,
RADPluto = (0x00000009), RADPluto = icsneoc2_devicetype_rad_pluto,
VCAN4_2EL = (0x0000000a), VCAN4_2EL = icsneoc2_devicetype_vcan42_el,
RADIO_CANHUB = (0x0000000b), RADIO_CANHUB = icsneoc2_devicetype_radio_canhub,
NEOECU12 = (0x0000000c), NEOECU12 = icsneoc2_devicetype_neo_ecu12,
OBD2_LCBADGE = (0x0000000d), OBD2_LCBADGE = icsneoc2_devicetype_obd2_lc_badge,
RADMoonDuo = (0x0000000e), RADMoonDuo = icsneoc2_devicetype_rad_moon_duo,
FIRE3 = (0x0000000f), FIRE3 = icsneoc2_devicetype_fire3,
VCAN3 = (0x00000010), VCAN3 = icsneoc2_devicetype_vcan3,
RADJupiter = (0x00000011), RADJupiter = icsneoc2_devicetype_rad_jupiter,
VCAN4_IND = (0x00000012), VCAN4_IND = icsneoc2_devicetype_vcan4_industrial,
RADGigastar = (0x00000013), RADGigastar = icsneoc2_devicetype_rad_gigastar,
RED2 = (0x00000014), RED2 = icsneoc2_devicetype_red2,
EtherBADGE = (0x00000016), EtherBADGE = icsneoc2_devicetype_etherbadge,
RAD_A2B = (0x00000017), RAD_A2B = icsneoc2_devicetype_rad_a2b,
RADEpsilon = (0x00000018), RADEpsilon = icsneoc2_devicetype_rad_epsilon,
RADEpsilonXL = (0x0000001e), RADEpsilonXL = icsneoc2_devicetype_rad_epsilon_xl,
RADGalaxy2 = (0x00000021), RADGalaxy2 = icsneoc2_devicetype_rad_galaxy2,
RADMoon3 = (0x00000023), RADMoon3 = icsneoc2_devicetype_rad_moon3,
RADComet = (0x00000024), RADComet = icsneoc2_devicetype_rad_comet,
FIRE3_FlexRay = (0x00000025), FIRE3_FlexRay = icsneoc2_devicetype_fire3_flexray,
Connect = (0x00000026), Connect = icsneoc2_devicetype_connect,
RADComet3 = (0x00000027), RADComet3 = icsneoc2_devicetype_rad_comet3,
RADMoonT1S = (0x00000028), RADMoonT1S = icsneoc2_devicetype_rad_moon_t1s,
RADGigastar2 = (0x00000029), RADGigastar2 = icsneoc2_devicetype_rad_gigastar2,
FIRE3_T1S_LIN = (0x0000002A), FIRE3_T1S_LIN = icsneoc2_devicetype_fire3_t1s_lin,
FIRE3_T1S_SENT = (0x0000002B), FIRE3_T1S_SENT = icsneoc2_devicetype_fire3_t1s_sent,
RADGemini = (0x0000002C), RADGemini = icsneoc2_devicetype_rad_gemini,
RED = (0x00000040), RED = icsneoc2_devicetype_red,
ECU = (0x00000080), ECU = icsneoc2_devicetype_ecu,
IEVB = (0x00000100), IEVB = icsneoc2_devicetype_ievb,
Pendant = (0x00000200), Pendant = icsneoc2_devicetype_pendant,
OBD2_PRO = (0x00000400), OBD2_PRO = icsneoc2_devicetype_obd2_pro,
ECUChip_UART = (0x00000800), ECUChip_UART = icsneoc2_devicetype_ecuchip_uart,
PLASMA = (0x00001000), PLASMA = icsneoc2_devicetype_plasma,
DONT_REUSE0 = (0x00002000), // Previously FIRE_VNET DONT_REUSE0 = 0x00002000, // Previously FIRE_VNET
NEOAnalog = (0x00004000), NEOAnalog = icsneoc2_devicetype_neo_analog,
CT_OBD = (0x00008000), CT_OBD = icsneoc2_devicetype_ct_obd,
DONT_REUSE1 = (0x00010000), // Previously PLASMA_1_12 DONT_REUSE1 = 0x00010000, // Previously PLASMA_1_12
DONT_REUSE2 = (0x00020000), // Previously PLASMA_1_13 DONT_REUSE2 = 0x00020000, // Previously PLASMA_1_13
ION = (0x00040000), ION = icsneoc2_devicetype_ion,
RADStar = (0x00080000), RADStar = icsneoc2_devicetype_rad_star,
DONT_REUSE3 = (0x00100000), // Previously ION3 DONT_REUSE3 = 0x00100000, // Previously ION3
VCAN4_4 = (0x00200000), VCAN4_4 = icsneoc2_devicetype_vcan44,
VCAN4_2 = (0x00400000), VCAN4_2 = icsneoc2_devicetype_vcan42,
CMProbe = (0x00800000), CMProbe = icsneoc2_devicetype_cm_probe,
EEVB = (0x01000000), EEVB = icsneoc2_devicetype_eevb,
VCANrf = (0x02000000), VCANrf = icsneoc2_devicetype_vcan_rf,
FIRE2 = (0x04000000), FIRE2 = icsneoc2_devicetype_fire2,
Flex = (0x08000000), Flex = icsneoc2_devicetype_flex,
RADGalaxy = (0x10000000), RADGalaxy = icsneoc2_devicetype_rad_galaxy,
RADStar2 = (0x20000000), RADStar2 = icsneoc2_devicetype_rad_star2,
VividCAN = (0x40000000), VividCAN = icsneoc2_devicetype_vividcan,
OBD2_SIM = (0x80000000) OBD2_SIM = devicetype_t(icsneoc2_devicetype_obd2_sim)
}; };
/** /**
@ -239,68 +242,68 @@ private:
#endif // __cplusplus #endif // __cplusplus
#ifdef __ICSNEOC_H_ // We are using the C API, so we want C-compatible defines #ifdef __ICSNEOC_H_ // We are using the C API, so we want C-compatible defines
#define ICSNEO_DEVICETYPE_UNKNOWN ((devicetype_t)0x00000000) #define ICSNEO_DEVICETYPE_UNKNOWN ((devicetype_t)icsneoc2_devicetype_unknown)
#define ICSNEO_DEVICETYPE_BLUE ((devicetype_t)0x00000001) #define ICSNEO_DEVICETYPE_BLUE ((devicetype_t)icsneoc2_devicetype_blue)
#define ICSNEO_DEVICETYPE_ECU_AVB ((devicetype_t)0x00000002) #define ICSNEO_DEVICETYPE_ECU_AVB ((devicetype_t)icsneoc2_devicetype_ecu_avb)
#define ICSNEO_DEVICETYPE_RADSUPERMOON ((devicetype_t)0x00000003) #define ICSNEO_DEVICETYPE_RADSUPERMOON ((devicetype_t)icsneoc2_devicetype_rad_supermoon)
#define ICSNEO_DEVICETYPE_DW_VCAN ((devicetype_t)0x00000004) #define ICSNEO_DEVICETYPE_DW_VCAN ((devicetype_t)icsneoc2_devicetype_dw_vcan)
#define ICSNEO_DEVICETYPE_RADMOON2 ((devicetype_t)0x00000005) #define ICSNEO_DEVICETYPE_RADMOON2 ((devicetype_t)icsneoc2_devicetype_rad_moon2)
#define ICSNEO_DEVICETYPE_RADMARS ((devicetype_t)0x00000006) #define ICSNEO_DEVICETYPE_RADMARS ((devicetype_t)icsneoc2_devicetype_rad_mars)
#define ICSNEO_DEVICETYPE_VCAN4_1 ((devicetype_t)0x00000007) #define ICSNEO_DEVICETYPE_VCAN4_1 ((devicetype_t)icsneoc2_devicetype_vcan41)
#define ICSNEO_DEVICETYPE_FIRE ((devicetype_t)0x00000008) #define ICSNEO_DEVICETYPE_FIRE ((devicetype_t)icsneoc2_devicetype_fire)
#define ICSNEO_DEVICETYPE_RADPLUTO ((devicetype_t)0x00000009) #define ICSNEO_DEVICETYPE_RADPLUTO ((devicetype_t)icsneoc2_devicetype_rad_pluto)
#define ICSNEO_DEVICETYPE_VCAN4_2EL ((devicetype_t)0x0000000a) #define ICSNEO_DEVICETYPE_VCAN4_2EL ((devicetype_t)icsneoc2_devicetype_vcan42_el)
#define ICSNEO_DEVICETYPE_RADIO_CANHUB ((devicetype_t)0x0000000b) #define ICSNEO_DEVICETYPE_RADIO_CANHUB ((devicetype_t)icsneoc2_devicetype_radio_canhub)
#define ICSNEO_DEVICETYPE_NEOECU12 ((devicetype_t)0x0000000c) #define ICSNEO_DEVICETYPE_NEOECU12 ((devicetype_t)icsneoc2_devicetype_neo_ecu12)
#define ICSNEO_DEVICETYPE_OBD2_LCBADGE ((devicetype_t)0x0000000d) #define ICSNEO_DEVICETYPE_OBD2_LCBADGE ((devicetype_t)icsneoc2_devicetype_obd2_lc_badge)
#define ICSNEO_DEVICETYPE_RADMOONDUO ((devicetype_t)0x0000000e) #define ICSNEO_DEVICETYPE_RADMOONDUO ((devicetype_t)icsneoc2_devicetype_rad_moon_duo)
#define ICSNEO_DEVICETYPE_FIRE3 ((devicetype_t)0x0000000f) #define ICSNEO_DEVICETYPE_FIRE3 ((devicetype_t)icsneoc2_devicetype_fire3)
#define ICSNEO_DEVICETYPE_VCAN3 ((devicetype_t)0x00000010) #define ICSNEO_DEVICETYPE_VCAN3 ((devicetype_t)icsneoc2_devicetype_vcan3)
#define ICSNEO_DEVICETYPE_RADJUPITER ((devicetype_t)0x00000011) #define ICSNEO_DEVICETYPE_RADJUPITER ((devicetype_t)icsneoc2_devicetype_rad_jupiter)
#define ICSNEO_DEVICETYPE_VCAN4_IND ((devicetype_t)0x00000012) #define ICSNEO_DEVICETYPE_VCAN4_IND ((devicetype_t)icsneoc2_devicetype_vcan4_industrial)
#define ICSNEO_DEVICETYPE_RADGIGASTAR ((devicetype_t)0x00000013) #define ICSNEO_DEVICETYPE_RADGIGASTAR ((devicetype_t)icsneoc2_devicetype_rad_gigastar)
#define ICSNEO_DEVICETYPE_RED2 ((devicetype_t)0x00000014) #define ICSNEO_DEVICETYPE_RED2 ((devicetype_t)icsneoc2_devicetype_red2)
#define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) #define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)icsneoc2_devicetype_etherbadge)
#define ICSNEO_DEVICETYPE_RAD_A2B ((devicetype_t)0x00000017) #define ICSNEO_DEVICETYPE_RAD_A2B ((devicetype_t)icsneoc2_devicetype_rad_a2b)
#define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)0x00000018) #define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)icsneoc2_devicetype_rad_epsilon)
#define ICSNEO_DEVICETYPE_RADEPSILONXL ((devicetype_t)0x0000001e) #define ICSNEO_DEVICETYPE_RADEPSILONXL ((devicetype_t)icsneoc2_devicetype_rad_epsilon_xl)
#define ICSNEO_DEVICETYPE_RADGALAXY2 ((devicetype_t)0x00000021) #define ICSNEO_DEVICETYPE_RADGALAXY2 ((devicetype_t)icsneoc2_devicetype_rad_galaxy2)
#define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023) #define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)icsneoc2_devicetype_rad_moon3)
#define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024) #define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)icsneoc2_devicetype_rad_comet)
#define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)0x00000025) #define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)icsneoc2_devicetype_fire3_flexray)
#define ICSNEO_DEVICETYPE_CONNECT ((devicetype_t)0x00000026) #define ICSNEO_DEVICETYPE_CONNECT ((devicetype_t)icsneoc2_devicetype_connect)
#define ICSNEO_DEVICETYPE_RADCOMET3 ((devicetype_t)0x00000027) #define ICSNEO_DEVICETYPE_RADCOMET3 ((devicetype_t)icsneoc2_devicetype_rad_comet3)
#define ICSNEO_DEVICETYPE_RADMOONT1S ((devicetype_t)0x00000028) #define ICSNEO_DEVICETYPE_RADMOONT1S ((devicetype_t)icsneoc2_devicetype_rad_moon_t1s)
#define ICSNEO_DEVICETYPE_RADGIGASTAR2 ((devicetype_t)0x00000029) #define ICSNEO_DEVICETYPE_RADGIGASTAR2 ((devicetype_t)icsneoc2_devicetype_rad_gigastar2)
#define ICSNEO_DEVICETYPE_FIRE3_T1S_LIN ((devicetype_t)0x0000002A) #define ICSNEO_DEVICETYPE_FIRE3_T1S_LIN ((devicetype_t)icsneoc2_devicetype_fire3_t1s_lin)
#define ICSNEO_DEVICETYPE_FIRE3_T1S_SENT ((devicetype_t)0x0000002B) #define ICSNEO_DEVICETYPE_FIRE3_T1S_SENT ((devicetype_t)icsneoc2_devicetype_fire3_t1s_sent)
#define ICSNEO_DEVICETYPE_RADGEMINI ((devicetype_t)0x0000002C) #define ICSNEO_DEVICETYPE_RADGEMINI ((devicetype_t)icsneoc2_devicetype_rad_gemini)
#define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040) #define ICSNEO_DEVICETYPE_RED ((devicetype_t)icsneoc2_devicetype_red)
#define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080) #define ICSNEO_DEVICETYPE_ECU ((devicetype_t)icsneoc2_devicetype_ecu)
#define ICSNEO_DEVICETYPE_IEVB ((devicetype_t)0x00000100) #define ICSNEO_DEVICETYPE_IEVB ((devicetype_t)icsneoc2_devicetype_ievb)
#define ICSNEO_DEVICETYPE_PENDANT ((devicetype_t)0x00000200) #define ICSNEO_DEVICETYPE_PENDANT ((devicetype_t)icsneoc2_devicetype_pendant)
#define ICSNEO_DEVICETYPE_OBD2_PRO ((devicetype_t)0x00000400) #define ICSNEO_DEVICETYPE_OBD2_PRO ((devicetype_t)icsneoc2_devicetype_obd2_pro)
#define ICSNEO_DEVICETYPE_ECUCHIP_UART ((devicetype_t)0x00000800) #define ICSNEO_DEVICETYPE_ECUCHIP_UART ((devicetype_t)icsneoc2_devicetype_ecuchip_uart)
#define ICSNEO_DEVICETYPE_PLASMA ((devicetype_t)0x00001000) #define ICSNEO_DEVICETYPE_PLASMA ((devicetype_t)icsneoc2_devicetype_plasma)
#define ICSNEO_DEVICETYPE_DONT_REUSE0 ((devicetype_t)0x00002000) // Previously FIRE_VNET #define ICSNEO_DEVICETYPE_DONT_REUSE0 ((devicetype_t)0x00002000) // Previously FIRE_VNET
#define ICSNEO_DEVICETYPE_NEOANALOG ((devicetype_t)0x00004000) #define ICSNEO_DEVICETYPE_NEOANALOG ((devicetype_t)icsneoc2_devicetype_neo_analog)
#define ICSNEO_DEVICETYPE_CT_OBD ((devicetype_t)0x00008000) #define ICSNEO_DEVICETYPE_CT_OBD ((devicetype_t)icsneoc2_devicetype_ct_obd)
#define ICSNEO_DEVICETYPE_DONT_REUSE1 ((devicetype_t)0x00010000) // Previously PLASMA_1_12 #define ICSNEO_DEVICETYPE_DONT_REUSE1 ((devicetype_t)0x00010000) // Previously PLASMA_1_12
#define ICSNEO_DEVICETYPE_DONT_REUSE2 ((devicetype_t)0x00020000) // Previously PLASMA_1_13 #define ICSNEO_DEVICETYPE_DONT_REUSE2 ((devicetype_t)0x00020000) // Previously PLASMA_1_13
#define ICSNEO_DEVICETYPE_ION ((devicetype_t)0x00040000) #define ICSNEO_DEVICETYPE_ION ((devicetype_t)icsneoc2_devicetype_ion)
#define ICSNEO_DEVICETYPE_RADSTAR ((devicetype_t)0x00080000) #define ICSNEO_DEVICETYPE_RADSTAR ((devicetype_t)icsneoc2_devicetype_rad_star)
#define ICSNEO_DEVICETYPE_DONT_REUSE3 ((devicetype_t)0x00100000) // Previously ION3 #define ICSNEO_DEVICETYPE_DONT_REUSE3 ((devicetype_t)0x00100000) // Previously ION3
#define ICSNEO_DEVICETYPE_VCAN4_4 ((devicetype_t)0x00200000) #define ICSNEO_DEVICETYPE_VCAN4_4 ((devicetype_t)icsneoc2_devicetype_vcan44)
#define ICSNEO_DEVICETYPE_VCAN4_2 ((devicetype_t)0x00400000) #define ICSNEO_DEVICETYPE_VCAN4_2 ((devicetype_t)icsneoc2_devicetype_vcan42)
#define ICSNEO_DEVICETYPE_CMPROBE ((devicetype_t)0x00800000) #define ICSNEO_DEVICETYPE_CMPROBE ((devicetype_t)icsneoc2_devicetype_cm_probe)
#define ICSNEO_DEVICETYPE_EEVB ((devicetype_t)0x01000000) #define ICSNEO_DEVICETYPE_EEVB ((devicetype_t)icsneoc2_devicetype_eevb)
#define ICSNEO_DEVICETYPE_VCANRF ((devicetype_t)0x02000000) #define ICSNEO_DEVICETYPE_VCANRF ((devicetype_t)icsneoc2_devicetype_vcan_rf)
#define ICSNEO_DEVICETYPE_FIRE2 ((devicetype_t)0x04000000) #define ICSNEO_DEVICETYPE_FIRE2 ((devicetype_t)icsneoc2_devicetype_fire2)
#define ICSNEO_DEVICETYPE_FLEX ((devicetype_t)0x08000000) #define ICSNEO_DEVICETYPE_FLEX ((devicetype_t)icsneoc2_devicetype_flex)
#define ICSNEO_DEVICETYPE_RADGALAXY ((devicetype_t)0x10000000) #define ICSNEO_DEVICETYPE_RADGALAXY ((devicetype_t)icsneoc2_devicetype_rad_galaxy)
#define ICSNEO_DEVICETYPE_RADSTAR2 ((devicetype_t)0x20000000) #define ICSNEO_DEVICETYPE_RADSTAR2 ((devicetype_t)icsneoc2_devicetype_rad_star2)
#define ICSNEO_DEVICETYPE_VIVIDCAN ((devicetype_t)0x40000000) #define ICSNEO_DEVICETYPE_VIVIDCAN ((devicetype_t)icsneoc2_devicetype_vividcan)
#define ICSNEO_DEVICETYPE_OBD2_SIM ((devicetype_t)0x80000000) #define ICSNEO_DEVICETYPE_OBD2_SIM ((devicetype_t)icsneoc2_devicetype_obd2_sim)
#endif #endif
#endif #endif

View File

@ -3,6 +3,7 @@
#include <stdint.h> #include <stdint.h>
#include "icsneo/platform/unaligned.h" #include "icsneo/platform/unaligned.h"
#include "icsneo/icsneoc2types.h"
#pragma pack(push, 2) #pragma pack(push, 2)
@ -48,24 +49,24 @@ enum
enum AELinkMode enum AELinkMode
{ {
AE_LINK_INVALID = -1, AE_LINK_INVALID = icsneoc2_ae_link_mode_invalid,
AE_LINK_AUTO = 0, AE_LINK_AUTO = icsneoc2_ae_link_mode_auto,
AE_LINK_MASTER, AE_LINK_MASTER = icsneoc2_ae_link_mode_master,
AE_LINK_SLAVE AE_LINK_SLAVE = icsneoc2_ae_link_mode_slave
}; };
enum EthPhyLinkMode enum EthPhyLinkMode
{ {
ETH_LINK_MODE_AUTO_NEGOTIATION = 0, ETH_LINK_MODE_AUTO_NEGOTIATION = icsneoc2_eth_phy_link_mode_auto_negotiation,
ETH_LINK_MODE_10MBPS_HALFDUPLEX, ETH_LINK_MODE_10MBPS_HALFDUPLEX = icsneoc2_eth_phy_link_mode_10mbps_halfduplex,
ETH_LINK_MODE_10MBPS_FULLDUPLEX, ETH_LINK_MODE_10MBPS_FULLDUPLEX = icsneoc2_eth_phy_link_mode_10mbps_full_duplex,
ETH_LINK_MODE_100MBPS_HALFDUPLEX, ETH_LINK_MODE_100MBPS_HALFDUPLEX = icsneoc2_eth_phy_link_mode_100mbps_half_duplex,
ETH_LINK_MODE_100MBPS_FULLDUPLEX, ETH_LINK_MODE_100MBPS_FULLDUPLEX = icsneoc2_eth_phy_link_mode_100mbps_full_duplex,
ETH_LINK_MODE_1GBPS_HALFDUPLEX, ETH_LINK_MODE_1GBPS_HALFDUPLEX = icsneoc2_eth_phy_link_mode_1gbps_half_duplex,
ETH_LINK_MODE_1GBPS_FULLDUPLEX, ETH_LINK_MODE_1GBPS_FULLDUPLEX = icsneoc2_eth_phy_link_mode_1gbps_full_duplex,
ETH_LINK_MODE_2_5GBPS_FULLDUPLEX, ETH_LINK_MODE_2_5GBPS_FULLDUPLEX = icsneoc2_eth_phy_link_mode_2_5gbps_full_duplex,
ETH_LINK_MODE_5GBPS_FULLDUPLEX, ETH_LINK_MODE_5GBPS_FULLDUPLEX = icsneoc2_eth_phy_link_mode_5gbps_full_duplex,
ETH_LINK_MODE_10GBPS_FULLDUPLEX ETH_LINK_MODE_10GBPS_FULLDUPLEX = icsneoc2_eth_phy_link_mode_10gbps_full_duplex
}; };
typedef struct typedef struct
@ -615,10 +616,10 @@ enum : uint8_t
/* Mode in LIN_SETTINGS */ /* Mode in LIN_SETTINGS */
enum LINMode enum LINMode
{ {
SLEEP_MODE, SLEEP_MODE = icsneoc2_lin_mode_sleep,
SLOW_MODE, SLOW_MODE = icsneoc2_lin_mode_slow,
NORMAL_MODE, NORMAL_MODE = icsneoc2_lin_mode_normal,
FAST_MODE FAST_MODE = icsneoc2_lin_mode_fast
}; };
typedef struct _LIN_SETTINGS typedef struct _LIN_SETTINGS
@ -752,12 +753,12 @@ namespace icsneo {
enum class MiscIOAnalogVoltage : uint8_t enum class MiscIOAnalogVoltage : uint8_t
{ {
V0 = 0, V0 = icsneoc2_misc_io_analog_voltage_v0,
V1 = 1, V1 = icsneoc2_misc_io_analog_voltage_v1,
V2 = 2, V2 = icsneoc2_misc_io_analog_voltage_v2,
V3 = 3, V3 = icsneoc2_misc_io_analog_voltage_v3,
V4 = 4, V4 = icsneoc2_misc_io_analog_voltage_v4,
V5 = 5 V5 = icsneoc2_misc_io_analog_voltage_v5
}; };
class IDeviceSettings { class IDeviceSettings {

View File

@ -6,12 +6,13 @@
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include <icsneo/api/eventmanager.h> #include <icsneo/api/eventmanager.h>
#include <icsneo/icsneoc2types.h>
namespace icsneo { namespace icsneo {
enum class DiskLayout : uint8_t { enum class DiskLayout : uint8_t {
Spanned = 0, Spanned = icsneoc2_disk_layout_spanned,
RAID0 = 1 RAID0 = icsneoc2_disk_layout_raid0
}; };
struct DiskInfo { struct DiskInfo {

View File

@ -0,0 +1,919 @@
#ifndef __ICSNEOC2_H_
#define __ICSNEOC2_H_
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <icsneo/icsneoc2types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct icsneoc2_device_info_t icsneoc2_device_info_t;
typedef struct icsneoc2_device_t icsneoc2_device_t;
typedef struct icsneoc2_message_t icsneoc2_message_t;
typedef struct icsneoc2_event_t icsneoc2_event_t;
typedef enum _icsneoc2_error_t {
icsneoc2_error_success, // Function was successful
icsneoc2_error_invalid_parameters, // Invalid parameters, typically because of a NULL reference.
icsneoc2_error_open_failed, // Error opening the device.
icsneoc2_error_go_online_failed, // Error going online.
icsneoc2_error_enable_message_polling_failed, // Error enabling message polling.
icsneoc2_error_sync_rtc_failed, // Error syncing RTC.
icsneoc2_error_get_messages_failed, // Error getting messages.
icsneoc2_error_invalid_type, // Generic invalid type error
icsneoc2_error_rtc_failure, // Generic RTC error code
icsneoc2_error_get_settings_failure, // Error getting settings
icsneoc2_error_set_settings_failure, // Error setting settings
icsneoc2_error_transmit_message_failed, // Failed to transmit message
icsneoc2_error_string_copy_failed, // Failed to copy string to buffer
icsneoc2_error_invalid_device, // Invalid device parameter
icsneoc2_error_invalid_message, // Invalid message parameter
icsneoc2_error_out_of_memory, // Out of memory
icsneoc2_error_format_disk_failed, // Failed to format disk
icsneoc2_error_script_start_failed, // Failed to start script
icsneoc2_error_script_stop_failed, // Failed to stop script
icsneoc2_error_script_clear_failed, // Failed to clear script
icsneoc2_error_script_upload_failed, // Failed to upload coremini script
icsneoc2_error_script_load_prepare_failed, // Failed to prepare script load
// NOTE: Any new values added here should be updated in icsneoc2_error_code_get
icsneoc2_error_maxsize
} _icsneoc2_error_t;
typedef uint32_t icsneoc2_error_t;
static const icsneoc2_open_options_t icsneoc2_open_options_default =
ICSNEOC2_OPEN_OPTIONS_GO_ONLINE | ICSNEOC2_OPEN_OPTIONS_SYNC_RTC | ICSNEOC2_OPEN_OPTIONS_ENABLE_AUTO_UPDATE;
/**
* Get the error string for an error code.
*
* @param[in] error_code The error code to get the description of.
* @param[out] value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_error_code_get(icsneoc2_error_t error_code, char* value, size_t* value_length);
/**
* Get the device type string for a icsneoc2_devicetype_t.
*
* @param[in] device_type The device type to get the description of.
* @param[out] value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_type_name_get(icsneoc2_devicetype_t device_type, char* value, size_t* value_length);
/**
* Enumerate connected devices. Returns head of an opaque linked list.
* Pass 0 for device_type to enumerate all devices, or a specific type to filter.
*
* @param[in] device_type The device type to filter by, or 0 for all devices.
* @param[out] devices Pointer to receive the head of the device info linked list.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*
* @see icsneoc2_enumeration_free
*/
icsneoc2_error_t icsneoc2_device_enumerate(icsneoc2_devicetype_t device_type, icsneoc2_device_info_t** devices);
/**
* Free an enumeration list returned by icsneoc2_device_enumerate().
* Safe to call after opening devices from the list.
*
* @param[in] devices The head of the device info linked list to free.
*/
void icsneoc2_enumeration_free(icsneoc2_device_info_t* devices);
/**
* Advance to the next device in an enumeration list.
*
* @param[in] device_info The current device info node.
*
* @return The next device info node, or NULL at the end of the list.
*/
icsneoc2_device_info_t* icsneoc2_device_info_next(const icsneoc2_device_info_t* device_info);
/**
* Get the serial number of an enumerated device.
*
* @param[in] device_info The device info node.
* @param[out] serial Buffer to copy the serial string into. Null terminated.
* @param[in,out] serial_length Size of the serial buffer. Modified with the length of the serial.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*/
icsneoc2_error_t icsneoc2_device_info_serial_get(const icsneoc2_device_info_t* device_info, char* serial, size_t* serial_length);
/**
* Get the device type of an enumerated device.
*
* @param[in] device_info The device info node.
* @param[out] type Pointer to receive the device type.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*/
icsneoc2_error_t icsneoc2_device_info_type_get(const icsneoc2_device_info_t* device_info, icsneoc2_devicetype_t* type);
/**
* Get the human-readable type name of an enumerated device.
*
* @param[in] device_info The device info node.
* @param[out] type_name Buffer to copy the type name into. Null terminated.
* @param[in,out] type_name_length Size of the buffer. Modified with the length of the name.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*/
icsneoc2_error_t icsneoc2_device_info_type_name_get(const icsneoc2_device_info_t* device_info, char* type_name, size_t* type_name_length);
/**
* Get the full description of an enumerated device (e.g. "neoVI FIRE 3 RS2043").
*
* @param[in] device_info The device info node.
* @param[out] description Buffer to copy the description into. Null terminated.
* @param[in,out] description_length Size of the buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*/
icsneoc2_error_t icsneoc2_device_info_description_get(const icsneoc2_device_info_t* device_info, char* description, size_t* description_length);
/**
* Check to make sure a device is valid.
*
* @param[in] device The device to check.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_is_valid(const icsneoc2_device_t* device);
/**
* Check to make sure a device is open.
*
* @param[in] device The device to check.
* @param[out] is_open true if the device is open, false otherwise
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_is_open(const icsneoc2_device_t* device, bool* is_open);
/**
* Check if a device is disconnected.
*
* @param[in] device The device to check.
* @param[out] is_disconnected true if the device is disconnected, false otherwise
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_is_disconnected(const icsneoc2_device_t* device, bool* is_disconnected);
/**
* Open a device from an enumeration node.
*
* After a successful call, icsneoc2_device_close() must be called to close the device.
*
* @param[in] device_info The device info node to open.
* @param[in] options Open options (e.g. icsneoc2_open_options_default).
* @param[out] device Pointer to receive the opened device handle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_open_failed otherwise.
*
* @see icsneoc2_device_close
*/
icsneoc2_error_t icsneoc2_device_open(const icsneoc2_device_info_t* device_info, icsneoc2_open_options_t options, icsneoc2_device_t** device);
/**
* Convenience: enumerate, find by serial, open, and free enumeration.
*
* @param[in] serial Serial number string to match (e.g. "RS2043").
* @param[in] options Open options (e.g. icsneoc2_open_options_default).
* @param[out] device Pointer to receive the opened device handle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*
* @see icsneoc2_device_close
*/
icsneoc2_error_t icsneoc2_device_open_serial(const char* serial, icsneoc2_open_options_t options, icsneoc2_device_t** device);
/**
* Convenience: enumerate, find first available device (optionally filtered by type), open, and free enumeration.
* Pass 0 for device_type to match any device.
*
* @param[in] device_type The device type to match, or 0 for any.
* @param[in] options Open options (e.g. icsneoc2_open_options_default).
* @param[out] device Pointer to receive the opened device handle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*
* @see icsneoc2_device_close
*/
icsneoc2_error_t icsneoc2_device_open_first(icsneoc2_devicetype_t device_type, icsneoc2_open_options_t options, icsneoc2_device_t** device);
/**
* Close a connection to a previously opened device.
*
* After a successful call to icsneoc2_device_open(), this function must be called to close the device.
* An already closed device will still succeed. All messages and events related to the device will be freed.
*
* @param[in,out] device Pointer to the device to close.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_device_is_valid() errors otherwise.
*
* @see icsneoc2_device_open icsneoc2_device_is_valid
*/
icsneoc2_error_t icsneoc2_device_close(icsneoc2_device_t* device);
/**
* Get the description of a device
*
* @param[in] device The device to get the description of.
* @param[out] value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_description_get(const icsneoc2_device_t* device, char* value, size_t* value_length);
/**
* Get the type of a device
*
* @param[in] device The device to get the type of.
* @param[out] value Pointer to an icsneoc2_devicetype_t to copy the type into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_type_get(const icsneoc2_device_t* device, icsneoc2_devicetype_t* value);
/**
* Get the serial of a device
*
* @param[in] device The device to get the serial of.
* @param[out] value Pointer to a buffer to copy the serial into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the serial.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_serial_get(const icsneoc2_device_t* device, char* value, size_t* value_length);
/**
* Set the online state of a device.
*
* @param[in] device The device to set the online state of.
* @param[in] go_online true to go online, false to go offline.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_go_online_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_go_online(const icsneoc2_device_t* device, bool go_online);
/**
* Get the online state of a device.
*
* @param[in] device The device to get the online state of.
* @param[out] is_online true if online, false if offline.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_is_online(const icsneoc2_device_t* device, bool* is_online);
/**
* Get the online supported state of a device.
*
* @param[in] device The device to get the online supported state of.
* @param[out] is_online_supported true if online supported, false if not.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_is_online_supported(const icsneoc2_device_t* device, bool* is_online_supported);
/**
* Set the message polling limit of a device.
*
* This will truncate the message queue to the specified limit.
*
* @param[in] device The device to enforce the message polling limit.
* @param[in] limit The limit to enforce.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_message_polling_limit_set(const icsneoc2_device_t* device, uint32_t limit);
/**
* Get the message polling limit of a device.
*
* @see icsneoc2_device_message_polling_limit_set
*
* @param[in] device The device to get the message polling limit from.
* @param[out] limit The limit to get.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_message_polling_limit_get(const icsneoc2_device_t* device, uint32_t* limit);
/**
* Get the timestamp resolution (nanoseconds) of a device
*
* @param[in] device The device to get the timestamp resolution of.
* @param[out] resolution Pointer to a uint32_t to copy the timestamp resolution in nanoseconds into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_timestamp_resolution_get(icsneoc2_device_t* device, uint32_t* resolution);
/**
* Get a message from a device
*
* @param[in] device The device to get the message from.
* @param[out] message Pointer to a icsneoc2_message_t to copy the message into.
* @param[in] timeout_ms The timeout in milliseconds to wait for a message. A value of 0 indicates a non-blocking call.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*
* @see icsneoc2_message_free
*/
icsneoc2_error_t icsneoc2_device_message_get(const icsneoc2_device_t* device, icsneoc2_message_t** message, uint32_t timeout_ms);
/**
* Transmit messages from a device
*
* @param[in] device The device to transmit the message from.
* @param[in] messages Pointer to an icsneoc2_message_t to transmit.
*
* @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_message_transmit(const icsneoc2_device_t* device, const icsneoc2_message_t* messages);
/**
* Get the network type string for a icsneoc2_network_type_t.
*
* @param[in] network_type The network type to get the description of.
* @param[out] value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_network_type_name_get(icsneoc2_network_type_t network_type, char* value, size_t* value_length);
/**
* Get the last event to occur, with an optional device filter.
*
* @param[out] event Pointer to an icsneoc2_event_t to copy the event into.
* @param[in] device Optional device filter to get event for.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*
* @see icsneoc2_event_free
*/
icsneoc2_error_t icsneoc2_event_get(icsneoc2_event_t** event, const icsneoc2_device_t* device);
/**
* Pop the last event not related to a specific device.
*
* @param[out] event Pointer to an icsneoc2_event_t to copy the event into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_event_free(icsneoc2_event_t* event);
/**
* Get the description of an event.
*
* @param[in] event The event to get the description of.
* @param[out] value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_event_description_get(const icsneoc2_event_t* event, char* value, size_t* value_length);
/**
* Get the RTC (Real time clock) of a device.
*
* @param[in] device The device to get the RTC of.
* @param[out] unix_epoch Pointer to an int64_t to copy the RTC into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_rtc_get(const icsneoc2_device_t* device, int64_t* unix_epoch);
/**
* Set the RTC (Real time clock) of a device.
*
* @param[in] device The device to set the RTC of.
* @param[in] unix_epoch int64_t to set the RTC to.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_rtc_set(const icsneoc2_device_t* device, int64_t unix_epoch);
/**
* Check if the device supports TC10.
*
* @param[in] device The device to check against.
* @param[out] supported Pointer to a bool to copy the value into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_supports_tc10(const icsneoc2_device_t* device, bool* supported);
/**
* Get the current state of a digital I/O pin.
*
* @param[in] device The device to query.
* @param[in] type The I/O pin type.
* @param[in] number The pin number (for misc/emisc types).
* @param[out] value Pointer to store the current pin state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_digital_io_get(const icsneoc2_device_t* device, icsneoc2_io_type_t type, uint32_t number, bool* value);
/**
* Set the state of a digital I/O pin.
*
* @param[in] device The device to configure.
* @param[in] type The I/O pin type.
* @param[in] number The pin number (for misc/emisc types).
* @param[in] value The desired pin state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_device_digital_io_set(const icsneoc2_device_t* device, icsneoc2_io_type_t type, uint32_t number, bool value);
/**
* Get the version of the icsneoc2 API.
*
* @param[out] value Pointer to a buffer to copy the version string into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the version string.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_version_get(char* value, size_t* value_length);
/**
* Convert a device serial number to a string.
*
* @param[in] num The serial number to convert.
* @param[out] str Pointer to a buffer to copy the serial string into. Null terminated.
* @param[in,out] str_length Size of the str buffer. Modified with the length of the serial string.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_string_copy_failed otherwise.
*/
icsneoc2_error_t icsneoc2_serial_num_to_string(uint32_t num, char* str, size_t* str_length);
/**
* Convert a device serial string to a number.
*
* @param[in] str The serial string to convert (e.g., "GS1128").
* @param[in] str_length The length of the serial string. This should match strlen(str).
* @param[out] num Pointer to store the converted serial number.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_serial_string_to_num(char* str, size_t str_length, uint32_t* num);
/**
* Get the number of disk slots on a device.
*
* @param[in] device The device to query.
* @param[out] count Pointer to receive the number of disk slots.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_disk_count_get(const icsneoc2_device_t* device, size_t* count);
/**
* Check if a device supports disk formatting.
*
* @param[in] device The device to query.
* @param[out] supported Pointer to receive true if the device supports disk formatting, false otherwise.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_supports_disk_formatting(const icsneoc2_device_t* device, bool* supported);
/**
* Query the current disk details from a device.
*
* On success, the caller owns the returned icsneoc2_disk_details_t and must free it
* with icsneoc2_disk_details_free() when done.
*
* @param[in] device The device to query.
* @param[out] disk_details Pointer to receive the allocated disk details handle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*
* @see icsneoc2_disk_details_free
*/
icsneoc2_error_t icsneoc2_device_disk_details_get(const icsneoc2_device_t* device, icsneoc2_disk_details_t** disk_details);
/**
* Free a disk details handle returned by icsneoc2_device_disk_details_get().
*
* @param[in] disk_details The disk details handle to free. May be NULL.
*/
void icsneoc2_disk_details_free(icsneoc2_disk_details_t* disk_details);
/**
* Get the number of disks described in a disk details handle.
*
* @param[in] disk_details The disk details handle.
* @param[out] count Pointer to receive the disk count.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_disk_details_count_get(const icsneoc2_disk_details_t* disk_details, size_t* count);
/**
* Get the layout of the disks (e.g. spanned or RAID0).
*
* @param[in] disk_details The disk details handle.
* @param[out] layout Pointer to receive the layout.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_disk_details_layout_get(const icsneoc2_disk_details_t* disk_details, icsneoc2_disk_layout_t* layout);
/**
* Set the layout of the disks (e.g. spanned or RAID0).
*
* @param[in] disk_details The disk details handle.
* @param[in] layout The layout to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_disk_details_layout_set(const icsneoc2_disk_details_t* disk_details, icsneoc2_disk_layout_t layout);
/**
* Get the status flags for a specific disk by index.
*
* Flags are a bitmask of icsneoc2_disk_format_flag_present, icsneoc2_disk_format_flag_initialized,
* and icsneoc2_disk_format_flag_formatted.
*
* @param[in] disk_details The disk details handle.
* @param[in] index Zero-based disk index.
* @param[out] flags Pointer to receive the flags bitmask.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters if out of range.
*/
icsneoc2_error_t icsneoc2_disk_details_flags_get(const icsneoc2_disk_details_t* disk_details, size_t index, icsneoc2_disk_format_flags_t* flags);
/**
* Set the status flags for a specific disk by index.
*
* Flags are a bitmask of icsneoc2_disk_format_flag_present, icsneoc2_disk_format_flag_initialized,
* and icsneoc2_disk_format_flag_formatted.
*
* @param[in] disk_details The disk details handle.
* @param[in] index Zero-based disk index.
* @param[in] flags Flags bitmask to apply.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters if out of range.
*/
icsneoc2_error_t icsneoc2_disk_details_flags_set(const icsneoc2_disk_details_t* disk_details, size_t index, icsneoc2_disk_format_flags_t flags);
/**
* Get the size of a specific disk by index.
*
* @param[in] disk_details The disk details handle.
* @param[in] index Zero-based disk index.
* @param[out] sectors Pointer to receive the number of sectors.
* @param[out] bytes_per_sector Pointer to receive the number of bytes per sector.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters if out of range.
*/
icsneoc2_error_t icsneoc2_disk_details_size_get(const icsneoc2_disk_details_t* disk_details, size_t index, uint64_t* sectors, uint64_t* bytes_per_sector);
/**
* Get whether a full format is configured.
*
* @param[in] disk_details The disk details handle.
* @param[out] full_format Pointer to receive true for full format, false for quick format.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_disk_details_full_format_get(const icsneoc2_disk_details_t* disk_details, bool* full_format);
/**
* Set whether to perform a full format.
*
* @param[in] disk_details The disk details handle.
* @param[in] full_format true for a full (slow) format, false for a quick format.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_disk_details_full_format_set(const icsneoc2_disk_details_t* disk_details, bool full_format);
/**
* Format the disk(s) on a device.
*
* This is a blocking call that runs until formatting completes or the progress callback
* returns icsneoc2_disk_format_directive_stop.
*
* @param[in] device The device whose disks should be formatted.
* @param[in] disk_details A disk details handle describing the format configuration.
* Use icsneoc2_device_disk_details_get() to obtain a handle, then modify flags
* (set icsneoc2_disk_format_flag_formatted on disks you want to format).
* @param[in] progress_callback Optional callback invoked periodically with progress.
* Return icsneoc2_disk_format_directive_continue to keep going, or
* icsneoc2_disk_format_directive_stop to cancel. May be NULL.
* @param[in] user_data Opaque pointer passed through to the progress callback.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_format_disk_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_format_disk(const icsneoc2_device_t* device, icsneoc2_disk_details_t* disk_details, icsneoc2_disk_format_progress_fn progress_callback, void* user_data);
/**
* Get the list of networks this device supports for receiving.
*
* If networks is NULL, only the count is written. Otherwise, up to *count network IDs
* are copied into the caller-provided buffer and *count is set to the number written.
*
* @param[in] device The device to query.
* @param[out] networks Caller-allocated array to receive network IDs, or NULL to query count only.
* @param[in,out] count On input, the maximum number of entries the buffer can hold.
* On output, the number of entries written (or total available if networks is NULL).
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_supported_rx_networks_get(const icsneoc2_device_t* device, icsneoc2_netid_t* networks, size_t* count);
/**
* Get the list of networks this device supports for transmitting.
*
* If networks is NULL, only the count is written. Otherwise, up to *count network IDs
* are copied into the caller-provided buffer and *count is set to the number written.
*
* @param[in] device The device to query.
* @param[out] networks Caller-allocated array to receive network IDs, or NULL to query count only.
* @param[in,out] count On input, the maximum number of entries the buffer can hold.
* On output, the number of entries written (or total available if networks is NULL).
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_supported_tx_networks_get(const icsneoc2_device_t* device, icsneoc2_netid_t* networks, size_t* count);
/**
* Check whether this device supports CoreMini scripts.
*
* @param[in] device The device to query.
* @param[out] supported Set to true if the device supports CoreMini scripts, false otherwise.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_device_supports_coremini_script(const icsneoc2_device_t* device, bool* supported);
/**
* Start a CoreMini script on the device.
*
* @param[in] device The device to start the script on.
* @param[in] memory_type The memory location of the script (flash or SD).
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_script_start_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_script_start(const icsneoc2_device_t* device, icsneoc2_memory_type_t memory_type);
/**
* Stop a running CoreMini script on the device.
*
* @param[in] device The device to stop the script on.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_script_stop_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_script_stop(const icsneoc2_device_t* device);
/**
* Clear a CoreMini script from the device.
*
* @param[in] device The device to clear the script from.
* @param[in] memory_type The memory location to clear the script from (flash or SD).
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_script_clear_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_script_clear(const icsneoc2_device_t* device, icsneoc2_memory_type_t memory_type);
/**
* Prepare the device for a script load operation.
*
* @param[in] device The device to prepare.
* @param[out] status Receives the prepare status code from the device.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_script_load_prepare_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_script_prepare_load(const icsneoc2_device_t* device, int8_t* status);
/**
* Upload a CoreMini script to the device from a file path.
*
* @param[in] device The device to upload to.
* @param[in] path Null-terminated file path to the CoreMini binary.
* @param[in] memory_type The memory location to upload to (flash or SD).
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_script_upload_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_coremini_upload_file(const icsneoc2_device_t* device, const char* path, icsneoc2_memory_type_t memory_type);
/**
* Upload a CoreMini script to the device from a memory buffer.
*
* @param[in] device The device to upload to.
* @param[in] data Pointer to the CoreMini binary data.
* @param[in] length Length of the data in bytes.
* @param[in] memory_type The memory location to upload to (flash or SD).
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_script_upload_failed otherwise.
*/
icsneoc2_error_t icsneoc2_device_coremini_upload(const icsneoc2_device_t* device, const uint8_t* data, size_t length, icsneoc2_memory_type_t memory_type);
/**
* Get the current script status from the device.
*
* Returns an opaque handle that must be freed with icsneoc2_script_status_free() when done.
*
* @param[in] device The device to query.
* @param[out] script_status Receives a newly allocated script status handle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
* @see icsneoc2_script_status_free
*/
icsneoc2_error_t icsneoc2_device_script_status_get(const icsneoc2_device_t* device, icsneoc2_script_status_t** script_status);
/**
* Free a script status handle returned by icsneoc2_device_script_status_get().
*
* @param[in] script_status The handle to free. May be NULL.
*/
void icsneoc2_script_status_free(icsneoc2_script_status_t* script_status);
/**
* Get whether the CoreMini script is currently running.
*
* @param[in] script_status The script status handle.
* @param[out] value Set to true if a script is running, false otherwise.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_is_coremini_running(const icsneoc2_script_status_t* script_status, bool* value);
/**
* Get whether the script is encrypted.
*
* @param[in] script_status The script status handle.
* @param[out] value Set to true if the script is encrypted, false otherwise.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_is_encrypted(const icsneoc2_script_status_t* script_status, bool* value);
/**
* Get the number of sector overflows.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the sector overflow count.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_sector_overflows_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the number of remaining sector buffers.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the remaining sector buffer count.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_remaining_sector_buffers_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the last sector written.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the last sector value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_last_sector_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the read binary size.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the read binary size in bytes.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_read_bin_size_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the minimum sector.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the minimum sector value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_min_sector_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the maximum sector.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the maximum sector value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_max_sector_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the current sector.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the current sector value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_current_sector_get(const icsneoc2_script_status_t* script_status, uint32_t* value);
/**
* Get the CoreMini creation timestamp.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the creation timestamp as a Unix epoch value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_coremini_create_time_get(const icsneoc2_script_status_t* script_status, uint64_t* value);
/**
* Get the file checksum.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the file checksum.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_file_checksum_get(const icsneoc2_script_status_t* script_status, uint16_t* value);
/**
* Get the CoreMini version.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the CoreMini version.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_coremini_version_get(const icsneoc2_script_status_t* script_status, uint16_t* value);
/**
* Get the CoreMini header size.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the CoreMini header size in bytes.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_coremini_header_size_get(const icsneoc2_script_status_t* script_status, uint16_t* value);
/**
* Get the diagnostic error code.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the diagnostic error code.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_diagnostic_error_code_get(const icsneoc2_script_status_t* script_status, uint8_t* value);
/**
* Get the diagnostic error code count.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the diagnostic error code count.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_diagnostic_error_code_count_get(const icsneoc2_script_status_t* script_status, uint8_t* value);
/**
* Get the maximum CoreMini size in kilobytes.
*
* @param[in] script_status The script status handle.
* @param[out] value Receives the maximum CoreMini size in KB.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_script_status_max_coremini_size_kb_get(const icsneoc2_script_status_t* script_status, uint16_t* value);
#ifdef __cplusplus
}
#endif
#endif // __ICSNEOC2_H_

View File

@ -0,0 +1,190 @@
#ifndef __ICSNEOC2MESSAGES_H_
#define __ICSNEOC2MESSAGES_H_
#include <icsneo/icsneoc2.h>
#include <icsneo/icsneoc2types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Create CAN message
*
* @param[out] message Pointer to icsneoc2_message_t to copy the message into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_can_create(icsneoc2_message_t** message);
/**
* Free message
*
* @param[in] message The message to free.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*
* @see icsneoc2_message_can_create icsneoc2_device_message_get
*/
icsneoc2_error_t icsneoc2_message_free(icsneoc2_message_t* message);
/**
* Get the transmission status of a message.
*
* When a message is transmitted from the device, it will be returned in the receive buffer.
* @see icsneoc2_device_messages_transmit
*
* @param[in] message The message to check.
* @param[out] value Pointer to a bool to copy the transmission status into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_is_transmit(icsneoc2_message_t* message, bool* value);
/**
* Get the Network ID (netid) of a bus message
*
* @param[in] message The message to check.
* @param[out] netid Pointer to a icsneoc2_netid_t to copy the netid into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_invalid_type otherwise.
*
* @see icsneoc2_netid_t, icsneoc2_netid_name_get
*/
icsneoc2_error_t icsneoc2_message_netid_get(icsneoc2_message_t* message, icsneoc2_netid_t* netid);
/**
* Get the netid string for a icsneoc2_netid_t.
*
* @param[in] netid The network id to get the description of.
* @param[out] value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, char* value, size_t* value_length);
/**
* Set the Network ID (netid) of a bus message
*
* @param[in] device The device to check against.
* @param[in] message The message to modify.
* @param[in] netid The netid to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_message_t* message, icsneoc2_netid_t netid);
/**
* Set the data bytes of a message
*
* @param[in] message The message to copy the data into.
* @param[in] data Pointer to a uint8_t array to copy from.
* @param[in] data_length length of the data.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_data_set(icsneoc2_message_t* message, uint8_t* data, size_t data_length);
/**
* Get the data bytes of a message
*
* @param[in] message The message to check.
* @param[out] data Pointer to a uint8_t to copy the data bytes into.
* @param[in,out] data_length Pointer to a size_t to copy the length of the data into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_data_get(icsneoc2_message_t* message, uint8_t* data, size_t* data_length);
#define ICSNEOC2_MESSAGE_CAN_FLAGS_RTR UINT64_C(0x01) // Remote Transmission Request
#define ICSNEOC2_MESSAGE_CAN_FLAGS_IDE UINT64_C(0x02) // Identifier Extension
#define ICSNEOC2_MESSAGE_CAN_FLAGS_FDF UINT64_C(0x04) // FD Format Indicator
#define ICSNEOC2_MESSAGE_CAN_FLAGS_BRS UINT64_C(0x08) // Bit Rate Switch (FD only)
#define ICSNEOC2_MESSAGE_CAN_FLAGS_ESI UINT64_C(0x10) // Error State Indicator (FD only)
typedef uint64_t icsneoc2_message_can_flags_t;
/**
* Set the CAN specific properties of a message
*
* @param[in] message The message to modify.
* @param[in] arb_id Pointer to a uint64_t containing the arbitration ID to set. If NULL, it's ignored.
* @param[in] flags Pointer to a icsneoc2_message_can_flags_t containing the flags to set. If NULL, it's ignored. See icsneoc2_message_can_flags_t for details.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_invalid_type otherwise.
*/
icsneoc2_error_t icsneoc2_message_can_props_set(icsneoc2_message_t* message, const uint64_t* arb_id, const icsneoc2_message_can_flags_t* flags);
/**
* Get the CAN specific properties of a message
*
* @param[in] message The message to check.
* @param[out] arb_id Pointer to a uint64_t to copy the arbitration ID into. If NULL, it's ignored.
* @param[out] flags Pointer to a series of flags. If NULL, it's ignored. See icsneoc2_message_can_flags_t for details.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_invalid_type otherwise.
*/
icsneoc2_error_t icsneoc2_message_can_props_get(icsneoc2_message_t* message, uint64_t* arb_id, icsneoc2_message_can_flags_t* flags);
/**
* Check if a message is valid
*
* @param[in] device The device to check against.
* @param[in] message The message to check.
* @param[out] is_valid Pointer to a bool to copy the validity of the message into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_is_valid(icsneoc2_message_t* message, bool* is_valid);
/**
* Check if a message is a raw message (message with data)
*
* @param[in] device The device to check against.
* @param[in] message The message to check.
* @param[out] is_raw Pointer to a bool to copy the raw status of the message into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_is_raw(icsneoc2_message_t* message, bool* is_raw);
/**
* Check if a message is a frame message (message with data)
*
* @param[in] device The device to check against.
* @param[in] message The message to check.
* @param[out] is_frame Pointer to a bool to copy the frame status of the message into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_is_frame(icsneoc2_message_t* message, bool* is_frame);
/**
* Check if a message is a CAN message
*
* @param[in] device The device to check against.
* @param[in] message The message to check.
* @param[out] is_can Pointer to a bool to copy the CAN status of the message into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_message_is_can(icsneoc2_message_t* message, bool* is_can);
/**
* Get the network type of a message
*
* @param[in] message The message to check.
* @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 or icsneoc2_error_invalid_type otherwise.
*
* @see icsneoc2_network_type_t, icsneoc2_network_type_name_get
*/
icsneoc2_error_t icsneoc2_message_network_type_get(icsneoc2_message_t* message, icsneoc2_network_type_t* network_type);
#ifdef __cplusplus
}
#endif
#endif // __ICSNEOC2MESSAGES_H_

View File

@ -0,0 +1,527 @@
#ifndef __ICSNEOC2SETTINGS_H_
#define __ICSNEOC2SETTINGS_H_
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <icsneo/icsneoc2.h>
#include <icsneo/icsneoc2types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Apply the default settings for a device
*
* @param[in] device The device to apply the settings for.
* @param[in] save True to make the settings permanent, false will be reverted on power cycle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_settings_apply_defaults(icsneoc2_device_t* device, bool save);
/**
* Apply the current settings for a device.
*
* This makes all settings persistent across power cycles.
*
* @param[in] device The device to apply the settings for.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_settings_apply(icsneoc2_device_t* device);
/**
* Refresh the settings for a device. This reads the current settings from the device,
* overwriting any unsaved local changes.
*
* @param[in] device The device to refresh the settings for.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_get_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_settings_refresh(icsneoc2_device_t* device);
/**
* Get the baudrate for a network
*
* @note @see icsneoc2_settings_canfd_baudrate_get for CANFD.
*
* @param[in] device The device to get the baudrate value.
* @param[in] netid The network to get the baudrate value.
* @param[out] baudrate Pointer to store the baudrate value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t* baudrate);
/**
* Set the baudrate for a network
*
* @note @see icsneoc2_settings_canfd_baudrate_set for CANFD.
*
* @param[in] device The device to set the baudrate for.
* @param[in] netid The network to set the baudrate for.
* @param[in] baudrate The baudrate to set the network to.
* @param[in] save True to make the settings permanent, false will be reverted on power cycle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t baudrate);
/**
* Get the baudrate for a CAN FD network
*
* @param[in] device The device to get the baudrate value.
* @param[in] netid The network to get the baudrate value.
* @param[out] baudrate Pointer to store the baudrate value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_canfd_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t* baudrate);
/**
* Set the baudrate for a CANFD network
*
* @param[in] device The device to set the baudrate for.
* @param[in] netid The network to set the baudrate for.
* @param[in] baudrate The baudrate to set the network to.
* @param[in] save True to make the settings permanent, false will be reverted on power cycle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_canfd_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t baudrate);
/**
* Check if termination is supported for a network.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check termination support for.
* @param[out] supported Pointer to store whether termination is supported.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_termination_is_supported(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* supported);
/**
* Check if termination can be enabled for a network.
*
* Termination may be supported but not currently able to be enabled (e.g., due to hardware constraints).
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] can_enable Pointer to store whether termination can be enabled.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_termination_can_enable(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* can_enable);
/**
* Check if termination is currently enabled for a network.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] enabled Pointer to store whether termination is currently enabled.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_termination_is_enabled(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* enabled);
/**
* Enable or disable termination for a network.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure termination for.
* @param[in] enable True to enable termination, false to disable.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_settings_termination_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool enable);
// TODO: getTerminationGroups
/**
* Check if the commander resistor is currently enabled for a network.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] enabled Pointer to store whether the commander resistor is currently enabled.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_commander_resistor_enabled(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* enabled);
/**
* Enable or disable the commander resistor for a network.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure the commander resistor for.
* @param[in] enable True to enable the commander resistor, false to disable.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_settings_commander_resistor_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool enable);
/**
* Get the LIN mode for a given network in the currently active device settings.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the LIN mode.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_lin_mode_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_lin_mode_t* value);
// TODO: setLINModeFor
/**
* Set the LIN mode for a given network in the currently active device settings.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The LIN mode to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_lin_mode_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_lin_mode_t value);
/**
* Get number of bit delays between commander ID and first responder byte for
* a given network in the currently active device settings.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the number of bit delays.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_lin_commander_response_time_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value);
/**
* Set number of bit delays between commander ID and first responder byte for
* a given network in the currently active device settings.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The number of bit delays to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_lin_commander_response_time_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value);
/**
* Get PHY enable state for switch devices (Epsilon/XL, Jupiter, etc) using port index.
* For all other devices, use icsneoc2_settings_phy_enable_for_get() instead.
*
* @param[in] device The device to check.
* @param[in] index The port index to check.
* @param[out] value Pointer to store the PHY enable state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_enable_get(icsneoc2_device_t* device, uint8_t index, bool* value);
/**
* Enable/disable PHY for switch devices (Epsilon/XL, Jupiter, etc) using port index.
* For all other devices, use icsneoc2_settings_phy_enable_for_set() instead.
*
* @param[in] device The device to configure.
* @param[in] index The port index to configure.
* @param[in] value bool to set the PHY enable state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_enable_set(icsneoc2_device_t* device, uint8_t index, bool value);
/**
* Get PHY role (Master/Slave/Auto) for switch devices (Epsilon/XL, Jupiter, etc) using port index.
* For all other devices, use icsneoc2_settings_phy_role_for_get() instead.
*
* @param[in] device The device to check.
* @param[in] index The port index to check.
* @param[out] value Pointer to store the link mode state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_mode_get(icsneoc2_device_t* device, uint8_t index, icsneoc2_ae_link_mode_t* value);
/**
* Set PHY role (Master/Slave/Auto) for switch devices (Epsilon/XL, Jupiter, etc) using port index.
* For all other devices, use icsneoc2_settings_phy_role_for_set() instead.
*
* @param[in] device The device to configure.
* @param[in] index The port index to configure.
* @param[in] value The link mode state to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_mode_set(icsneoc2_device_t* device, uint8_t index, icsneoc2_ae_link_mode_t value);
/**
* Get PHY link mode (speed and duplex) for switch devices (Epsilon/XL, Jupiter, etc) using port index.
* For all other devices, use icsneoc2_settings_phy_link_mode_for_get() instead.
*
* @param[in] device The device to check.
* @param[in] index The port index to check.
* @param[out] value Pointer to store the link mode state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_speed_get(icsneoc2_device_t* device, uint8_t index, icsneoc2_eth_phy_link_mode_t* value);
/**
* Set PHY link mode (speed and duplex) for switch devices (Epsilon/XL, Jupiter, etc) using port index.
* For all other devices, use icsneoc2_settings_phy_link_mode_for_set() instead.
*
* @param[in] device The device to configure.
* @param[in] index The port index to configure.
* @param[in] value The link mode state to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_speed_set(icsneoc2_device_t* device, uint8_t index, icsneoc2_eth_phy_link_mode_t value);
/**
* Get PHY role (Master/Slave/Auto) for network-based devices.
* For switch devices, use icsneoc2_settings_phy_mode_get() with port index instead.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the PHY role state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_role_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_ae_link_mode_t* value);
/**
* Set PHY role (Master/Slave/Auto) for network-based devices.
* For switch devices, use icsneoc2_settings_phy_mode_set() with port index instead.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The PHY role state to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_role_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_ae_link_mode_t value);
/**
* Get PHY link mode (speed and duplex) for network-based devices.
* For switch devices, use icsneoc2_settings_phy_speed_get() with port index instead.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the PHY link mode state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_link_mode_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t* value);
/**
* Set PHY link mode (speed and duplex) for network-based devices.
* For switch devices, use icsneoc2_settings_phy_speed_set() with port index instead.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The PHY link mode to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_link_mode_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t value);
/**
* Get PHY enable state for network-based devices.
* For switch devices, use icsneoc2_settings_phy_enable_get() with port index instead.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the PHY enable state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_enable_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* value);
/**
* Enable/disable PHY for network-based devices.
* For switch devices, use icsneoc2_settings_phy_enable_set() with port index instead.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The PHY enable state to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_phy_enable_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool value);
/**
* Get supported PHY link modes (combined speed+duplex) for a network.
* Each mode represents a valid hardware configuration.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] link_modes Pointer to store the supported PHY link modes. Should be at least the size of icsneoc2_eth_phy_link_mode_maxsize.
* @param[in,out] link_modes_count Pointer to the size of link_modes array. Updated with the number of link modes written to the array.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_supported_phy_link_modes_for(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t** link_modes, size_t* link_modes_count);
/**
* Check if PLCA is enabled for a network that supports 10BASE-T1S.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the PLCA enable state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_is_plca_enabled_for(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* value);
/**
* Set PLCA enabled for a network that supports 10BASE-T1S.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The PLCA enable state to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_plca_enabled_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool value);
/**
* Get the local ID for a network that supports 10BASE-T1S.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the local ID.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_local_id_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value);
/**
* Set the local ID for a network that supports 10BASE-T1S.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The local ID to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_local_id_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value);
/**
* Get the maximum number of nodes for a network that supports 10BASE-T1S.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the maximum number of nodes.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_max_nodes_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value);
/**
* Set the maximum number of nodes for a network that supports 10BASE-T1S.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The maximum number of nodes to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_max_nodes_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value);
/**
* Get the OOP Timer for a network that supports 10BASE-T1S.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the OOP Timer value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_tx_opp_timer_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value);
/**
* Set the OOP Timer for a network that supports 10BASE-T1S.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The OOP Timer value to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_tx_opp_timer_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value);
/**
* Get the Max burst timer for a network that supports 10BASE-T1S.
*
* @param[in] device The device to check.
* @param[in] netid The network ID to check.
* @param[out] value Pointer to store the Max burst timer value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_max_burst_timer_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value);
/**
* Set the Max burst timer for a network that supports 10BASE-T1S.
*
* @param[in] device The device to configure.
* @param[in] netid The network ID to configure.
* @param[in] value The Max burst timer value to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_t1s_max_burst_timer_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value);
/**
* Set the analog output enabled.
*
* @param[in] device The device to configure.
* @param[in] pin The analog output pin to configure.
* @param[in] value The analog output value to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_misc_io_analog_output_enabled_set(icsneoc2_device_t* device, uint8_t pin, uint8_t value);
/**
* Set the analog output voltage for a misc IO pin.
*
* @param[in] device The device to configure.
* @param[in] pin The analog output pin to configure.
* @param[in] value The analog output voltage to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_misc_io_analog_output_set(icsneoc2_device_t* device, uint8_t pin, icsneoc2_misc_io_analog_voltage_t value);
/**
* Check if settings are disabled.
*
* @param[in] device The device to check.
* @param[out] value Pointer to store the disabled state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_disabled_get(icsneoc2_device_t* device, bool* value);
/**
* Check if settings are read-only.
*
* @param[in] device The device to check.
* @param[out] value Pointer to store the read-only state.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
icsneoc2_error_t icsneoc2_settings_readonly_get(icsneoc2_device_t* device, bool* value);
#ifdef __cplusplus
}
#endif
#endif // __ICSNEOC2SETTINGS_H_

View File

@ -0,0 +1,405 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define ICSNEOC2_OPEN_OPTIONS_NONE UINT32_C(0x0) // No options
#define ICSNEOC2_OPEN_OPTIONS_GO_ONLINE UINT32_C(0x1) // After opening, go online
#define ICSNEOC2_OPEN_OPTIONS_SYNC_RTC UINT32_C(0x2) // After opening, sync RTC
#define ICSNEOC2_OPEN_OPTIONS_ENABLE_AUTO_UPDATE UINT32_C(0x4) // After opening, enable auto update
#define ICSNEOC2_OPEN_OPTIONS_FORCE_UPDATE UINT32_C(0x8) // After opening, force update
typedef uint32_t icsneoc2_open_options_t;
typedef enum _icsneoc2_devicetype_t {
// Ordered by numeric value to keep bitmask values grouped and predictable.
icsneoc2_devicetype_unknown = 0x00000000,
icsneoc2_devicetype_blue = 0x00000001,
icsneoc2_devicetype_ecu_avb = 0x00000002,
icsneoc2_devicetype_rad_supermoon = 0x00000003,
icsneoc2_devicetype_dw_vcan = 0x00000004,
icsneoc2_devicetype_rad_moon2 = 0x00000005,
icsneoc2_devicetype_rad_mars = 0x00000006,
icsneoc2_devicetype_vcan41 = 0x00000007,
icsneoc2_devicetype_fire = 0x00000008,
icsneoc2_devicetype_rad_pluto = 0x00000009,
icsneoc2_devicetype_vcan42_el = 0x0000000a,
icsneoc2_devicetype_radio_canhub = 0x0000000b,
icsneoc2_devicetype_neo_ecu12 = 0x0000000c,
icsneoc2_devicetype_obd2_lc_badge = 0x0000000d,
icsneoc2_devicetype_rad_moon_duo = 0x0000000e,
icsneoc2_devicetype_fire3 = 0x0000000f,
icsneoc2_devicetype_vcan3 = 0x00000010,
icsneoc2_devicetype_rad_jupiter = 0x00000011,
icsneoc2_devicetype_vcan4_industrial = 0x00000012,
icsneoc2_devicetype_rad_gigastar = 0x00000013,
icsneoc2_devicetype_red2 = 0x00000014,
icsneoc2_devicetype_etherbadge = 0x00000016,
icsneoc2_devicetype_rad_a2b = 0x00000017,
icsneoc2_devicetype_rad_epsilon = 0x00000018,
icsneoc2_devicetype_rad_epsilon_xl = 0x0000001e,
icsneoc2_devicetype_rad_galaxy2 = 0x00000021,
icsneoc2_devicetype_rad_moon3 = 0x00000023,
icsneoc2_devicetype_rad_comet = 0x00000024,
icsneoc2_devicetype_fire3_flexray = 0x00000025,
icsneoc2_devicetype_connect = 0x00000026,
icsneoc2_devicetype_rad_comet3 = 0x00000027,
icsneoc2_devicetype_rad_moon_t1s = 0x00000028,
icsneoc2_devicetype_rad_gigastar2 = 0x00000029,
icsneoc2_devicetype_fire3_t1s_lin = 0x0000002a,
icsneoc2_devicetype_fire3_t1s_sent = 0x0000002b,
icsneoc2_devicetype_rad_gemini = 0x0000002c,
icsneoc2_devicetype_red = 0x00000040,
icsneoc2_devicetype_ecu = 0x00000080,
icsneoc2_devicetype_ievb = 0x00000100,
icsneoc2_devicetype_pendant = 0x00000200,
icsneoc2_devicetype_obd2_pro = 0x00000400,
icsneoc2_devicetype_ecuchip_uart = 0x00000800,
icsneoc2_devicetype_plasma = 0x00001000,
icsneoc2_devicetype_neo_analog = 0x00004000,
icsneoc2_devicetype_ct_obd = 0x00008000,
icsneoc2_devicetype_ion = 0x00040000,
icsneoc2_devicetype_rad_star = 0x00080000,
icsneoc2_devicetype_vcan44 = 0x00200000,
icsneoc2_devicetype_vcan42 = 0x00400000,
icsneoc2_devicetype_cm_probe = 0x00800000,
icsneoc2_devicetype_eevb = 0x01000000,
icsneoc2_devicetype_vcan_rf = 0x02000000,
icsneoc2_devicetype_fire2 = 0x04000000,
icsneoc2_devicetype_flex = 0x08000000,
icsneoc2_devicetype_rad_galaxy = 0x10000000,
icsneoc2_devicetype_rad_star2 = 0x20000000,
icsneoc2_devicetype_vividcan = 0x40000000,
icsneoc2_devicetype_obd2_sim = 0x80000000,
icsneoc2_devicetype_maxsize // Must be last entry
} _icsneoc2_devicetype_t;
typedef uint32_t icsneoc2_devicetype_t;
typedef enum _icsneoc2_network_type_t {
icsneoc2_network_type_invalid = 0, // Invalid network type, used for error checking
icsneoc2_network_type_internal = 1, // Used for statuses that don't actually need to be transferred to the client application
icsneoc2_network_type_can = 2, // CAN (Controller Area Network)
icsneoc2_network_type_lin = 3, // LIN (Local Interconnect Network)
icsneoc2_network_type_flexray = 4, // FlexRay
icsneoc2_network_type_most = 5, // MOST (Media Oriented Systems Transport)
icsneoc2_network_type_ethernet = 6, // Ethernet
icsneoc2_network_type_lsftcan = 7, // LSFTCAN (Low Speed/Fault Tolerant CAN)
icsneoc2_network_type_swcan = 8, // SWCAN (Single-Wire CAN)
icsneoc2_network_type_iso9141 = 9, // ISO 9141-2 (K-Line)
icsneoc2_network_type_i2c = 10, // I2C (Inter-Integrated Circuit)
icsneoc2_network_type_a2b = 11, // A2B (Automotive Audio Bus)
icsneoc2_network_type_spi = 12, // SPI (Serial Peripheral Interface)
icsneoc2_network_type_mdio = 13, // MDIO (Management Data Input/Output)
icsneoc2_network_type_automotive_ethernet = 14, // Automotive Ethernet
// Must be the last entry, Don't use as a network type.
icsneoc2_network_type_maxsize,
// Used as a wildcard for filtering, never actually set as a type
icsneoc2_network_type_any = 0xFE,
// Used for unknown or other network types
icsneoc2_network_type_other = 0xFF
} _icsneoc2_network_type_t;
typedef uint8_t icsneoc2_network_type_t;
typedef enum _icsneoc2_netid_t {
icsneoc2_netid_device = 0,
icsneoc2_netid_dwcan_01 = 1,
icsneoc2_netid_dwcan_08 = 2,
icsneoc2_netid_swcan_01 = 3,
icsneoc2_netid_lsftcan_01 = 4,
icsneoc2_netid_fordscp = 5,
icsneoc2_netid_j1708 = 6,
icsneoc2_netid_aux = 7,
icsneoc2_netid_j1850vpw = 8,
icsneoc2_netid_iso9141 = 9,
icsneoc2_netid_disk_data = 10,
icsneoc2_netid_main51 = 11,
icsneoc2_netid_red = 12,
icsneoc2_netid_sci = 13,
icsneoc2_netid_iso9141_02 = 14,
icsneoc2_netid_iso14230 = 15,
icsneoc2_netid_lin_01 = 16,
icsneoc2_netid_ae_01 = 17,
icsneoc2_netid_ae_02 = 18,
icsneoc2_netid_ae_03 = 19,
// START Device Command Returns
// When we send a command, the device returns on one of these, depending on command
icsneoc2_netid_red_ext_memoryread = 20,
icsneoc2_netid_red_int_memoryread = 21,
icsneoc2_netid_red_dflash_read = 22,
icsneoc2_netid_neo_memory_sdread = 23,
icsneoc2_netid_can_errbits = 24,
icsneoc2_netid_neo_memory_write_done = 25,
icsneoc2_netid_red_wave_can1_logical = 26,
icsneoc2_netid_red_wave_can2_logical = 27,
icsneoc2_netid_red_wave_lin1_logical = 28,
icsneoc2_netid_red_wave_lin2_logical = 29,
icsneoc2_netid_red_wave_lin1_analog = 30,
icsneoc2_netid_red_wave_lin2_analog = 31,
icsneoc2_netid_red_wave_misc_analog = 32,
icsneoc2_netid_red_wave_miscdio2_logical = 33,
icsneoc2_netid_red_network_com_enable_ex = 34,
icsneoc2_netid_red_neovi_network = 35,
icsneoc2_netid_red_read_baud_settings = 36,
icsneoc2_netid_red_oldformat = 37,
icsneoc2_netid_red_scope_capture = 38,
icsneoc2_netid_red_hardware_excep = 39,
icsneoc2_netid_red_get_rtc = 40,
// END Device Command Returns
icsneoc2_netid_iso9141_03 = 41,
icsneoc2_netid_dwcan_02 = 42,
icsneoc2_netid_dwcan_03 = 44,
icsneoc2_netid_ae_04 = 45,
icsneoc2_netid_ae_05 = 46,
icsneoc2_netid_iso9141_04 = 47,
icsneoc2_netid_lin_02 = 48,
icsneoc2_netid_lin_03 = 49,
icsneoc2_netid_lin_04 = 50,
icsneoc2_netid_most_unused = 51,
icsneoc2_netid_red_app_error = 52,
icsneoc2_netid_cgi = 53,
icsneoc2_netid_reset_status = 54,
icsneoc2_netid_fb_status = 55,
icsneoc2_netid_app_signal_status = 56,
icsneoc2_netid_read_datalink_cm_tx_msg = 57,
icsneoc2_netid_read_datalink_cm_rx_msg = 58,
icsneoc2_netid_logging_overflow = 59,
icsneoc2_netid_read_settings = 60,
icsneoc2_netid_dwcan_04 = 61,
icsneoc2_netid_dwcan_05 = 62,
icsneoc2_netid_rs232 = 63,
icsneoc2_netid_uart_01 = 64,
icsneoc2_netid_uart_02 = 65,
icsneoc2_netid_uart_03 = 66,
icsneoc2_netid_uart_04 = 67,
icsneoc2_netid_swcan_02 = 68,
icsneoc2_netid_ethernet_daq = 69,
icsneoc2_netid_data_to_host = 70,
icsneoc2_netid_textapi_to_host = 71,
icsneoc2_netid_spi_01 = 72,
icsneoc2_netid_ae_06 = 73,
icsneoc2_netid_red_vbat = 74,
icsneoc2_netid_ae_07 = 75,
icsneoc2_netid_ae_08 = 76,
icsneoc2_netid_ae_09 = 77,
icsneoc2_netid_ae_10 = 78,
icsneoc2_netid_ae_11 = 79,
icsneoc2_netid_flexray_01a = 80,
icsneoc2_netid_flexray_01b = 81,
icsneoc2_netid_flexray_02a = 82,
icsneoc2_netid_flexray_02b = 83,
icsneoc2_netid_lin_05 = 84,
icsneoc2_netid_flexray_01 = 85,
icsneoc2_netid_flexray_02 = 86,
icsneoc2_netid_ae_12 = 87,
icsneoc2_netid_i2c_01 = 88,
icsneoc2_netid_most_25 = 90,
icsneoc2_netid_most_50 = 91,
icsneoc2_netid_most_150 = 92,
icsneoc2_netid_ethernet_01 = 93,
icsneoc2_netid_gmfsa = 94,
icsneoc2_netid_tcp = 95,
icsneoc2_netid_dwcan_06 = 96,
icsneoc2_netid_dwcan_07 = 97,
icsneoc2_netid_lin_06 = 98,
icsneoc2_netid_lsftcan_02 = 99,
icsneoc2_netid_logical_disk_info = 187,
icsneoc2_netid_wivi_command = 221,
icsneoc2_netid_script_status = 224,
icsneoc2_netid_eth_phy_control = 239,
icsneoc2_netid_extended_command = 240,
icsneoc2_netid_extended_data = 242,
icsneoc2_netid_flexray_control = 243,
icsneoc2_netid_coremini_preload = 244,
icsneoc2_netid_hw_com_latency_test = 512,
icsneoc2_netid_device_status = 513,
icsneoc2_netid_udp = 514,
icsneoc2_netid_forwarded_message = 516,
icsneoc2_netid_i2c_02 = 517,
icsneoc2_netid_i2c_03 = 518,
icsneoc2_netid_i2c_04 = 519,
icsneoc2_netid_ethernet_02 = 520,
icsneoc2_netid_ethernet_tx_wrap = 521,
icsneoc2_netid_a2b_01 = 522,
icsneoc2_netid_a2b_02 = 523,
icsneoc2_netid_ethernet_03 = 524,
icsneoc2_netid_wbms_01 = 532,
icsneoc2_netid_dwcan_09 = 534,
icsneoc2_netid_dwcan_10 = 535,
icsneoc2_netid_dwcan_11 = 536,
icsneoc2_netid_dwcan_12 = 537,
icsneoc2_netid_dwcan_13 = 538,
icsneoc2_netid_dwcan_14 = 539,
icsneoc2_netid_dwcan_15 = 540,
icsneoc2_netid_dwcan_16 = 541,
icsneoc2_netid_lin_07 = 542,
icsneoc2_netid_lin_08 = 543,
icsneoc2_netid_spi_02 = 544,
icsneoc2_netid_mdio_01 = 545,
icsneoc2_netid_mdio_02 = 546,
icsneoc2_netid_mdio_03 = 547,
icsneoc2_netid_mdio_04 = 548,
icsneoc2_netid_mdio_05 = 549,
icsneoc2_netid_mdio_06 = 550,
icsneoc2_netid_mdio_07 = 551,
icsneoc2_netid_mdio_08 = 552,
icsneoc2_netid_ae_13 = 553,
icsneoc2_netid_ae_14 = 554,
icsneoc2_netid_ae_15 = 555,
icsneoc2_netid_ae_16 = 556,
icsneoc2_netid_spi_03 = 557,
icsneoc2_netid_spi_04 = 558,
icsneoc2_netid_spi_05 = 559,
icsneoc2_netid_spi_06 = 560,
icsneoc2_netid_spi_07 = 561,
icsneoc2_netid_spi_08 = 562,
icsneoc2_netid_lin_09 = 563,
icsneoc2_netid_lin_10 = 564,
icsneoc2_netid_lin_11 = 565,
icsneoc2_netid_lin_12 = 566,
icsneoc2_netid_lin_13 = 567,
icsneoc2_netid_lin_14 = 568,
icsneoc2_netid_lin_15 = 569,
icsneoc2_netid_lin_16 = 570,
// Must be the last entry, Don't use as a NetID.
icsneoc2_netid_maxsize,
// Used as a wildcard for filtering, never actually set as a NetID
icsneoc2_netid_any = 0xfffe,
// Used for unknown or invalid NetID
icsneoc2_netid_invalid = 0xffff
} _icsneoc2_netid_t;
typedef uint16_t icsneoc2_netid_t;
typedef enum _icsneoc2_io_type_t {
icsneoc2_io_type_eth_activation = 0, // DoIP activation line (0=HiZ, 1=pulled up to VBAT)
icsneoc2_io_type_usb_host_power = 1, // USB host power control
icsneoc2_io_type_backup_power_en = 2, // Backup super capacitor enable (FIRE 2)
icsneoc2_io_type_backup_power_good = 3, // Backup super capacitor charged status (FIRE 2, read only)
icsneoc2_io_type_misc = 4, // General purpose I/O on the device
icsneoc2_io_type_emisc = 5, // Extended general purpose I/O on the device
// Must be last entry. Don't use as an IO type.
icsneoc2_io_type_maxsize
} _icsneoc2_io_type_t;
typedef uint32_t icsneoc2_io_type_t;
typedef enum _icsneoc2_lin_mode_t {
icsneoc2_lin_mode_sleep = 0,
icsneoc2_lin_mode_slow = 1,
icsneoc2_lin_mode_normal = 2,
icsneoc2_lin_mode_fast = 3,
// Must be last entry. Don't use as a LIN mode.
icsneoc2_lin_mode_maxsize
} _icsneoc2_lin_mode_t;
typedef uint32_t icsneoc2_lin_mode_t;
typedef enum _icsneoc2_ae_link_mode_t {
icsneoc2_ae_link_mode_invalid = -1, // Invalid/Unknown link mode
icsneoc2_ae_link_mode_auto = 0, // Auto select link mode
icsneoc2_ae_link_mode_master = 1, // Master mode
icsneoc2_ae_link_mode_slave = 2, // Slave mode
// Must be last entry. Don't use as an AE link mode.
icsneoc2_ae_link_mode_maxsize
} _icsneoc2_ae_link_mode_t;
typedef uint32_t icsneoc2_ae_link_mode_t;
typedef enum _icsneoc2_eth_phy_link_mode_t {
icsneoc2_eth_phy_link_mode_auto_negotiation = 1, // Auto negotiation mode
icsneoc2_eth_phy_link_mode_10mbps_halfduplex = 2, // 10 Mbps half duplex
icsneoc2_eth_phy_link_mode_10mbps_full_duplex = 3, // 10 Mbps full duplex
icsneoc2_eth_phy_link_mode_100mbps_half_duplex = 4, // 100 Mbps half duplex
icsneoc2_eth_phy_link_mode_100mbps_full_duplex = 5, // 100 Mbps full duplex
icsneoc2_eth_phy_link_mode_1gbps_half_duplex = 6, // 1 Gbps half duplex
icsneoc2_eth_phy_link_mode_1gbps_full_duplex = 7, // 1 Gbps full duplex
icsneoc2_eth_phy_link_mode_2_5gbps_full_duplex = 8, // 2.5 Gbps full duplex
icsneoc2_eth_phy_link_mode_5gbps_full_duplex = 9, // 5 Gbps full duplex
icsneoc2_eth_phy_link_mode_10gbps_full_duplex = 10, // 10 Gbps full duplex
// Must be last entry. Don't use as an Ethernet PHY link mode.
icsneoc2_eth_phy_link_mode_maxsize
} _icsneoc2_eth_phy_link_mode_t;
typedef uint32_t icsneoc2_eth_phy_link_mode_t;
typedef enum _icsneoc2_misc_io_analog_voltage_t {
icsneoc2_misc_io_analog_voltage_v0 = 0, // Analog voltage level 0V
icsneoc2_misc_io_analog_voltage_v1 = 1, // Analog voltage level 1V
icsneoc2_misc_io_analog_voltage_v2 = 2, // Analog voltage level 2V
icsneoc2_misc_io_analog_voltage_v3 = 3, // Analog voltage level 3V
icsneoc2_misc_io_analog_voltage_v4 = 4, // Analog voltage level 4V
icsneoc2_misc_io_analog_voltage_v5 = 5, // Analog voltage level 5V
// Must be last entry. Don't use as an analog voltage.
icsneoc2_misc_io_analog_voltage_maxsize
} _icsneoc2_misc_io_analog_voltage_t;
typedef uint8_t icsneoc2_misc_io_analog_voltage_t;
typedef struct icsneoc2_disk_details_t icsneoc2_disk_details_t;
typedef enum _icsneoc2_disk_layout_t {
// Spanned layout, where each disk is treated as one contiguous space and data is written to each disk until it's full before moving to the next.
icsneoc2_disk_layout_spanned = 0,
// RAID 0 layout, where data is striped across multiple disks.
icsneoc2_disk_layout_raid0 = 1,
// Must be last entry. Don't use as a disk layout.
icsneoc2_disk_layout_maxsize
} _icsneoc2_disk_layout_t;
typedef uint8_t icsneoc2_disk_layout_t;
#define ICSNEOC2_DISK_FORMAT_FLAGS_PRESENT UINT32_C(0x1) // Indicates that the disk is present
#define ICSNEOC2_DISK_FORMAT_FLAGS_INITIALIZED UINT32_C(0x2) // Indicates that the disk is initialized
#define ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED UINT32_C(0x4) // Indicates that the disk is already formatted
typedef uint32_t icsneoc2_disk_format_flags_t;
typedef enum _icsneoc2_disk_format_directive_t {
icsneoc2_disk_format_directive_continue = 0,
icsneoc2_disk_format_directive_stop = 1,
// Must be last entry. Don't use as a disk format directive.
icsneoc2_disk_format_directive_maxsize
} _icsneoc2_disk_format_directive_t;
typedef uint8_t icsneoc2_disk_format_directive_t;
typedef icsneoc2_disk_format_directive_t (*icsneoc2_disk_format_progress_fn)(
uint64_t sectors_formatted,
uint64_t total_sectors,
void* user_data
);
typedef struct icsneoc2_script_status_t icsneoc2_script_status_t;
typedef enum _icsneoc2_memory_type_t {
icsneoc2_memory_type_flash = 0, // Flash memory
icsneoc2_memory_type_sd = 1, // SD card memory
// Must be last entry. Don't use as a memory type.
icsneoc2_memory_type_maxsize
} _icsneoc2_memory_type_t;
typedef uint8_t icsneoc2_memory_type_t;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,687 @@
#include <gtest/gtest.h>
#include <icsneo/icsneoc2.h>
#include <icsneo/icsneoc2settings.h>
#include <icsneo/icsneoc2messages.h>
#include <icsneo/device/devicetype.h>
#include <vector>
#include <tuple>
// Forward declare the safe_str_copy function for testing
extern bool safe_str_copy(char* dest, size_t* dest_size, std::string_view src);
TEST(icsneoc2, test_safe_str_copy)
{
char buffer[10] = {0};
size_t buffer_size = sizeof(buffer);
// Test normal copy
ASSERT_TRUE(safe_str_copy(buffer, &buffer_size, "test"));
ASSERT_STREQ(buffer, "test");
ASSERT_EQ(buffer_size, 4);
// Test copy with string too long - buffer should be null terminated, buffer_size should reflect truncated length
buffer_size = sizeof(buffer);
ASSERT_FALSE(safe_str_copy(buffer, &buffer_size, "this is a very long string")) << buffer << ": " << buffer_size;
ASSERT_EQ(buffer[sizeof(buffer) - 1], '\0');
ASSERT_STREQ(buffer, "this is a");
ASSERT_EQ(buffer_size, 9); // truncated to buffer capacity - 1
ASSERT_EQ(buffer[sizeof(buffer) - 1], '\0');
// Test null parameters - buffer_size should be unmodified on failure
buffer_size = sizeof(buffer);
ASSERT_FALSE(safe_str_copy(NULL, &buffer_size, "test"));
ASSERT_EQ(buffer_size, sizeof(buffer));
ASSERT_FALSE(safe_str_copy(buffer, NULL, "test"));
ASSERT_FALSE(safe_str_copy(NULL, NULL, "test"));
// Test empty string
buffer_size = sizeof(buffer);
memset(buffer, 0xCA, sizeof(buffer));
ASSERT_TRUE(safe_str_copy(buffer, &buffer_size, ""));
ASSERT_STREQ(buffer, "");
ASSERT_EQ(buffer_size, 0);
// Make sure the rest of the buffer is untouched (should be 0xCA)
for (size_t i = buffer_size + 1; i < sizeof(buffer) - 1; ++i)
{
ASSERT_EQ(buffer[i], '\xCA') << i << ") '" << buffer << "': " << buffer_size;
}
// Test string that fits exactly
buffer_size = sizeof(buffer);
ASSERT_TRUE(safe_str_copy(buffer, &buffer_size, "123456789"));
ASSERT_STREQ(buffer, "123456789");
ASSERT_EQ(buffer_size, 9);
ASSERT_EQ(buffer[sizeof(buffer) - 1], '\0');
// Test zero-size buffer - should always fail and write nothing
char tiny0[1] = {0};
buffer_size = 0;
ASSERT_FALSE(safe_str_copy(tiny0, &buffer_size, "test"));
ASSERT_FALSE(safe_str_copy(tiny0, &buffer_size, ""));
// Test single-byte buffer (room for null terminator only)
char tiny1[1];
buffer_size = sizeof(tiny1);
memset(tiny1, 0xFF, sizeof(tiny1));
ASSERT_FALSE(safe_str_copy(tiny1, &buffer_size, "test")); // non-empty: truncates to just '\0'
ASSERT_EQ(tiny1[0], '\0');
// Test single-byte buffer with empty string - should succeed and write just the null terminator
buffer_size = sizeof(tiny1);
memset(tiny1, 0xFF, sizeof(tiny1));
ASSERT_TRUE(safe_str_copy(tiny1, &buffer_size, "")); // empty string fits exactly
ASSERT_EQ(tiny1[0], '\0');
ASSERT_EQ(buffer_size, 0);
}
TEST(icsneoc2, test_icsneoc2_device_enumerate)
{
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_enumerate(0, NULL));
icsneoc2_device_info_t* devices = nullptr;
ASSERT_EQ(icsneoc2_error_success, icsneoc2_device_enumerate(0, &devices));
icsneoc2_enumeration_free(devices);
}
TEST(icsneoc2, test_icsneoc2_device_is_valid)
{
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_is_valid(NULL));
}
TEST(icsneoc2, test_icsneoc2_error_invalid_parameters_and_invalid_device)
{
bool placeholderBool = false;
uint8_t placeholderInteger8 = 0;
uint32_t placeholderInteger32 = 0;
int64_t placeholderInteger64 = 0;
uint64_t placeholderUnsignedInteger64 = 0;
size_t placeholderSizeT = 0;
char placeholderStr[255] = {0};
icsneoc2_event_t *eventPlaceHolder = nullptr;
icsneoc2_lin_mode_t placeholderLinMode = 0;
icsneoc2_ae_link_mode_t placeholderAeLinkMode = 0;
icsneoc2_eth_phy_link_mode_t placeholderEthPhyLinkMode = 0;
icsneoc2_eth_phy_link_mode_t* placeholderEthPhyLinkModePtr = nullptr;
icsneoc2_misc_io_analog_voltage_t placeholderMiscIoAnalogVoltage = 0;
// All of these don't have a device parameter
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_enumerate(0, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_network_type_name_get(0, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_event_description_get(eventPlaceHolder, placeholderStr, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_event_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_type_name_get(0, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_error_code_get(0, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_netid_name_get(0, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_can_create(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_free(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_data_get(NULL, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_data_set(NULL, NULL, 0));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_netid_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_netid_set(NULL, 0));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_network_type_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_is_transmit(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_message_is_valid(NULL, NULL));
// Test utility functions with NULL parameters
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_version_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_serial_num_to_string(0, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_serial_string_to_num(NULL, 0, NULL));
// Test new enumeration/info accessors with NULL parameters
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_info_serial_get(NULL, placeholderStr, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_info_type_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_info_type_name_get(NULL, placeholderStr, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_info_description_get(NULL, placeholderStr, &placeholderSizeT));
// Test open/close with NULL parameters
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_open(NULL, 0, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_open_serial(NULL, 0, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_open_first(0, 0, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_close(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_description_get(NULL, placeholderStr, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_go_online(NULL, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_is_online(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_is_online_supported(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_is_valid(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_is_open(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_is_disconnected(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_rtc_get(NULL, (int64_t *)&placeholderUnsignedInteger64));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_rtc_set(NULL, 0));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_serial_get(NULL, placeholderStr, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supports_tc10(NULL, &placeholderBool));
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_set(NULL, 0, 0, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_type_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_message_polling_limit_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_message_polling_limit_set(NULL, 0));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_message_get(NULL, NULL, 0));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_message_transmit(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_apply_defaults(NULL, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_apply(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_refresh(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_baudrate_get(NULL, 0, &placeholderInteger64));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_baudrate_set(NULL, 0, placeholderInteger64));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_canfd_baudrate_get(NULL, 0, &placeholderInteger64));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_canfd_baudrate_set(NULL, 0, placeholderInteger64));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_termination_is_supported(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_termination_can_enable(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_termination_is_enabled(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_termination_set(NULL, 0, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_commander_resistor_enabled(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_commander_resistor_set(NULL, 0, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_lin_mode_get(NULL, 0, &placeholderLinMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_lin_mode_set(NULL, 0, placeholderLinMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_lin_commander_response_time_get(NULL, 0, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_lin_commander_response_time_set(NULL, 0, placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_enable_get(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_enable_set(NULL, 0, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_mode_get(NULL, 0, &placeholderAeLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_mode_set(NULL, 0, placeholderAeLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_speed_get(NULL, 0, &placeholderEthPhyLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_speed_set(NULL, 0, placeholderEthPhyLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_role_for_get(NULL, 0, &placeholderAeLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_role_for_set(NULL, 0, placeholderAeLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_link_mode_for_get(NULL, 0, &placeholderEthPhyLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_link_mode_for_set(NULL, 0, placeholderEthPhyLinkMode));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_enable_for_get(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_phy_enable_for_set(NULL, 0, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_supported_phy_link_modes_for(NULL, 0, &placeholderEthPhyLinkModePtr, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_is_plca_enabled_for(NULL, 0, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_plca_enabled_for_set(NULL, 0, false));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_local_id_get(NULL, 0, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_local_id_set(NULL, 0, placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_max_nodes_get(NULL, 0, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_max_nodes_set(NULL, 0, placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_tx_opp_timer_get(NULL, 0, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_tx_opp_timer_set(NULL, 0, placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_max_burst_timer_for_get(NULL, 0, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_t1s_max_burst_timer_for_set(NULL, 0, placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_misc_io_analog_output_enabled_set(NULL, 0, placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_misc_io_analog_output_set(NULL, 0, placeholderMiscIoAnalogVoltage));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_disabled_get(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_settings_readonly_get(NULL, &placeholderBool));
// Disk formatting functions
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_disk_count_get(NULL, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supports_disk_formatting(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_disk_details_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_format_disk(NULL, NULL, NULL, NULL));
// Disk details accessors with NULL details
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_count_get(NULL, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_count_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_layout_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_layout_set(NULL, 0));
icsneoc2_disk_format_flags_t placeholderFlags = 0;
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_flags_get(NULL, 0, &placeholderFlags));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_flags_get(NULL, 0, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_flags_set(NULL, 0, placeholderFlags));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_flags_set(NULL, 0, 0));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_size_get(NULL, 0, &placeholderUnsignedInteger64, &placeholderUnsignedInteger64));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_size_get(NULL, 0, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_full_format_get(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_full_format_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_disk_details_full_format_set(NULL, false));
// Supported networks
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supported_rx_networks_get(NULL, NULL, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supported_rx_networks_get(NULL, NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supported_tx_networks_get(NULL, NULL, &placeholderSizeT));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supported_tx_networks_get(NULL, NULL, NULL));
// Script functions
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supports_coremini_script(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_supports_coremini_script(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_start(NULL, icsneoc2_memory_type_sd));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_stop(NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_clear(NULL, icsneoc2_memory_type_sd));
int8_t placeholderSignedInteger8 = 0;
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_prepare_load(NULL, &placeholderSignedInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_prepare_load(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_coremini_upload_file(NULL, "test.bin", icsneoc2_memory_type_sd));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_coremini_upload_file(NULL, NULL, icsneoc2_memory_type_sd));
const uint8_t placeholderData[] = {0};
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_coremini_upload(NULL, placeholderData, sizeof(placeholderData), icsneoc2_memory_type_sd));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_coremini_upload(NULL, NULL, 0, icsneoc2_memory_type_sd));
icsneoc2_script_status_t* placeholderScriptStatus = NULL;
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_status_get(NULL, &placeholderScriptStatus));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_device_script_status_get(NULL, NULL));
// Script status accessors with NULL handle
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_is_coremini_running(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_is_coremini_running(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_is_encrypted(NULL, &placeholderBool));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_sector_overflows_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_sector_overflows_get(NULL, NULL));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_remaining_sector_buffers_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_last_sector_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_read_bin_size_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_min_sector_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_max_sector_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_current_sector_get(NULL, &placeholderInteger32));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_coremini_create_time_get(NULL, &placeholderUnsignedInteger64));
uint16_t placeholderInteger16 = 0;
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_file_checksum_get(NULL, &placeholderInteger16));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_coremini_version_get(NULL, &placeholderInteger16));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_coremini_header_size_get(NULL, &placeholderInteger16));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_diagnostic_error_code_get(NULL, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_diagnostic_error_code_count_get(NULL, &placeholderInteger8));
ASSERT_EQ(icsneoc2_error_invalid_parameters, icsneoc2_script_status_max_coremini_size_kb_get(NULL, &placeholderInteger16));
}
TEST(icsneoc2, test_icsneoc2_devicetype_t)
{
ASSERT_EQ(icsneoc2_devicetype_unknown, 0x00000000);
ASSERT_EQ(icsneoc2_devicetype_blue, 0x00000001);
ASSERT_EQ(icsneoc2_devicetype_ecu_avb, 0x00000002);
ASSERT_EQ(icsneoc2_devicetype_rad_supermoon, 0x00000003);
ASSERT_EQ(icsneoc2_devicetype_dw_vcan, 0x00000004);
ASSERT_EQ(icsneoc2_devicetype_rad_moon2, 0x00000005);
ASSERT_EQ(icsneoc2_devicetype_rad_mars, 0x00000006);
ASSERT_EQ(icsneoc2_devicetype_vcan41, 0x00000007);
ASSERT_EQ(icsneoc2_devicetype_fire, 0x00000008);
ASSERT_EQ(icsneoc2_devicetype_rad_pluto, 0x00000009);
ASSERT_EQ(icsneoc2_devicetype_vcan42_el, 0x0000000a);
ASSERT_EQ(icsneoc2_devicetype_radio_canhub, 0x0000000b);
ASSERT_EQ(icsneoc2_devicetype_neo_ecu12, 0x0000000c);
ASSERT_EQ(icsneoc2_devicetype_obd2_lc_badge, 0x0000000d);
ASSERT_EQ(icsneoc2_devicetype_rad_moon_duo, 0x0000000e);
ASSERT_EQ(icsneoc2_devicetype_fire3, 0x0000000f);
ASSERT_EQ(icsneoc2_devicetype_vcan3, 0x00000010);
ASSERT_EQ(icsneoc2_devicetype_rad_jupiter, 0x00000011);
ASSERT_EQ(icsneoc2_devicetype_vcan4_industrial, 0x00000012);
ASSERT_EQ(icsneoc2_devicetype_rad_gigastar, 0x00000013);
ASSERT_EQ(icsneoc2_devicetype_red2, 0x00000014);
ASSERT_EQ(icsneoc2_devicetype_etherbadge, 0x00000016);
ASSERT_EQ(icsneoc2_devicetype_rad_a2b, 0x00000017);
ASSERT_EQ(icsneoc2_devicetype_rad_epsilon, 0x00000018);
ASSERT_EQ(icsneoc2_devicetype_rad_epsilon_xl, 0x0000001e);
ASSERT_EQ(icsneoc2_devicetype_rad_galaxy2, 0x00000021);
ASSERT_EQ(icsneoc2_devicetype_rad_moon3, 0x00000023);
ASSERT_EQ(icsneoc2_devicetype_rad_comet, 0x00000024);
ASSERT_EQ(icsneoc2_devicetype_fire3_flexray, 0x00000025);
ASSERT_EQ(icsneoc2_devicetype_connect, 0x00000026);
ASSERT_EQ(icsneoc2_devicetype_rad_comet3, 0x00000027);
ASSERT_EQ(icsneoc2_devicetype_rad_moon_t1s, 0x00000028);
ASSERT_EQ(icsneoc2_devicetype_rad_gigastar2, 0x00000029);
ASSERT_EQ(icsneoc2_devicetype_fire3_t1s_lin, 0x0000002a);
ASSERT_EQ(icsneoc2_devicetype_fire3_t1s_sent, 0x0000002b);
ASSERT_EQ(icsneoc2_devicetype_rad_gemini, 0x0000002c);
ASSERT_EQ(icsneoc2_devicetype_red, 0x00000040);
ASSERT_EQ(icsneoc2_devicetype_ecu, 0x00000080);
ASSERT_EQ(icsneoc2_devicetype_ievb, 0x00000100);
ASSERT_EQ(icsneoc2_devicetype_pendant, 0x00000200);
ASSERT_EQ(icsneoc2_devicetype_obd2_pro, 0x00000400);
ASSERT_EQ(icsneoc2_devicetype_ecuchip_uart, 0x00000800);
ASSERT_EQ(icsneoc2_devicetype_plasma, 0x00001000);
ASSERT_EQ(icsneoc2_devicetype_neo_analog, 0x00004000);
ASSERT_EQ(icsneoc2_devicetype_ct_obd, 0x00008000);
ASSERT_EQ(icsneoc2_devicetype_ion, 0x00040000);
ASSERT_EQ(icsneoc2_devicetype_rad_star, 0x00080000);
ASSERT_EQ(icsneoc2_devicetype_vcan44, 0x00200000);
ASSERT_EQ(icsneoc2_devicetype_vcan42, 0x00400000);
ASSERT_EQ(icsneoc2_devicetype_cm_probe, 0x00800000);
ASSERT_EQ(icsneoc2_devicetype_eevb, 0x01000000);
ASSERT_EQ(icsneoc2_devicetype_vcan_rf, 0x02000000);
ASSERT_EQ(icsneoc2_devicetype_fire2, 0x04000000);
ASSERT_EQ(icsneoc2_devicetype_flex, 0x08000000);
ASSERT_EQ(icsneoc2_devicetype_rad_galaxy, 0x10000000);
ASSERT_EQ(icsneoc2_devicetype_rad_star2, 0x20000000);
ASSERT_EQ(icsneoc2_devicetype_vividcan, 0x40000000);
ASSERT_EQ(icsneoc2_devicetype_obd2_sim, 0x80000000);
ASSERT_EQ(icsneoc2_devicetype_maxsize, 0x80000001);
ASSERT_EQ(sizeof(icsneoc2_devicetype_t), sizeof(uint32_t));
}
TEST(icsneoc2, test_devicetype_enum_alignment)
{
ASSERT_EQ(icsneo::DeviceType::Unknown, icsneoc2_devicetype_unknown);
ASSERT_EQ(icsneo::DeviceType::BLUE, icsneoc2_devicetype_blue);
ASSERT_EQ(icsneo::DeviceType::ECU_AVB, icsneoc2_devicetype_ecu_avb);
ASSERT_EQ(icsneo::DeviceType::RADSupermoon, icsneoc2_devicetype_rad_supermoon);
ASSERT_EQ(icsneo::DeviceType::DW_VCAN, icsneoc2_devicetype_dw_vcan);
ASSERT_EQ(icsneo::DeviceType::RADMoon2, icsneoc2_devicetype_rad_moon2);
ASSERT_EQ(icsneo::DeviceType::RADMars, icsneoc2_devicetype_rad_mars);
ASSERT_EQ(icsneo::DeviceType::VCAN4_1, icsneoc2_devicetype_vcan41);
ASSERT_EQ(icsneo::DeviceType::FIRE, icsneoc2_devicetype_fire);
ASSERT_EQ(icsneo::DeviceType::RADPluto, icsneoc2_devicetype_rad_pluto);
ASSERT_EQ(icsneo::DeviceType::VCAN4_2EL, icsneoc2_devicetype_vcan42_el);
ASSERT_EQ(icsneo::DeviceType::RADIO_CANHUB, icsneoc2_devicetype_radio_canhub);
ASSERT_EQ(icsneo::DeviceType::NEOECU12, icsneoc2_devicetype_neo_ecu12);
ASSERT_EQ(icsneo::DeviceType::OBD2_LCBADGE, icsneoc2_devicetype_obd2_lc_badge);
ASSERT_EQ(icsneo::DeviceType::RADMoonDuo, icsneoc2_devicetype_rad_moon_duo);
ASSERT_EQ(icsneo::DeviceType::FIRE3, icsneoc2_devicetype_fire3);
ASSERT_EQ(icsneo::DeviceType::VCAN3, icsneoc2_devicetype_vcan3);
ASSERT_EQ(icsneo::DeviceType::RADJupiter, icsneoc2_devicetype_rad_jupiter);
ASSERT_EQ(icsneo::DeviceType::VCAN4_IND, icsneoc2_devicetype_vcan4_industrial);
ASSERT_EQ(icsneo::DeviceType::RADGigastar, icsneoc2_devicetype_rad_gigastar);
ASSERT_EQ(icsneo::DeviceType::RED2, icsneoc2_devicetype_red2);
ASSERT_EQ(icsneo::DeviceType::EtherBADGE, icsneoc2_devicetype_etherbadge);
ASSERT_EQ(icsneo::DeviceType::RAD_A2B, icsneoc2_devicetype_rad_a2b);
ASSERT_EQ(icsneo::DeviceType::RADEpsilon, icsneoc2_devicetype_rad_epsilon);
ASSERT_EQ(icsneo::DeviceType::RADEpsilonXL, icsneoc2_devicetype_rad_epsilon_xl);
ASSERT_EQ(icsneo::DeviceType::RADMoon3, icsneoc2_devicetype_rad_moon3);
ASSERT_EQ(icsneo::DeviceType::RADComet, icsneoc2_devicetype_rad_comet);
ASSERT_EQ(icsneo::DeviceType::FIRE3_FlexRay, icsneoc2_devicetype_fire3_flexray);
ASSERT_EQ(icsneo::DeviceType::Connect, icsneoc2_devicetype_connect);
ASSERT_EQ(icsneo::DeviceType::RADComet3, icsneoc2_devicetype_rad_comet3);
ASSERT_EQ(icsneo::DeviceType::RADMoonT1S, icsneoc2_devicetype_rad_moon_t1s);
ASSERT_EQ(icsneo::DeviceType::RADGigastar2, icsneoc2_devicetype_rad_gigastar2);
ASSERT_EQ(icsneo::DeviceType::FIRE3_T1S_LIN, icsneoc2_devicetype_fire3_t1s_lin);
ASSERT_EQ(icsneo::DeviceType::FIRE3_T1S_SENT, icsneoc2_devicetype_fire3_t1s_sent);
ASSERT_EQ(icsneo::DeviceType::RADGemini, icsneoc2_devicetype_rad_gemini);
ASSERT_EQ(icsneo::DeviceType::RED, icsneoc2_devicetype_red);
ASSERT_EQ(icsneo::DeviceType::ECU, icsneoc2_devicetype_ecu);
ASSERT_EQ(icsneo::DeviceType::IEVB, icsneoc2_devicetype_ievb);
ASSERT_EQ(icsneo::DeviceType::Pendant, icsneoc2_devicetype_pendant);
ASSERT_EQ(icsneo::DeviceType::OBD2_PRO, icsneoc2_devicetype_obd2_pro);
ASSERT_EQ(icsneo::DeviceType::ECUChip_UART, icsneoc2_devicetype_ecuchip_uart);
ASSERT_EQ(icsneo::DeviceType::PLASMA, icsneoc2_devicetype_plasma);
ASSERT_EQ(icsneo::DeviceType::NEOAnalog, icsneoc2_devicetype_neo_analog);
ASSERT_EQ(icsneo::DeviceType::CT_OBD, icsneoc2_devicetype_ct_obd);
ASSERT_EQ(icsneo::DeviceType::ION, icsneoc2_devicetype_ion);
ASSERT_EQ(icsneo::DeviceType::RADStar, icsneoc2_devicetype_rad_star);
ASSERT_EQ(icsneo::DeviceType::VCAN4_4, icsneoc2_devicetype_vcan44);
ASSERT_EQ(icsneo::DeviceType::VCAN4_2, icsneoc2_devicetype_vcan42);
ASSERT_EQ(icsneo::DeviceType::CMProbe, icsneoc2_devicetype_cm_probe);
ASSERT_EQ(icsneo::DeviceType::EEVB, icsneoc2_devicetype_eevb);
ASSERT_EQ(icsneo::DeviceType::VCANrf, icsneoc2_devicetype_vcan_rf);
ASSERT_EQ(icsneo::DeviceType::FIRE2, icsneoc2_devicetype_fire2);
ASSERT_EQ(icsneo::DeviceType::Flex, icsneoc2_devicetype_flex);
ASSERT_EQ(icsneo::DeviceType::RADGalaxy, icsneoc2_devicetype_rad_galaxy);
ASSERT_EQ(icsneo::DeviceType::RADStar2, icsneoc2_devicetype_rad_star2);
ASSERT_EQ(icsneo::DeviceType::VividCAN, icsneoc2_devicetype_vividcan);
ASSERT_EQ(icsneo::DeviceType::OBD2_SIM, icsneoc2_devicetype_obd2_sim);
ASSERT_EQ(icsneo::DeviceType::RADGalaxy2, icsneoc2_devicetype_rad_galaxy2);
}
TEST(icsneoc2, icsneoc2_network_type_t)
{
ASSERT_EQ(icsneoc2_network_type_invalid, 0);
ASSERT_EQ(icsneoc2_network_type_internal, 1);
ASSERT_EQ(icsneoc2_network_type_can, 2);
ASSERT_EQ(icsneoc2_network_type_lin, 3);
ASSERT_EQ(icsneoc2_network_type_flexray, 4);
ASSERT_EQ(icsneoc2_network_type_most, 5);
ASSERT_EQ(icsneoc2_network_type_ethernet, 6);
ASSERT_EQ(icsneoc2_network_type_lsftcan, 7);
ASSERT_EQ(icsneoc2_network_type_swcan, 8);
ASSERT_EQ(icsneoc2_network_type_iso9141, 9);
ASSERT_EQ(icsneoc2_network_type_i2c, 10);
ASSERT_EQ(icsneoc2_network_type_a2b, 11);
ASSERT_EQ(icsneoc2_network_type_spi, 12);
ASSERT_EQ(icsneoc2_network_type_mdio, 13);
ASSERT_EQ(icsneoc2_network_type_automotive_ethernet, 14);
ASSERT_EQ(icsneoc2_network_type_maxsize, 15);
ASSERT_EQ(sizeof(icsneoc2_network_type_t), sizeof(uint8_t));
}
TEST(icsneoc2, test_icsneoc2_io_type_t)
{
ASSERT_EQ(icsneoc2_io_type_eth_activation, 0);
ASSERT_EQ(icsneoc2_io_type_usb_host_power, 1);
ASSERT_EQ(icsneoc2_io_type_backup_power_en, 2);
ASSERT_EQ(icsneoc2_io_type_backup_power_good, 3);
ASSERT_EQ(icsneoc2_io_type_misc, 4);
ASSERT_EQ(icsneoc2_io_type_emisc, 5);
ASSERT_EQ(sizeof(icsneoc2_io_type_t), sizeof(uint32_t));
}
TEST(icsneoc2, test_icsneoc2_netid_t)
{
ASSERT_EQ(icsneoc2_netid_device, 0);
ASSERT_EQ(icsneoc2_netid_dwcan_01, 1);
ASSERT_EQ(icsneoc2_netid_dwcan_08, 2);
ASSERT_EQ(icsneoc2_netid_swcan_01, 3);
ASSERT_EQ(icsneoc2_netid_lsftcan_01, 4);
ASSERT_EQ(icsneoc2_netid_fordscp, 5);
ASSERT_EQ(icsneoc2_netid_j1708, 6);
ASSERT_EQ(icsneoc2_netid_aux, 7);
ASSERT_EQ(icsneoc2_netid_j1850vpw, 8);
ASSERT_EQ(icsneoc2_netid_iso9141, 9);
ASSERT_EQ(icsneoc2_netid_disk_data, 10);
ASSERT_EQ(icsneoc2_netid_main51, 11);
ASSERT_EQ(icsneoc2_netid_red, 12);
ASSERT_EQ(icsneoc2_netid_sci, 13);
ASSERT_EQ(icsneoc2_netid_iso9141_02, 14);
ASSERT_EQ(icsneoc2_netid_iso14230, 15);
ASSERT_EQ(icsneoc2_netid_lin_01, 16);
ASSERT_EQ(icsneoc2_netid_ae_01, 17);
ASSERT_EQ(icsneoc2_netid_ae_02, 18);
ASSERT_EQ(icsneoc2_netid_ae_03, 19);
ASSERT_EQ(icsneoc2_netid_red_ext_memoryread, 20);
ASSERT_EQ(icsneoc2_netid_red_int_memoryread, 21);
ASSERT_EQ(icsneoc2_netid_red_dflash_read, 22);
ASSERT_EQ(icsneoc2_netid_neo_memory_sdread, 23); // Response from NeoMemory (MemoryTypeSD)
ASSERT_EQ(icsneoc2_netid_can_errbits, 24);
ASSERT_EQ(icsneoc2_netid_neo_memory_write_done, 25);
ASSERT_EQ(icsneoc2_netid_red_wave_can1_logical, 26);
ASSERT_EQ(icsneoc2_netid_red_wave_can2_logical, 27);
ASSERT_EQ(icsneoc2_netid_red_wave_lin1_logical, 28);
ASSERT_EQ(icsneoc2_netid_red_wave_lin2_logical, 29);
ASSERT_EQ(icsneoc2_netid_red_wave_lin1_analog, 30);
ASSERT_EQ(icsneoc2_netid_red_wave_lin2_analog, 31);
ASSERT_EQ(icsneoc2_netid_red_wave_misc_analog, 32);
ASSERT_EQ(icsneoc2_netid_red_wave_miscdio2_logical, 33);
ASSERT_EQ(icsneoc2_netid_red_network_com_enable_ex, 34);
ASSERT_EQ(icsneoc2_netid_red_neovi_network, 35);
ASSERT_EQ(icsneoc2_netid_red_read_baud_settings, 36);
ASSERT_EQ(icsneoc2_netid_red_oldformat, 37);
ASSERT_EQ(icsneoc2_netid_red_scope_capture, 38);
ASSERT_EQ(icsneoc2_netid_red_hardware_excep, 39);
ASSERT_EQ(icsneoc2_netid_red_get_rtc, 40);
ASSERT_EQ(icsneoc2_netid_iso9141_03, 41);
ASSERT_EQ(icsneoc2_netid_dwcan_02, 42);
ASSERT_EQ(icsneoc2_netid_dwcan_03, 44);
ASSERT_EQ(icsneoc2_netid_ae_04, 45);
ASSERT_EQ(icsneoc2_netid_ae_05, 46);
ASSERT_EQ(icsneoc2_netid_iso9141_04, 47);
ASSERT_EQ(icsneoc2_netid_lin_02, 48);
ASSERT_EQ(icsneoc2_netid_lin_03, 49);
ASSERT_EQ(icsneoc2_netid_lin_04, 50);
ASSERT_EQ(icsneoc2_netid_most_unused, 51); // MOST = 51, Old and unused
ASSERT_EQ(icsneoc2_netid_red_app_error, 52);
ASSERT_EQ(icsneoc2_netid_cgi, 53);
ASSERT_EQ(icsneoc2_netid_reset_status, 54);
ASSERT_EQ(icsneoc2_netid_fb_status, 55);
ASSERT_EQ(icsneoc2_netid_app_signal_status, 56);
ASSERT_EQ(icsneoc2_netid_read_datalink_cm_tx_msg, 57);
ASSERT_EQ(icsneoc2_netid_read_datalink_cm_rx_msg, 58);
ASSERT_EQ(icsneoc2_netid_logging_overflow, 59);
ASSERT_EQ(icsneoc2_netid_read_settings, 60);
ASSERT_EQ(icsneoc2_netid_dwcan_04, 61);
ASSERT_EQ(icsneoc2_netid_dwcan_05, 62);
ASSERT_EQ(icsneoc2_netid_rs232, 63);
ASSERT_EQ(icsneoc2_netid_uart_01, 64);
ASSERT_EQ(icsneoc2_netid_uart_02, 65);
ASSERT_EQ(icsneoc2_netid_uart_03, 66);
ASSERT_EQ(icsneoc2_netid_uart_04, 67);
ASSERT_EQ(icsneoc2_netid_swcan_02, 68);
ASSERT_EQ(icsneoc2_netid_ethernet_daq, 69);
ASSERT_EQ(icsneoc2_netid_data_to_host, 70);
ASSERT_EQ(icsneoc2_netid_textapi_to_host, 71);
ASSERT_EQ(icsneoc2_netid_spi_01, 72);
ASSERT_EQ(icsneoc2_netid_ae_06, 73);
ASSERT_EQ(icsneoc2_netid_red_vbat, 74);
ASSERT_EQ(icsneoc2_netid_ae_07, 75);
ASSERT_EQ(icsneoc2_netid_ae_08, 76);
ASSERT_EQ(icsneoc2_netid_ae_09, 77);
ASSERT_EQ(icsneoc2_netid_ae_10, 78);
ASSERT_EQ(icsneoc2_netid_ae_11, 79);
ASSERT_EQ(icsneoc2_netid_flexray_01a, 80);
ASSERT_EQ(icsneoc2_netid_flexray_01b, 81);
ASSERT_EQ(icsneoc2_netid_flexray_02a, 82);
ASSERT_EQ(icsneoc2_netid_flexray_02b, 83);
ASSERT_EQ(icsneoc2_netid_lin_05, 84);
ASSERT_EQ(icsneoc2_netid_flexray_01, 85);
ASSERT_EQ(icsneoc2_netid_flexray_02, 86);
ASSERT_EQ(icsneoc2_netid_ae_12, 87);
ASSERT_EQ(icsneoc2_netid_i2c_01, 88);
ASSERT_EQ(icsneoc2_netid_most_25, 90);
ASSERT_EQ(icsneoc2_netid_most_50, 91);
ASSERT_EQ(icsneoc2_netid_most_150, 92);
ASSERT_EQ(icsneoc2_netid_ethernet_01, 93);
ASSERT_EQ(icsneoc2_netid_gmfsa, 94);
ASSERT_EQ(icsneoc2_netid_tcp, 95);
ASSERT_EQ(icsneoc2_netid_dwcan_06, 96);
ASSERT_EQ(icsneoc2_netid_dwcan_07, 97);
ASSERT_EQ(icsneoc2_netid_lin_06, 98);
ASSERT_EQ(icsneoc2_netid_lsftcan_02, 99);
ASSERT_EQ(icsneoc2_netid_logical_disk_info, 187);
ASSERT_EQ(icsneoc2_netid_wivi_command, 221);
ASSERT_EQ(icsneoc2_netid_script_status, 224);
ASSERT_EQ(icsneoc2_netid_eth_phy_control, 239);
ASSERT_EQ(icsneoc2_netid_extended_command, 240);
ASSERT_EQ(icsneoc2_netid_extended_data, 242);
ASSERT_EQ(icsneoc2_netid_flexray_control, 243);
ASSERT_EQ(icsneoc2_netid_coremini_preload, 244);
ASSERT_EQ(icsneoc2_netid_hw_com_latency_test, 512);
ASSERT_EQ(icsneoc2_netid_device_status, 513);
ASSERT_EQ(icsneoc2_netid_udp, 514);
ASSERT_EQ(icsneoc2_netid_forwarded_message, 516);
ASSERT_EQ(icsneoc2_netid_i2c_02, 517);
ASSERT_EQ(icsneoc2_netid_i2c_03, 518);
ASSERT_EQ(icsneoc2_netid_i2c_04, 519);
ASSERT_EQ(icsneoc2_netid_ethernet_02, 520);
ASSERT_EQ(icsneoc2_netid_ethernet_tx_wrap, 521);
ASSERT_EQ(icsneoc2_netid_a2b_01, 522);
ASSERT_EQ(icsneoc2_netid_a2b_02, 523);
ASSERT_EQ(icsneoc2_netid_ethernet_03, 524);
ASSERT_EQ(icsneoc2_netid_wbms_01, 532);
ASSERT_EQ(icsneoc2_netid_dwcan_09, 534);
ASSERT_EQ(icsneoc2_netid_dwcan_10, 535);
ASSERT_EQ(icsneoc2_netid_dwcan_11, 536);
ASSERT_EQ(icsneoc2_netid_dwcan_12, 537);
ASSERT_EQ(icsneoc2_netid_dwcan_13, 538);
ASSERT_EQ(icsneoc2_netid_dwcan_14, 539);
ASSERT_EQ(icsneoc2_netid_dwcan_15, 540);
ASSERT_EQ(icsneoc2_netid_dwcan_16, 541);
ASSERT_EQ(icsneoc2_netid_lin_07, 542);
ASSERT_EQ(icsneoc2_netid_lin_08, 543);
ASSERT_EQ(icsneoc2_netid_spi_02, 544);
ASSERT_EQ(icsneoc2_netid_mdio_01, 545);
ASSERT_EQ(icsneoc2_netid_mdio_02, 546);
ASSERT_EQ(icsneoc2_netid_mdio_03, 547);
ASSERT_EQ(icsneoc2_netid_mdio_04, 548);
ASSERT_EQ(icsneoc2_netid_mdio_05, 549);
ASSERT_EQ(icsneoc2_netid_mdio_06, 550);
ASSERT_EQ(icsneoc2_netid_mdio_07, 551);
ASSERT_EQ(icsneoc2_netid_mdio_08, 552);
ASSERT_EQ(icsneoc2_netid_ae_13, 553);
ASSERT_EQ(icsneoc2_netid_ae_14, 554);
ASSERT_EQ(icsneoc2_netid_ae_15, 555);
ASSERT_EQ(icsneoc2_netid_ae_16, 556);
ASSERT_EQ(icsneoc2_netid_spi_03, 557);
ASSERT_EQ(icsneoc2_netid_spi_04, 558);
ASSERT_EQ(icsneoc2_netid_spi_05, 559);
ASSERT_EQ(icsneoc2_netid_spi_06, 560);
ASSERT_EQ(icsneoc2_netid_spi_07, 561);
ASSERT_EQ(icsneoc2_netid_spi_08, 562);
ASSERT_EQ(icsneoc2_netid_lin_09, 563);
ASSERT_EQ(icsneoc2_netid_lin_10, 564);
ASSERT_EQ(icsneoc2_netid_lin_11, 565);
ASSERT_EQ(icsneoc2_netid_lin_12, 566);
ASSERT_EQ(icsneoc2_netid_lin_13, 567);
ASSERT_EQ(icsneoc2_netid_lin_14, 568);
ASSERT_EQ(icsneoc2_netid_lin_15, 569);
ASSERT_EQ(icsneoc2_netid_lin_16, 570);
ASSERT_EQ(icsneoc2_netid_maxsize, 571);
}
TEST(icsneoc2, test_icsneoc2_open_options_default)
{
icsneoc2_open_options_t expected = ICSNEOC2_OPEN_OPTIONS_GO_ONLINE | ICSNEOC2_OPEN_OPTIONS_SYNC_RTC | ICSNEOC2_OPEN_OPTIONS_ENABLE_AUTO_UPDATE;
ASSERT_EQ(icsneoc2_open_options_default, expected);
}
TEST(icsneoc2, test_icsneoc2_disk_format_enums)
{
// Disk layout enum values
ASSERT_EQ(icsneoc2_disk_layout_spanned, 0);
ASSERT_EQ(icsneoc2_disk_layout_raid0, 1);
// Disk format flag bitmask values
ASSERT_EQ(ICSNEOC2_DISK_FORMAT_FLAGS_PRESENT, 0x01);
ASSERT_EQ(ICSNEOC2_DISK_FORMAT_FLAGS_INITIALIZED, 0x02);
ASSERT_EQ(ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED, 0x04);
// Disk format directive values
ASSERT_EQ(icsneoc2_disk_format_directive_continue, 0);
ASSERT_EQ(icsneoc2_disk_format_directive_stop, 1);
// Type sizes
ASSERT_EQ(sizeof(icsneoc2_disk_layout_t), sizeof(uint8_t));
ASSERT_EQ(sizeof(icsneoc2_disk_format_flags_t), sizeof(uint32_t));
ASSERT_EQ(sizeof(icsneoc2_disk_format_directive_t), sizeof(uint8_t));
}
TEST(icsneoc2, test_icsneoc2_free_null)
{
// Free functions should be safe to call with NULL
icsneoc2_disk_details_free(NULL);
icsneoc2_script_status_free(NULL);
}
TEST(icsneoc2, test_icsneoc2_format_disk_error_code)
{
// Verify the new error code exists and has a valid string
char error_str[64] = {0};
size_t error_str_len = sizeof(error_str);
ASSERT_EQ(icsneoc2_error_success, icsneoc2_error_code_get(icsneoc2_error_format_disk_failed, error_str, &error_str_len));
ASSERT_GT(error_str_len, 0u);
ASSERT_STREQ(error_str, "Disk format failed");
}
TEST(icsneoc2, test_icsneoc2_memory_type_enums)
{
// Memory type enum values should match Disk::MemoryType
ASSERT_EQ(0, icsneoc2_memory_type_flash);
ASSERT_EQ(1, icsneoc2_memory_type_sd);
}
TEST(icsneoc2, test_icsneoc2_script_error_codes)
{
// Verify script error codes exist and have distinct string representations
char buf[256];
size_t len;
len = sizeof(buf);
ASSERT_EQ(icsneoc2_error_success, icsneoc2_error_code_get(icsneoc2_error_script_start_failed, buf, &len));
ASSERT_GT(len, 0u);
len = sizeof(buf);
ASSERT_EQ(icsneoc2_error_success, icsneoc2_error_code_get(icsneoc2_error_script_stop_failed, buf, &len));
ASSERT_GT(len, 0u);
len = sizeof(buf);
ASSERT_EQ(icsneoc2_error_success, icsneoc2_error_code_get(icsneoc2_error_script_clear_failed, buf, &len));
ASSERT_GT(len, 0u);
len = sizeof(buf);
ASSERT_EQ(icsneoc2_error_success, icsneoc2_error_code_get(icsneoc2_error_script_upload_failed, buf, &len));
ASSERT_GT(len, 0u);
len = sizeof(buf);
ASSERT_EQ(icsneoc2_error_success, icsneoc2_error_code_get(icsneoc2_error_script_load_prepare_failed, buf, &len));
ASSERT_GT(len, 0u);
}