mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-09-20 16:08:37 +02:00
Compare commits
122
Commits
1.2.0
...
3a6501d116
+55
-75
@@ -35,30 +35,6 @@ unit_test windows/x64:
|
|||||||
- libicsneo-win-x64
|
- libicsneo-win-x64
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
build windows/x86:
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- cmd /C ci\build-windows32.bat
|
|
||||||
artifacts:
|
|
||||||
when: always
|
|
||||||
paths:
|
|
||||||
- build
|
|
||||||
expire_in: 3 days
|
|
||||||
tags:
|
|
||||||
- libicsneo-win-x64
|
|
||||||
|
|
||||||
unit_test windows/x86:
|
|
||||||
stage: unit_test
|
|
||||||
script:
|
|
||||||
- build\libicsneo-unit-tests.exe
|
|
||||||
dependencies:
|
|
||||||
- build windows/x86
|
|
||||||
needs:
|
|
||||||
- build windows/x86
|
|
||||||
tags:
|
|
||||||
- libicsneo-win-x64
|
|
||||||
timeout: 5m
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Ubuntu
|
# Ubuntu
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -119,30 +95,6 @@ unit_test windows/x86:
|
|||||||
- linux-build
|
- linux-build
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
build linux/ubuntu/2204/amd64/gcc:
|
|
||||||
<<: *build_linux_ubuntu_gcc
|
|
||||||
image: ubuntu:22.04
|
|
||||||
|
|
||||||
unit_test linux/ubuntu/2204/amd64/gcc:
|
|
||||||
<<: *test_linux_ubuntu_gcc
|
|
||||||
image: ubuntu:22.04
|
|
||||||
dependencies:
|
|
||||||
- build linux/ubuntu/2204/amd64/gcc
|
|
||||||
needs:
|
|
||||||
- build linux/ubuntu/2204/amd64/gcc
|
|
||||||
|
|
||||||
build linux/ubuntu/2204/amd64/clang:
|
|
||||||
<<: *build_linux_ubuntu_clang
|
|
||||||
image: ubuntu:22.04
|
|
||||||
|
|
||||||
unit_test linux/ubuntu/2204/amd64/clang:
|
|
||||||
<<: *test_linux_ubuntu_clang
|
|
||||||
image: ubuntu:22.04
|
|
||||||
dependencies:
|
|
||||||
- build linux/ubuntu/2204/amd64/clang
|
|
||||||
needs:
|
|
||||||
- build linux/ubuntu/2204/amd64/clang
|
|
||||||
|
|
||||||
build linux/ubuntu/2404/amd64/gcc:
|
build linux/ubuntu/2404/amd64/gcc:
|
||||||
<<: *build_linux_ubuntu_gcc
|
<<: *build_linux_ubuntu_gcc
|
||||||
image: ubuntu:24.04
|
image: ubuntu:24.04
|
||||||
@@ -167,6 +119,30 @@ unit_test linux/ubuntu/2404/amd64/clang:
|
|||||||
needs:
|
needs:
|
||||||
- build linux/ubuntu/2404/amd64/clang
|
- build linux/ubuntu/2404/amd64/clang
|
||||||
|
|
||||||
|
build linux/ubuntu/2604/amd64/gcc:
|
||||||
|
<<: *build_linux_ubuntu_gcc
|
||||||
|
image: ubuntu:26.04
|
||||||
|
|
||||||
|
unit_test linux/ubuntu/2604/amd64/gcc:
|
||||||
|
<<: *test_linux_ubuntu_gcc
|
||||||
|
image: ubuntu:26.04
|
||||||
|
dependencies:
|
||||||
|
- build linux/ubuntu/2604/amd64/gcc
|
||||||
|
needs:
|
||||||
|
- build linux/ubuntu/2604/amd64/gcc
|
||||||
|
|
||||||
|
build linux/ubuntu/2604/amd64/clang:
|
||||||
|
<<: *build_linux_ubuntu_clang
|
||||||
|
image: ubuntu:26.04
|
||||||
|
|
||||||
|
unit_test linux/ubuntu/2604/amd64/clang:
|
||||||
|
<<: *test_linux_ubuntu_clang
|
||||||
|
image: ubuntu:26.04
|
||||||
|
dependencies:
|
||||||
|
- build linux/ubuntu/2604/amd64/clang
|
||||||
|
needs:
|
||||||
|
- build linux/ubuntu/2604/amd64/clang
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Fedora
|
# Fedora
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -243,30 +219,6 @@ unit_test linux/ubuntu/2404/amd64/clang:
|
|||||||
- linux-build
|
- linux-build
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
build linux/fedora/42/amd64/gcc:
|
|
||||||
<<: *build_linux_fedora_gcc
|
|
||||||
image: fedora:42
|
|
||||||
|
|
||||||
unit_test linux/fedora/42/amd64/gcc:
|
|
||||||
<<: *test_linux_fedora_gcc
|
|
||||||
image: fedora:42
|
|
||||||
dependencies:
|
|
||||||
- build linux/fedora/42/amd64/gcc
|
|
||||||
needs:
|
|
||||||
- build linux/fedora/42/amd64/gcc
|
|
||||||
|
|
||||||
build linux/fedora/42/amd64/clang:
|
|
||||||
<<: *build_linux_fedora_clang
|
|
||||||
image: fedora:42
|
|
||||||
|
|
||||||
unit_test linux/fedora/42/amd64/clang:
|
|
||||||
<<: *test_linux_fedora_clang
|
|
||||||
image: fedora:42
|
|
||||||
dependencies:
|
|
||||||
- build linux/fedora/42/amd64/clang
|
|
||||||
needs:
|
|
||||||
- build linux/fedora/42/amd64/clang
|
|
||||||
|
|
||||||
build linux/fedora/43/amd64/gcc:
|
build linux/fedora/43/amd64/gcc:
|
||||||
<<: *build_linux_fedora_gcc
|
<<: *build_linux_fedora_gcc
|
||||||
image: fedora:43
|
image: fedora:43
|
||||||
@@ -291,6 +243,30 @@ unit_test linux/fedora/43/amd64/clang:
|
|||||||
needs:
|
needs:
|
||||||
- build linux/fedora/43/amd64/clang
|
- build linux/fedora/43/amd64/clang
|
||||||
|
|
||||||
|
build linux/fedora/44/amd64/gcc:
|
||||||
|
<<: *build_linux_fedora_gcc
|
||||||
|
image: fedora:44
|
||||||
|
|
||||||
|
unit_test linux/fedora/44/amd64/gcc:
|
||||||
|
<<: *test_linux_fedora_gcc
|
||||||
|
image: fedora:44
|
||||||
|
dependencies:
|
||||||
|
- build linux/fedora/44/amd64/gcc
|
||||||
|
needs:
|
||||||
|
- build linux/fedora/44/amd64/gcc
|
||||||
|
|
||||||
|
build linux/fedora/44/amd64/clang:
|
||||||
|
<<: *build_linux_fedora_clang
|
||||||
|
image: fedora:44
|
||||||
|
|
||||||
|
unit_test linux/fedora/44/amd64/clang:
|
||||||
|
<<: *test_linux_fedora_clang
|
||||||
|
image: fedora:44
|
||||||
|
dependencies:
|
||||||
|
- build linux/fedora/44/amd64/clang
|
||||||
|
needs:
|
||||||
|
- build linux/fedora/44/amd64/clang
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Python Module
|
# Python Module
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -303,7 +279,8 @@ build python/linux/amd64:
|
|||||||
CIBW_BEFORE_ALL: sh ci/bootstrap-cibuildwheel.sh && sh ci/bootstrap-libpcap.sh
|
CIBW_BEFORE_ALL: sh ci/bootstrap-cibuildwheel.sh && sh ci/bootstrap-libpcap.sh
|
||||||
CIBW_BUILD: "*manylinux*" # no musl
|
CIBW_BUILD: "*manylinux*" # no musl
|
||||||
CIBW_ARCHS: x86_64
|
CIBW_ARCHS: x86_64
|
||||||
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install
|
CIBW_ENVIRONMENT: PCAP_ROOT=/project/libpcap/install
|
||||||
|
SKBUILD_CMAKE_DEFINE: ICSPB_BOOTSTRAP_DIR=/project/icspb
|
||||||
script:
|
script:
|
||||||
- sh ci/build-wheel-posix.sh
|
- sh ci/build-wheel-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -318,7 +295,8 @@ build python/linux/arm64:
|
|||||||
CIBW_BEFORE_ALL: sh ci/bootstrap-cibuildwheel.sh && sh ci/bootstrap-libpcap.sh
|
CIBW_BEFORE_ALL: sh ci/bootstrap-cibuildwheel.sh && sh ci/bootstrap-libpcap.sh
|
||||||
CIBW_BUILD: "*manylinux*" # no musl
|
CIBW_BUILD: "*manylinux*" # no musl
|
||||||
CIBW_ARCHS: aarch64
|
CIBW_ARCHS: aarch64
|
||||||
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install
|
CIBW_ENVIRONMENT: PCAP_ROOT=/project/libpcap/install
|
||||||
|
SKBUILD_CMAKE_DEFINE: ICSPB_BOOTSTRAP_DIR=/project/icspb
|
||||||
script:
|
script:
|
||||||
- sh ci/build-wheel-posix.sh
|
- sh ci/build-wheel-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -332,7 +310,8 @@ build python/macos:
|
|||||||
variables:
|
variables:
|
||||||
CIBW_BEFORE_ALL: sh ci/bootstrap-libpcap.sh
|
CIBW_BEFORE_ALL: sh ci/bootstrap-libpcap.sh
|
||||||
CIBW_ARCHS: arm64
|
CIBW_ARCHS: arm64
|
||||||
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=$CI_PROJECT_DIR/libpcap/install
|
CIBW_ENVIRONMENT: PCAP_ROOT=$CI_PROJECT_DIR/libpcap/install
|
||||||
|
SKBUILD_CMAKE_DEFINE: ICSPB_BOOTSTRAP_DIR=$CI_PROJECT_DIR/icspb
|
||||||
MACOSX_DEPLOYMENT_TARGET: 10.14
|
MACOSX_DEPLOYMENT_TARGET: 10.14
|
||||||
script:
|
script:
|
||||||
- sh ci/build-wheel-posix.sh
|
- sh ci/build-wheel-posix.sh
|
||||||
@@ -347,6 +326,7 @@ build python/windows:
|
|||||||
variables:
|
variables:
|
||||||
CIBW_ARCHS: AMD64
|
CIBW_ARCHS: AMD64
|
||||||
CIBW_ENVIRONMENT: CMAKE_GENERATOR=Ninja
|
CIBW_ENVIRONMENT: CMAKE_GENERATOR=Ninja
|
||||||
|
SKBUILD_CMAKE_DEFINE: ICSPB_BOOTSTRAP_DIR=$CI_PROJECT_DIR/icspb
|
||||||
script:
|
script:
|
||||||
- cmd /c ci\build-wheel-windows.bat
|
- cmd /c ci\build-wheel-windows.bat
|
||||||
artifacts:
|
artifacts:
|
||||||
|
|||||||
@@ -5,3 +5,6 @@ KERNEL=="ttyACM?", ATTRS{idVendor}=="093c", GROUP="users", MODE="0666"
|
|||||||
|
|
||||||
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="093c", KERNEL=="ttyUSB*", \
|
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="093c", KERNEL=="ttyUSB*", \
|
||||||
RUN+="/bin/sh -c 'echo $id:1.0>/sys/bus/usb/drivers/ftdi_sio/unbind'"
|
RUN+="/bin/sh -c 'echo $id:1.0>/sys/bus/usb/drivers/ftdi_sio/unbind'"
|
||||||
|
|
||||||
|
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="093c", DRIVER=="usbhid", \
|
||||||
|
RUN+="/bin/sh -c 'echo $id:1.0>/sys/bus/usb/drivers/usbhid/unbind'"
|
||||||
|
|||||||
+94
-9
@@ -1,5 +1,43 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(libicsneo VERSION 1.0.0)
|
|
||||||
|
function(git_tag_version VERSION_RESULT)
|
||||||
|
set(${VERSION_RESULT} "0.0.0.0" PARENT_SCOPE)
|
||||||
|
find_package(Git)
|
||||||
|
if(NOT Git_FOUND)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE LAST_TAG
|
||||||
|
RESULT_VARIABLE RESULT
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if(NOT RESULT EQUAL 0)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} rev-list ${LAST_TAG}..HEAD --count
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE COMMIT_COUNT_SINCE_TAG
|
||||||
|
RESULT_VARIABLE RESULT
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if(NOT RESULT EQUAL 0)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(${VERSION_RESULT} "${LAST_TAG}.${COMMIT_COUNT_SINCE_TAG}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
git_tag_version(LIBICSNEO_VERSION)
|
||||||
|
|
||||||
|
if(LIBICSNEO_VERSION STREQUAL "0.0.0.0")
|
||||||
|
message(WARNING "Unable to parse version from git history")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(libicsneo VERSION ${LIBICSNEO_VERSION})
|
||||||
|
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
if(POLICY CMP0135)
|
if(POLICY CMP0135)
|
||||||
@@ -11,6 +49,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")
|
||||||
@@ -42,7 +82,7 @@ if(MSVC)
|
|||||||
add_definitions(-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
|
add_definitions(-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
|
||||||
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
|
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
|
||||||
else() #if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
else() #if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(LIBICSNEO_COMPILER_WARNINGS -Wall -Wno-switch -Wno-unknown-pragmas)
|
set(LIBICSNEO_COMPILER_WARNINGS -Wall -Wno-unknown-pragmas)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
@@ -170,10 +210,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})
|
||||||
@@ -194,10 +230,18 @@ set(SRC_FILES
|
|||||||
communication/message/logdatamessage.cpp
|
communication/message/logdatamessage.cpp
|
||||||
communication/message/tc10statusmessage.cpp
|
communication/message/tc10statusmessage.cpp
|
||||||
communication/message/gptpstatusmessage.cpp
|
communication/message/gptpstatusmessage.cpp
|
||||||
|
communication/message/allmacaddressesmessage.cpp
|
||||||
communication/message/ethernetstatusmessage.cpp
|
communication/message/ethernetstatusmessage.cpp
|
||||||
communication/message/networkmutexmessage.cpp
|
communication/message/networkmutexmessage.cpp
|
||||||
communication/message/clientidmessage.cpp
|
communication/message/clientidmessage.cpp
|
||||||
|
communication/message/mfgconfigmessage.cpp
|
||||||
communication/message/transmitmessage.cpp
|
communication/message/transmitmessage.cpp
|
||||||
|
|
||||||
|
|
||||||
|
communication/message/spiportkeymessage.cpp
|
||||||
|
communication/message/genericapidatamessage.cpp
|
||||||
|
communication/message/genericapistatusmessage.cpp
|
||||||
|
communication/message/iso15765message.cpp
|
||||||
communication/packet/flexraypacket.cpp
|
communication/packet/flexraypacket.cpp
|
||||||
communication/packet/canpacket.cpp
|
communication/packet/canpacket.cpp
|
||||||
communication/packet/a2bpacket.cpp
|
communication/packet/a2bpacket.cpp
|
||||||
@@ -289,6 +333,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})
|
||||||
@@ -307,6 +352,7 @@ add_library(icsneocpp
|
|||||||
api/icsneocpp/icsneocpp.cpp
|
api/icsneocpp/icsneocpp.cpp
|
||||||
api/icsneocpp/event.cpp
|
api/icsneocpp/event.cpp
|
||||||
api/icsneocpp/eventmanager.cpp
|
api/icsneocpp/eventmanager.cpp
|
||||||
|
api/icsneocpp/heartbeat.cpp
|
||||||
api/icsneocpp/version.cpp
|
api/icsneocpp/version.cpp
|
||||||
${SRC_FILES}
|
${SRC_FILES}
|
||||||
)
|
)
|
||||||
@@ -360,7 +406,7 @@ if(LIBICSNEO_ENABLE_DXX)
|
|||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(libredxx
|
FetchContent_Declare(libredxx
|
||||||
GIT_REPOSITORY https://github.com/Zeranoe/libredxx.git
|
GIT_REPOSITORY https://github.com/Zeranoe/libredxx.git
|
||||||
GIT_TAG e1fe2bd6ba6079b17037379d78f3f18024b389d7
|
GIT_TAG e823a96c39a64ab41b7d1632dbe8f86bb854df83
|
||||||
)
|
)
|
||||||
set(LIBREDXX_DISABLE_INSTALL ON)
|
set(LIBREDXX_DISABLE_INSTALL ON)
|
||||||
FetchContent_MakeAvailable(libredxx)
|
FetchContent_MakeAvailable(libredxx)
|
||||||
@@ -392,7 +438,7 @@ endif()
|
|||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(icspb
|
FetchContent_Declare(icspb
|
||||||
GIT_REPOSITORY ${LIBICSNEO_ICSPB_REPO}
|
GIT_REPOSITORY ${LIBICSNEO_ICSPB_REPO}
|
||||||
GIT_TAG 48df5dd7fd0c38034f82a2f94e0eada404d5e2b9
|
GIT_TAG 3339fa6b83a6b3e7704d41f5c2f2175cfc761a1f
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(icspb)
|
FetchContent_MakeAvailable(icspb)
|
||||||
target_link_libraries(icsneocpp PRIVATE icspb::icspb)
|
target_link_libraries(icsneocpp PRIVATE icspb::icspb)
|
||||||
@@ -426,6 +472,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 +545,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 +557,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 +572,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 +581,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})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2018-2025 Intrepid Control Systems, Inc.
|
Copyright (c) 2018-2026 Intrepid Control Systems, Inc.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
are permitted provided that the following conditions are met:
|
are permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -4,11 +4,20 @@ libicsneo is the [Intrepid Control Systems](https://intrepidcs.com/) device
|
|||||||
communication library. Installation and usage documentation can be found within
|
communication library. Installation and usage documentation can be found within
|
||||||
each of the respective APIs.
|
each of the respective APIs.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
libicsneo relies on Servd, IntrepidCS's device communication server.
|
||||||
|
|
||||||
|
Servd can be installed for all platforms from https://cdn.intrepidcs.net/servd/.
|
||||||
|
|
||||||
|
Instructions for installing each API can be found in its respective documentation.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- [C++](https://libicsneo.readthedocs.io/en/latest/icsneocpp/)
|
- [C++](https://libicsneo.readthedocs.io/en/latest/icsneocpp/)
|
||||||
- [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
|
||||||
|
|
||||||
@@ -36,7 +45,7 @@ each of the respective APIs.
|
|||||||
- RAD-Pluto
|
- RAD-Pluto
|
||||||
- RAD-Star 2
|
- RAD-Star 2
|
||||||
- RAD-SuperMoon
|
- RAD-SuperMoon
|
||||||
- RADComet
|
- RAD-wBMS
|
||||||
- ValueCAN 3
|
- ValueCAN 3
|
||||||
- ValueCAN 4
|
- ValueCAN 4
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ BEGIN
|
|||||||
VALUE "FileDescription", "Intrepid Control Systems Open Device Communication C API"
|
VALUE "FileDescription", "Intrepid Control Systems Open Device Communication C API"
|
||||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||||
VALUE "InternalName", "icsneoc.dll"
|
VALUE "InternalName", "icsneoc.dll"
|
||||||
VALUE "LegalCopyright", "Intrepid Control Systems, Inc. (C) 2018-2025"
|
VALUE "LegalCopyright", "Intrepid Control Systems, Inc. (C) 2018-2026"
|
||||||
VALUE "OriginalFilename", "icsneoc.dll"
|
VALUE "OriginalFilename", "icsneoc.dll"
|
||||||
VALUE "ProductName", "libicsneo"
|
VALUE "ProductName", "libicsneo"
|
||||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,74 @@
|
|||||||
|
// 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_supported_device_t {
|
||||||
|
DeviceType device_type;
|
||||||
|
icsneoc2_supported_device_t* next;
|
||||||
|
} icsneoc2_supported_device_t;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
typedef struct icsneoc2_chip_versions_t {
|
||||||
|
VersionReport version_report;
|
||||||
|
icsneoc2_chip_versions_t* next;
|
||||||
|
} icsneoc2_chip_versions_t;
|
||||||
|
|
||||||
|
typedef struct icsneoc2_termination_group_t {
|
||||||
|
std::vector<icsneoc2_netid_t> netids;
|
||||||
|
icsneoc2_termination_group_t* next;
|
||||||
|
} icsneoc2_termination_group_t;
|
||||||
|
|
||||||
|
typedef struct icsneoc2_mac_addr_entry_t {
|
||||||
|
uint16_t network_id;
|
||||||
|
uint8_t address[ICSNEO_MAC_ADDRESS_LEN];
|
||||||
|
icsneoc2_mac_addr_entry_t* next;
|
||||||
|
} icsneoc2_mac_addr_entry_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);
|
||||||
@@ -0,0 +1,710 @@
|
|||||||
|
#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/canerrormessage.h"
|
||||||
|
#include "icsneo/communication/message/apperrormessage.h"
|
||||||
|
#include "icsneo/communication/message/linmessage.h"
|
||||||
|
#include "icsneo/communication/message/ethernetmessage.h"
|
||||||
|
#include "icsneo/communication/message/ethernetstatusmessage.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_is_error(icsneoc2_message_t* message, bool* value) {
|
||||||
|
if(!message || !value) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto frame = std::dynamic_pointer_cast<Frame>(message->message);
|
||||||
|
if(!frame) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
*value = frame->error;
|
||||||
|
|
||||||
|
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_netid_network_type_get(icsneoc2_netid_t netid, icsneoc2_network_type_t* network_type) {
|
||||||
|
if(!network_type) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*network_type = static_cast<icsneoc2_network_type_t>(Network::GetTypeOfNetID(static_cast<Network::NetID>(netid), true));
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_message_t* message, icsneoc2_netid_t netid) {
|
||||||
|
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_timestamp_set(icsneoc2_message_t* message, uint64_t timestamp) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
if(!message->message) {
|
||||||
|
return icsneoc2_error_invalid_message;
|
||||||
|
}
|
||||||
|
message->message->timestamp = timestamp;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_timestamp_get(icsneoc2_message_t* message, uint64_t* timestamp) {
|
||||||
|
if(!message || !timestamp) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
if(!message->message) {
|
||||||
|
return icsneoc2_error_invalid_message;
|
||||||
|
}
|
||||||
|
*timestamp = message->message->timestamp;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
if(can_msg->txAborted) {
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_TX_ABORTED;
|
||||||
|
}
|
||||||
|
if(can_msg->txLostArb) {
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_TX_LOST_ARB;
|
||||||
|
}
|
||||||
|
if(can_msg->txError) {
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_TX_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_is_can_error(icsneoc2_message_t* message, bool* is_can_error) {
|
||||||
|
if(!message || !is_can_error) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*is_can_error = std::dynamic_pointer_cast<CANErrorMessage>(message->message) != nullptr;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_can_error_props_get(
|
||||||
|
icsneoc2_message_t *message, uint8_t *tx_err_count, uint8_t *rx_err_count,
|
||||||
|
icsneoc2_can_error_code_t *error_code,
|
||||||
|
icsneoc2_can_error_code_t *data_error_code,
|
||||||
|
icsneoc2_message_can_error_flags_t *flags) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto can_err = std::dynamic_pointer_cast<CANErrorMessage>(message->message);
|
||||||
|
if(!can_err) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(tx_err_count) {
|
||||||
|
*tx_err_count = can_err->transmitErrorCount;
|
||||||
|
}
|
||||||
|
if(rx_err_count) {
|
||||||
|
*rx_err_count = can_err->receiveErrorCount;
|
||||||
|
}
|
||||||
|
if(error_code) {
|
||||||
|
*error_code = static_cast<icsneoc2_can_error_code_t>(can_err->errorCode);
|
||||||
|
}
|
||||||
|
if(data_error_code) {
|
||||||
|
*data_error_code = static_cast<icsneoc2_can_error_code_t>(can_err->dataErrorCode);
|
||||||
|
}
|
||||||
|
if(flags) {
|
||||||
|
*flags = 0;
|
||||||
|
if(can_err->busOff) {
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_CAN_ERROR_FLAGS_BUS_OFF;
|
||||||
|
}
|
||||||
|
if(can_err->errorPassive) {
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_CAN_ERROR_FLAGS_ERROR_PASSIVE;
|
||||||
|
}
|
||||||
|
if(can_err->errorWarn) {
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_CAN_ERROR_FLAGS_ERROR_WARN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_is_app_error(icsneoc2_message_t* message, bool* is_app_error) {
|
||||||
|
if(!message || !is_app_error) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*is_app_error = std::dynamic_pointer_cast<AppErrorMessage>(message->message) != nullptr;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_app_error_props_get(icsneoc2_message_t* message,
|
||||||
|
icsneoc2_app_error_type_t* error_type, icsneoc2_netid_t* error_netid) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto app_err = std::dynamic_pointer_cast<AppErrorMessage>(message->message);
|
||||||
|
if(!app_err) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(error_type) {
|
||||||
|
*error_type = static_cast<icsneoc2_app_error_type_t>(app_err->getAppErrorType());
|
||||||
|
}
|
||||||
|
if(error_netid) {
|
||||||
|
*error_netid = static_cast<icsneoc2_netid_t>(app_err->errorNetID);
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_app_error_string_get(icsneoc2_message_t* message,
|
||||||
|
char* value, size_t* value_length) {
|
||||||
|
if(!message || !value_length) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto app_err = std::dynamic_pointer_cast<AppErrorMessage>(message->message);
|
||||||
|
if(!app_err) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
return safe_str_copy(value, value_length, app_err->getAppErrorString()) ? icsneoc2_error_success : icsneoc2_error_string_copy_failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_is_lin(icsneoc2_message_t* message, bool* is_lin) {
|
||||||
|
if(!message || !is_lin) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*is_lin = std::dynamic_pointer_cast<LINMessage>(message->message) != nullptr;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_lin_create(icsneoc2_message_t** message, uint8_t id) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
*message = new icsneoc2_message_t;
|
||||||
|
(*message)->message = std::make_shared<LINMessage>(id);
|
||||||
|
} catch(const std::bad_alloc&) {
|
||||||
|
return icsneoc2_error_out_of_memory;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_lin_props_get(const icsneoc2_message_t* message,
|
||||||
|
uint8_t* id, uint8_t* protected_id, uint8_t* checksum,
|
||||||
|
icsneoc2_lin_msg_type_t* msg_type, bool* is_enhanced_checksum) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto lin_msg = std::dynamic_pointer_cast<LINMessage>(message->message);
|
||||||
|
if(!lin_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(id) {
|
||||||
|
*id = lin_msg->ID;
|
||||||
|
}
|
||||||
|
if(protected_id) {
|
||||||
|
*protected_id = lin_msg->protectedID;
|
||||||
|
}
|
||||||
|
if(checksum) {
|
||||||
|
*checksum = lin_msg->checksum;
|
||||||
|
}
|
||||||
|
if(msg_type) {
|
||||||
|
*msg_type = static_cast<icsneoc2_lin_msg_type_t>(lin_msg->linMsgType);
|
||||||
|
}
|
||||||
|
if(is_enhanced_checksum) {
|
||||||
|
*is_enhanced_checksum = lin_msg->isEnhancedChecksum;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_lin_props_set(icsneoc2_message_t* message,
|
||||||
|
const uint8_t* id, const uint8_t* checksum,
|
||||||
|
const icsneoc2_lin_msg_type_t* msg_type, const bool* is_enhanced_checksum) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto lin_msg = std::dynamic_pointer_cast<LINMessage>(message->message);
|
||||||
|
if(!lin_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(id) {
|
||||||
|
lin_msg->ID = *id & 0x3Fu;
|
||||||
|
lin_msg->protectedID = lin_msg->calcProtectedID(lin_msg->ID);
|
||||||
|
}
|
||||||
|
if(checksum) {
|
||||||
|
lin_msg->checksum = *checksum;
|
||||||
|
}
|
||||||
|
if(msg_type) {
|
||||||
|
lin_msg->linMsgType = static_cast<LINMessage::Type>(*msg_type);
|
||||||
|
}
|
||||||
|
if(is_enhanced_checksum) {
|
||||||
|
lin_msg->isEnhancedChecksum = *is_enhanced_checksum;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_lin_err_flags_get(const icsneoc2_message_t* message, icsneoc2_lin_err_flags_t* err_flags) {
|
||||||
|
if(!message || !err_flags) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto lin_msg = std::dynamic_pointer_cast<LINMessage>(message->message);
|
||||||
|
if(!lin_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
*err_flags = 0;
|
||||||
|
if(lin_msg->errFlags.ErrRxBreakOnly) *err_flags |= ICSNEOC2_LIN_ERR_RX_BREAK_ONLY;
|
||||||
|
if(lin_msg->errFlags.ErrRxBreakSyncOnly) *err_flags |= ICSNEOC2_LIN_ERR_RX_BREAK_SYNC_ONLY;
|
||||||
|
if(lin_msg->errFlags.ErrTxRxMismatch) *err_flags |= ICSNEOC2_LIN_ERR_TX_RX_MISMATCH;
|
||||||
|
if(lin_msg->errFlags.ErrRxBreakNotZero) *err_flags |= ICSNEOC2_LIN_ERR_RX_BREAK_NOT_ZERO;
|
||||||
|
if(lin_msg->errFlags.ErrRxBreakTooShort) *err_flags |= ICSNEOC2_LIN_ERR_RX_BREAK_TOO_SHORT;
|
||||||
|
if(lin_msg->errFlags.ErrRxSyncNot55) *err_flags |= ICSNEOC2_LIN_ERR_RX_SYNC_NOT_55;
|
||||||
|
if(lin_msg->errFlags.ErrRxDataLenOver8) *err_flags |= ICSNEOC2_LIN_ERR_RX_DATA_LEN_OVER_8;
|
||||||
|
if(lin_msg->errFlags.ErrFrameSync) *err_flags |= ICSNEOC2_LIN_ERR_FRAME_SYNC;
|
||||||
|
if(lin_msg->errFlags.ErrFrameMessageID) *err_flags |= ICSNEOC2_LIN_ERR_FRAME_MESSAGE_ID;
|
||||||
|
if(lin_msg->errFlags.ErrFrameResponderData) *err_flags |= ICSNEOC2_LIN_ERR_FRAME_RESPONDER_DATA;
|
||||||
|
if(lin_msg->errFlags.ErrChecksumMatch) *err_flags |= ICSNEOC2_LIN_ERR_CHECKSUM_MATCH;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_lin_status_flags_get(const icsneoc2_message_t* message, icsneoc2_lin_status_flags_t* status_flags) {
|
||||||
|
if(!message || !status_flags) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto lin_msg = std::dynamic_pointer_cast<LINMessage>(message->message);
|
||||||
|
if(!lin_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
*status_flags = 0;
|
||||||
|
if(lin_msg->statusFlags.TxChecksumEnhanced) *status_flags |= ICSNEOC2_LIN_STATUS_TX_CHECKSUM_ENHANCED;
|
||||||
|
if(lin_msg->statusFlags.TxCommander) *status_flags |= ICSNEOC2_LIN_STATUS_TX_COMMANDER;
|
||||||
|
if(lin_msg->statusFlags.TxResponder) *status_flags |= ICSNEOC2_LIN_STATUS_TX_RESPONDER;
|
||||||
|
if(lin_msg->statusFlags.TxAborted) *status_flags |= ICSNEOC2_LIN_STATUS_TX_ABORTED;
|
||||||
|
if(lin_msg->statusFlags.UpdateResponderOnce) *status_flags |= ICSNEOC2_LIN_STATUS_UPDATE_RESPONDER_ONCE;
|
||||||
|
if(lin_msg->statusFlags.HasUpdatedResponderOnce) *status_flags |= ICSNEOC2_LIN_STATUS_HAS_UPDATED_RESPONDER_ONCE;
|
||||||
|
if(lin_msg->statusFlags.BusRecovered) *status_flags |= ICSNEOC2_LIN_STATUS_BUS_RECOVERED;
|
||||||
|
if(lin_msg->statusFlags.BreakOnly) *status_flags |= ICSNEOC2_LIN_STATUS_BREAK_ONLY;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_lin_calc_checksum(icsneoc2_message_t* message) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto lin_msg = std::dynamic_pointer_cast<LINMessage>(message->message);
|
||||||
|
if(!lin_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
LINMessage::calcChecksum(*lin_msg);
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_create(icsneoc2_message_t** message) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
*message = new icsneoc2_message_t;
|
||||||
|
(*message)->message = std::make_shared<EthernetMessage>();
|
||||||
|
} catch(const std::bad_alloc&) {
|
||||||
|
return icsneoc2_error_out_of_memory;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_props_set(icsneoc2_message_t* message, const icsneoc2_message_eth_flags_t* flags, const bool* has_fcs, const uint32_t* fcs) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto eth_msg = std::dynamic_pointer_cast<EthernetMessage>(message->message);
|
||||||
|
if(!eth_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(flags) {
|
||||||
|
eth_msg->frameTooShort = (*flags & ICSNEOC2_MESSAGE_ETH_FLAGS_FRAME_TOO_SHORT);
|
||||||
|
eth_msg->noPadding = (*flags & ICSNEOC2_MESSAGE_ETH_FLAGS_NO_PADDING);
|
||||||
|
eth_msg->fcsVerified = (*flags & ICSNEOC2_MESSAGE_ETH_FLAGS_FCS_VERIFIED);
|
||||||
|
eth_msg->txAborted = (*flags & ICSNEOC2_MESSAGE_ETH_FLAGS_TX_ABORTED);
|
||||||
|
eth_msg->crcError = (*flags & ICSNEOC2_MESSAGE_ETH_FLAGS_CRC_ERROR);
|
||||||
|
}
|
||||||
|
if(has_fcs && !*has_fcs) {
|
||||||
|
eth_msg->fcs = std::nullopt;
|
||||||
|
} else if(has_fcs && *has_fcs) {
|
||||||
|
// I'm pretty sure we can leave this alone, setting fcs below will take care of the behavior,
|
||||||
|
// otherwise we get into a weird state where we have to set fcs to zero if fcs is null but has_fcs is true.
|
||||||
|
}
|
||||||
|
if (fcs) {
|
||||||
|
eth_msg->fcs = *fcs;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_props_get(icsneoc2_message_t* message, icsneoc2_message_eth_flags_t* flags, bool* has_fcs, uint32_t* fcs) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto eth_msg = std::dynamic_pointer_cast<EthernetMessage>(message->message);
|
||||||
|
if(!eth_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(flags) {
|
||||||
|
*flags = 0;
|
||||||
|
if(eth_msg->noPadding)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_FLAGS_NO_PADDING;
|
||||||
|
if(eth_msg->fcsVerified)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_FLAGS_FCS_VERIFIED;
|
||||||
|
if(eth_msg->txAborted)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_FLAGS_TX_ABORTED;
|
||||||
|
if(eth_msg->crcError)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_FLAGS_CRC_ERROR;
|
||||||
|
if(eth_msg->frameTooShort)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_FLAGS_FRAME_TOO_SHORT;
|
||||||
|
}
|
||||||
|
if(has_fcs) {
|
||||||
|
*has_fcs = eth_msg->fcs.has_value();
|
||||||
|
}
|
||||||
|
if(fcs) {
|
||||||
|
if(eth_msg->fcs) {
|
||||||
|
*fcs = eth_msg->fcs.value();
|
||||||
|
} else {
|
||||||
|
*fcs = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_mac_get(icsneoc2_message_t* message, uint8_t* dst_mac, uint8_t* src_mac) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto eth_msg = std::dynamic_pointer_cast<EthernetMessage>(message->message);
|
||||||
|
if(!eth_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(dst_mac) {
|
||||||
|
if(auto mac = eth_msg->getDestinationMAC(); mac.has_value()) {
|
||||||
|
const auto& mac_value = mac.value();
|
||||||
|
std::memcpy(dst_mac, mac_value.data(), mac_value.size());
|
||||||
|
} else {
|
||||||
|
return icsneoc2_error_invalid_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(src_mac) {
|
||||||
|
if(auto mac = eth_msg->getSourceMAC(); mac.has_value()) {
|
||||||
|
const auto& mac_value = mac.value();
|
||||||
|
std::memcpy(src_mac, mac_value.data(), mac_value.size());
|
||||||
|
} else {
|
||||||
|
return icsneoc2_error_invalid_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_ether_type_get(icsneoc2_message_t* message, uint16_t* ether_type) {
|
||||||
|
if(!message || !ether_type) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto eth_msg = std::dynamic_pointer_cast<EthernetMessage>(message->message);
|
||||||
|
if(!eth_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if (auto et = eth_msg->getEtherType(); et.has_value()) {
|
||||||
|
*ether_type = et.value();
|
||||||
|
} else {
|
||||||
|
return icsneoc2_error_invalid_data;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_t1s_props_set(icsneoc2_message_t* message, const icsneoc2_message_eth_t1s_flags_t* flags, const uint8_t* node_id, const uint8_t* burst_count, const uint8_t* symbol_type) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto eth_msg = std::dynamic_pointer_cast<EthernetMessage>(message->message);
|
||||||
|
if(!eth_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
// If all parameters are null/zero, clear the T1S state. Otherwise, if any parameters are set and we don't have a T1S state, create it.
|
||||||
|
if(!flags && !node_id && !burst_count && !symbol_type) {
|
||||||
|
eth_msg->t1s = std::nullopt;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
if((flags || node_id || burst_count || symbol_type) && !eth_msg->t1s.has_value()) {
|
||||||
|
eth_msg->t1s.emplace();
|
||||||
|
}
|
||||||
|
if(flags) {
|
||||||
|
eth_msg->t1s->isSymbol = (*flags & ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_IS_T1S_SYMBOL);
|
||||||
|
eth_msg->t1s->isBurst = (*flags & ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_IS_T1S_BURST);
|
||||||
|
eth_msg->t1s->txCollision = (*flags & ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_TX_COLLISION);
|
||||||
|
eth_msg->t1s->isWake = (*flags & ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_IS_T1S_WAKE);
|
||||||
|
}
|
||||||
|
if(node_id) {
|
||||||
|
eth_msg->t1s->nodeId = *node_id;
|
||||||
|
}
|
||||||
|
if(burst_count) {
|
||||||
|
eth_msg->t1s->burstCount = *burst_count;
|
||||||
|
}
|
||||||
|
if(symbol_type) {
|
||||||
|
eth_msg->t1s->symbolType = *symbol_type;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_t1s_props_get(icsneoc2_message_t* message, icsneoc2_message_eth_t1s_flags_t* flags, uint8_t* node_id, uint8_t* burst_count, uint8_t* symbol_type) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto eth_msg = std::dynamic_pointer_cast<EthernetMessage>(message->message);
|
||||||
|
if(!eth_msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(flags) {
|
||||||
|
*flags = 0;
|
||||||
|
if(eth_msg->t1s.has_value()) {
|
||||||
|
if(eth_msg->t1s->isSymbol)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_IS_T1S_SYMBOL;
|
||||||
|
if(eth_msg->t1s->isBurst)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_IS_T1S_BURST;
|
||||||
|
if(eth_msg->t1s->txCollision)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_TX_COLLISION;
|
||||||
|
if(eth_msg->t1s->isWake)
|
||||||
|
*flags |= ICSNEOC2_MESSAGE_ETH_T1S_FLAGS_IS_T1S_WAKE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(node_id) {
|
||||||
|
*node_id = eth_msg->t1s.has_value() ? eth_msg->t1s->nodeId : 0;
|
||||||
|
}
|
||||||
|
if(burst_count) {
|
||||||
|
*burst_count = eth_msg->t1s.has_value() ? eth_msg->t1s->burstCount : 0;
|
||||||
|
}
|
||||||
|
if(symbol_type) {
|
||||||
|
*symbol_type = eth_msg->t1s.has_value() ? eth_msg->t1s->symbolType : 0;
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_is_ethernet(icsneoc2_message_t* message, bool* is_ethernet) {
|
||||||
|
if(!message || !is_ethernet) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*is_ethernet = std::dynamic_pointer_cast<EthernetMessage>(message->message) != nullptr;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_is_ethernet_status(icsneoc2_message_t* message, bool* is_ethernet_status) {
|
||||||
|
if(!message || !is_ethernet_status) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
*is_ethernet_status = std::dynamic_pointer_cast<EthernetStatusMessage>(message->message) != nullptr;
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_error_t icsneoc2_message_eth_status_props_get(icsneoc2_message_t* message, bool* link_state, bool* duplex, icsneoc2_link_speed_t* link_speed, icsneoc2_link_mode_t* link_mode) {
|
||||||
|
if(!message) {
|
||||||
|
return icsneoc2_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
auto msg = std::dynamic_pointer_cast<EthernetStatusMessage>(message->message);
|
||||||
|
if(!msg) {
|
||||||
|
return icsneoc2_error_invalid_type;
|
||||||
|
}
|
||||||
|
if(link_state) {
|
||||||
|
*link_state = msg->state;
|
||||||
|
}
|
||||||
|
if(duplex) {
|
||||||
|
*duplex = msg->duplex;
|
||||||
|
}
|
||||||
|
if(link_speed) {
|
||||||
|
*link_speed = static_cast<icsneoc2_link_speed_t>(msg->speed);
|
||||||
|
}
|
||||||
|
if(link_mode) {
|
||||||
|
*link_mode = static_cast<icsneoc2_link_mode_t>(msg->mode);
|
||||||
|
}
|
||||||
|
return icsneoc2_error_success;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||||
+85
-35
@@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
APIEvent::APIEvent(Type type, APIEvent::Severity severity, const Device* device) : eventStruct({}) {
|
APIEvent::APIEvent(Type type, APIEvent::Severity severity, std::weak_ptr<Device> device) : eventStruct({}), device(device) {
|
||||||
this->device = device;
|
auto shared = device.lock();
|
||||||
if(device) {
|
if(shared) {
|
||||||
serial = device->getSerial();
|
serial = shared->getSerial();
|
||||||
eventStruct.serial[serial.copy(eventStruct.serial, sizeof(eventStruct.serial))] = '\0';
|
eventStruct.serial[serial.copy(eventStruct.serial, sizeof(eventStruct.serial))] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,37 +22,15 @@ void APIEvent::init(Type event, APIEvent::Severity severity) {
|
|||||||
eventStruct.timestamp = EventClock::to_time_t(timepoint);
|
eventStruct.timestamp = EventClock::to_time_t(timepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string APIEvent::describe() const noexcept {
|
|
||||||
std::stringstream ss;
|
|
||||||
if(device)
|
|
||||||
ss << *device; // Makes use of device.describe()
|
|
||||||
else
|
|
||||||
ss << "API";
|
|
||||||
|
|
||||||
Severity severity = getSeverity();
|
|
||||||
if(severity == Severity::EventInfo) {
|
|
||||||
ss << " Info: ";
|
|
||||||
} else if(severity == Severity::EventWarning) {
|
|
||||||
ss << " Warning: ";
|
|
||||||
} else if(severity == Severity::Error) {
|
|
||||||
ss << " Error: ";
|
|
||||||
} else {
|
|
||||||
// Should never get here, since Severity::Any should only be used for filtering
|
|
||||||
ss << " Any: ";
|
|
||||||
}
|
|
||||||
|
|
||||||
ss << getDescription();
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void APIEvent::downgradeFromError() noexcept {
|
void APIEvent::downgradeFromError() noexcept {
|
||||||
eventStruct.severity = (uint8_t) APIEvent::Severity::EventWarning;
|
eventStruct.severity = (uint8_t) APIEvent::Severity::EventWarning;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APIEvent::isForDevice(std::string filterSerial) const noexcept {
|
bool APIEvent::isForDevice(std::string filterSerial) const noexcept {
|
||||||
if(!device || filterSerial.length() == 0)
|
auto shared = device.lock();
|
||||||
|
if(!shared || filterSerial.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
return device->getSerial() == filterSerial;
|
return shared->getSerial() == filterSerial;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API Errors
|
// API Errors
|
||||||
@@ -86,8 +64,8 @@ static constexpr const char* NO_SERIAL_NUMBER_12V = "Communication could not be
|
|||||||
static constexpr const char* NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered or requires a firmware update using Vehicle Spy.";
|
static constexpr const char* NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered or requires a firmware update using Vehicle Spy.";
|
||||||
static constexpr const char* INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!";
|
static constexpr const char* INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!";
|
||||||
static constexpr const char* SETTINGS_READ = "The device settings could not be read.";
|
static constexpr const char* SETTINGS_READ = "The device settings could not be read.";
|
||||||
static constexpr const char* SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with neoVI Explorer.";
|
static constexpr const char* SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with ICS Device Manager.";
|
||||||
static constexpr const char* SETTINGS_LENGTH = "The settings length is incorrect, please update your firmware with neoVI Explorer.";
|
static constexpr const char* SETTINGS_LENGTH = "The settings length is incorrect, please update your firmware with ICS Device Manager.";
|
||||||
static constexpr const char* SETTINGS_CHECKSUM = "The settings checksum is incorrect, attempting to set defaults may remedy this issue.";
|
static constexpr const char* SETTINGS_CHECKSUM = "The settings checksum is incorrect, attempting to set defaults may remedy this issue.";
|
||||||
static constexpr const char* SETTINGS_NOT_AVAILABLE = "Settings are not available for this device.";
|
static constexpr const char* SETTINGS_NOT_AVAILABLE = "Settings are not available for this device.";
|
||||||
static constexpr const char* SETTINGS_READONLY = "Settings are read-only for this device.";
|
static constexpr const char* SETTINGS_READONLY = "Settings are read-only for this device.";
|
||||||
@@ -118,18 +96,28 @@ static constexpr const char* ATOMIC_OPERATION_COMPLETED_NONATOMICALLY = "An idea
|
|||||||
static constexpr const char* WIVI_STACK_REFRESH_FAILED = "The Wireless neoVI stack encountered a communication error.";
|
static constexpr const char* WIVI_STACK_REFRESH_FAILED = "The Wireless neoVI stack encountered a communication error.";
|
||||||
static constexpr const char* WIVI_UPLOAD_STACK_OVERFLOW = "The Wireless neoVI upload stack has encountered an overflow condition.";
|
static constexpr const char* WIVI_UPLOAD_STACK_OVERFLOW = "The Wireless neoVI upload stack has encountered an overflow condition.";
|
||||||
static constexpr const char* A2B_MESSAGE_INCOMPLETE_FRAME = "At least one of the frames of the A2B message does not contain samples for each channel and stream.";
|
static constexpr const char* A2B_MESSAGE_INCOMPLETE_FRAME = "At least one of the frames of the A2B message does not contain samples for each channel and stream.";
|
||||||
|
static constexpr const char* I2C_MESSAGE_EXCEED_MAX_LENGTH = "The I2C message was too long.";
|
||||||
static constexpr const char* COREMINI_UPLOAD_VERSION_MISMATCH = "The version of the coremini engine on the device and the script uploaded are not the same.";
|
static constexpr const char* COREMINI_UPLOAD_VERSION_MISMATCH = "The version of the coremini engine on the device and the script uploaded are not the same.";
|
||||||
static constexpr const char* DISK_NOT_CONNECTED = "The program tried to access a disk that is not connected.";
|
static constexpr const char* DISK_NOT_CONNECTED = "The program tried to access a disk that is not connected.";
|
||||||
static constexpr const char* UNEXPECTED_RESPONSE = "Received an unexpected or invalid response from the device.";
|
static constexpr const char* UNEXPECTED_RESPONSE = "Received an unexpected or invalid response from the device.";
|
||||||
|
static constexpr const char* LIVE_DATA_INVALID_HANDLE = "The live data handle was invalid.";
|
||||||
|
static constexpr const char* LIVE_DATA_INVALID_COMMAND = "The live data command was invalid.";
|
||||||
|
static constexpr const char* LIVE_DATA_INVALID_ARGUMENT = "The live data argument was invalid.";
|
||||||
|
static constexpr const char* LIVE_DATA_VERSION_MISMATCH = "The live data version between libicsneo and firmware are not the same.";
|
||||||
|
static constexpr const char* LIVE_DATA_NO_DEVICE_RESPONSE = "Expected a response from the device for live data but none were found.";
|
||||||
|
static constexpr const char* LIVE_DATA_MAX_SIGNALS_REACHED = "The max amound of signals to subscribe to for live data has been reached.";
|
||||||
|
static constexpr const char* LIVE_DATA_COMMAND_FAILED = "The live data command failed.";
|
||||||
|
static constexpr const char* LIVE_DATA_ENCODER_ERROR = "Failure to encode live data message.";
|
||||||
|
static constexpr const char* LIVE_DATA_DECODER_ERROR = "Failure to decode live data message.";
|
||||||
|
static constexpr const char* LIVE_DATA_NOT_SUPPORTED = "Live data is not supported on this device.";
|
||||||
static constexpr const char* LIN_SETTINGS_NOT_AVAILABLE = "LIN settings are not available for this device.";
|
static constexpr const char* LIN_SETTINGS_NOT_AVAILABLE = "LIN settings are not available for this device.";
|
||||||
static constexpr const char* MODE_NOT_FOUND = "The mode was not found.";
|
static constexpr const char* MODE_NOT_FOUND = "The mode was not found.";
|
||||||
|
static constexpr const char* APP_ERROR_PARSING_FAILED = "Failure to decode app error message.";
|
||||||
static constexpr const char* GPTP_NOT_SUPPORTED = "GPTP clock synchronization is not supported on this device.";
|
static constexpr const char* GPTP_NOT_SUPPORTED = "GPTP clock synchronization is not supported on this device.";
|
||||||
static constexpr const char* SETTING_NOT_AVAILABLE = "Requested a setting that is not available on this device";
|
static constexpr const char* SETTING_NOT_AVAILABLE = "Requested a setting that is not available on this device";
|
||||||
static constexpr const char* DISK_FORMAT_NOT_SUPPORTED = "Disk formatting is not supported on this device.";
|
static constexpr const char* DISK_FORMAT_NOT_SUPPORTED = "Disk formatting is not supported on this device.";
|
||||||
static constexpr const char* DISK_FORMAT_INVALID_COUNT = "Disk format config disk count is mismatched with device disk count.";
|
static constexpr const char* DISK_FORMAT_INVALID_COUNT = "Disk format config disk count is mismatched with device disk count.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Transport Errors
|
// Transport Errors
|
||||||
static constexpr const char* FAILED_TO_READ = "A read operation failed.";
|
static constexpr const char* FAILED_TO_READ = "A read operation failed.";
|
||||||
static constexpr const char* FAILED_TO_WRITE = "A write operation failed.";
|
static constexpr const char* FAILED_TO_WRITE = "A write operation failed.";
|
||||||
@@ -146,6 +134,7 @@ static constexpr const char* FAILED_TO_BIND = "Unable to bind socket.";
|
|||||||
static constexpr const char* ERROR_SETTING_SOCKET_OPTION = "A call to setsockopt() failed.";
|
static constexpr const char* ERROR_SETTING_SOCKET_OPTION = "A call to setsockopt() failed.";
|
||||||
static constexpr const char* GETIFADDRS_ERROR = "A call to getifaddrs() failed.";
|
static constexpr const char* GETIFADDRS_ERROR = "A call to getifaddrs() failed.";
|
||||||
static constexpr const char* SEND_TO_ERROR = "A call to sendto() failed.";
|
static constexpr const char* SEND_TO_ERROR = "A call to sendto() failed.";
|
||||||
|
static constexpr const char* MDIO_MESSAGE_EXCEED_MAX_LENGTH = "The MDIO message was too long.";
|
||||||
|
|
||||||
// VSA
|
// VSA
|
||||||
static constexpr const char* VSA_BUFFER_CORRUPTED = "VSA data in record buffer is corrupted.";
|
static constexpr const char* VSA_BUFFER_CORRUPTED = "VSA data in record buffer is corrupted.";
|
||||||
@@ -178,6 +167,7 @@ static constexpr const char* SERVD_RECV_ERROR = "Error receiving from Servd";
|
|||||||
static constexpr const char* SERVD_POLL_ERROR = "Error polling on Servd socket";
|
static constexpr const char* SERVD_POLL_ERROR = "Error polling on Servd socket";
|
||||||
static constexpr const char* SERVD_NODATA_ERROR = "No data received from Servd";
|
static constexpr const char* SERVD_NODATA_ERROR = "No data received from Servd";
|
||||||
static constexpr const char* SERVD_JOIN_MULTICAST_ERROR = "Error joining Servd multicast group";
|
static constexpr const char* SERVD_JOIN_MULTICAST_ERROR = "Error joining Servd multicast group";
|
||||||
|
static constexpr const char* SERVD_NOT_REACHABLE = "Could not reach Servd; ensure it is installed and running";
|
||||||
|
|
||||||
// DXX
|
// DXX
|
||||||
static constexpr const char* DXX_ERROR_SYS = "System error, check errno/GetLastError()";
|
static constexpr const char* DXX_ERROR_SYS = "System error, check errno/GetLastError()";
|
||||||
@@ -186,6 +176,7 @@ static constexpr const char* DXX_ERROR_OVERFLOW = "Overflow in DXX";
|
|||||||
static constexpr const char* DXX_ERROR_IO = "I/O failure in DXX";
|
static constexpr const char* DXX_ERROR_IO = "I/O failure in DXX";
|
||||||
static constexpr const char* DXX_ERROR_ARG = "Invalid arg passed to DXX";
|
static constexpr const char* DXX_ERROR_ARG = "Invalid arg passed to DXX";
|
||||||
|
|
||||||
|
static constexpr const char* NO_ERROR_FOUND = "No errors were found.";
|
||||||
static constexpr const char* TOO_MANY_EVENTS = "Too many events have occurred. The list has been truncated.";
|
static constexpr const char* TOO_MANY_EVENTS = "Too many events have occurred. The list has been truncated.";
|
||||||
static constexpr const char* UNKNOWN = "An unknown internal error occurred.";
|
static constexpr const char* UNKNOWN = "An unknown internal error occurred.";
|
||||||
static constexpr const char* INVALID = "An invalid internal error occurred.";
|
static constexpr const char* INVALID = "An invalid internal error occurred.";
|
||||||
@@ -313,6 +304,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return WIVI_STACK_REFRESH_FAILED;
|
return WIVI_STACK_REFRESH_FAILED;
|
||||||
case Type::WiVIUploadStackOverflow:
|
case Type::WiVIUploadStackOverflow:
|
||||||
return WIVI_UPLOAD_STACK_OVERFLOW;
|
return WIVI_UPLOAD_STACK_OVERFLOW;
|
||||||
|
case Type::I2CMessageExceedsMaxLength:
|
||||||
|
return I2C_MESSAGE_EXCEED_MAX_LENGTH;
|
||||||
case Type::A2BMessageIncompleteFrame:
|
case Type::A2BMessageIncompleteFrame:
|
||||||
return A2B_MESSAGE_INCOMPLETE_FRAME;
|
return A2B_MESSAGE_INCOMPLETE_FRAME;
|
||||||
case Type::CoreminiUploadVersionMismatch:
|
case Type::CoreminiUploadVersionMismatch:
|
||||||
@@ -321,10 +314,32 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return DISK_NOT_CONNECTED;
|
return DISK_NOT_CONNECTED;
|
||||||
case Type::UnexpectedResponse:
|
case Type::UnexpectedResponse:
|
||||||
return UNEXPECTED_RESPONSE;
|
return UNEXPECTED_RESPONSE;
|
||||||
|
case Type::LiveDataInvalidHandle:
|
||||||
|
return LIVE_DATA_INVALID_HANDLE;
|
||||||
|
case Type::LiveDataInvalidCommand:
|
||||||
|
return LIVE_DATA_INVALID_COMMAND;
|
||||||
|
case Type::LiveDataInvalidArgument:
|
||||||
|
return LIVE_DATA_INVALID_ARGUMENT;
|
||||||
|
case Type::LiveDataVersionMismatch:
|
||||||
|
return LIVE_DATA_VERSION_MISMATCH;
|
||||||
|
case Type::LiveDataNoDeviceResponse:
|
||||||
|
return LIVE_DATA_NO_DEVICE_RESPONSE;
|
||||||
|
case Type::LiveDataMaxSignalsReached:
|
||||||
|
return LIVE_DATA_MAX_SIGNALS_REACHED;
|
||||||
|
case Type::LiveDataCommandFailed:
|
||||||
|
return LIVE_DATA_COMMAND_FAILED;
|
||||||
|
case Type::LiveDataEncoderError:
|
||||||
|
return LIVE_DATA_ENCODER_ERROR;
|
||||||
|
case Type::LiveDataDecoderError:
|
||||||
|
return LIVE_DATA_DECODER_ERROR;
|
||||||
|
case Type::LiveDataNotSupported:
|
||||||
|
return LIVE_DATA_NOT_SUPPORTED;
|
||||||
case Type::LINSettingsNotAvailable:
|
case Type::LINSettingsNotAvailable:
|
||||||
return LIN_SETTINGS_NOT_AVAILABLE;
|
return LIN_SETTINGS_NOT_AVAILABLE;
|
||||||
case Type::ModeNotFound:
|
case Type::ModeNotFound:
|
||||||
return MODE_NOT_FOUND;
|
return MODE_NOT_FOUND;
|
||||||
|
case Type::AppErrorParsingFailed:
|
||||||
|
return APP_ERROR_PARSING_FAILED;
|
||||||
case Type::SettingNotAvaiableDevice:
|
case Type::SettingNotAvaiableDevice:
|
||||||
return SETTING_NOT_AVAILABLE;
|
return SETTING_NOT_AVAILABLE;
|
||||||
// Transport Errors
|
// Transport Errors
|
||||||
@@ -358,6 +373,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return GETIFADDRS_ERROR;
|
return GETIFADDRS_ERROR;
|
||||||
case Type::SendToError:
|
case Type::SendToError:
|
||||||
return SEND_TO_ERROR;
|
return SEND_TO_ERROR;
|
||||||
|
case Type::MDIOMessageExceedsMaxLength:
|
||||||
|
return MDIO_MESSAGE_EXCEED_MAX_LENGTH;
|
||||||
case Type::GPTPNotSupported:
|
case Type::GPTPNotSupported:
|
||||||
return GPTP_NOT_SUPPORTED;
|
return GPTP_NOT_SUPPORTED;
|
||||||
case Type::DiskFormatNotSupported:
|
case Type::DiskFormatNotSupported:
|
||||||
@@ -423,6 +440,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return SERVD_NODATA_ERROR;
|
return SERVD_NODATA_ERROR;
|
||||||
case Type::ServdJoinMulticastError:
|
case Type::ServdJoinMulticastError:
|
||||||
return SERVD_JOIN_MULTICAST_ERROR;
|
return SERVD_JOIN_MULTICAST_ERROR;
|
||||||
|
case Type::ServdNotReachable:
|
||||||
|
return SERVD_NOT_REACHABLE;
|
||||||
|
|
||||||
// DXX
|
// DXX
|
||||||
case Type::DXXErrorSys:
|
case Type::DXXErrorSys:
|
||||||
@@ -437,13 +456,44 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return DXX_ERROR_ARG;
|
return DXX_ERROR_ARG;
|
||||||
|
|
||||||
// Other Errors
|
// Other Errors
|
||||||
|
case Type::NoErrorFound:
|
||||||
|
return NO_ERROR_FOUND;
|
||||||
case Type::TooManyEvents:
|
case Type::TooManyEvents:
|
||||||
return TOO_MANY_EVENTS;
|
return TOO_MANY_EVENTS;
|
||||||
case Type::Unknown:
|
case Type::Unknown:
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
default:
|
case Type::Any:
|
||||||
return INVALID;
|
break;
|
||||||
}
|
}
|
||||||
|
return INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string APIEvent::describe() const noexcept {
|
||||||
|
std::stringstream ss;
|
||||||
|
auto shared = device.lock();
|
||||||
|
if(shared)
|
||||||
|
ss << *shared; // Makes use of device.describe()
|
||||||
|
else
|
||||||
|
ss << "API";
|
||||||
|
|
||||||
|
Severity severity = getSeverity();
|
||||||
|
if(severity == Severity::EventInfo) {
|
||||||
|
ss << " Info: ";
|
||||||
|
} else if(severity == Severity::EventWarning) {
|
||||||
|
ss << " Warning: ";
|
||||||
|
} else if(severity == Severity::Error) {
|
||||||
|
ss << " Error: ";
|
||||||
|
} else {
|
||||||
|
// Should never get here, since Severity::Any should only be used for filtering
|
||||||
|
ss << " Any: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* description = DescriptionForType(getType());
|
||||||
|
if(description == INVALID)
|
||||||
|
ss << description << " (0x" << std::hex << eventStruct.eventNumber << ")";
|
||||||
|
else
|
||||||
|
ss << description;
|
||||||
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventFilter::match(const APIEvent& event) const noexcept {
|
bool EventFilter::match(const APIEvent& event) const noexcept {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
EventManager& EventManager::GetInstance() {
|
EventManager& EventManager::GetInstance() {
|
||||||
static EventManager inst;
|
static EventManager* inst = new EventManager();
|
||||||
return inst;
|
return *inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::downgradeErrorsOnCurrentThread() {
|
void EventManager::downgradeErrorsOnCurrentThread() {
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#include "icsneo/api/heartbeat.h"
|
||||||
|
#include "icsneo/api/lifetime.h"
|
||||||
|
#include "icsneo/device/device.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
Heartbeat::Heartbeat(Device& device) :
|
||||||
|
device(device), mode(device.isOnline() ? Mode::Passive : Mode::Active), thread(&Heartbeat::run, this) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Heartbeat::~Heartbeat() {
|
||||||
|
{
|
||||||
|
std::lock_guard lk(mutex);
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
|
cv.notify_one();
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Heartbeat::run() {
|
||||||
|
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||||
|
|
||||||
|
auto filter = std::make_shared<MessageFilter>();
|
||||||
|
filter->includeInternalInAny = true;
|
||||||
|
bool status = false;
|
||||||
|
auto cbHandle = device.com->addMessageCallback(std::make_shared<MessageCallback>(filter, [&](std::shared_ptr<Message> msg) {
|
||||||
|
// TODO: remove DeviceStatus after 2027-08-17, as ResetStatus should be widely supported
|
||||||
|
const bool isHeartbeat =
|
||||||
|
(msg->type == Message::Type::ResetStatus) ||
|
||||||
|
(msg->type == Message::Type::RawMessage && std::static_pointer_cast<RawMessage>(msg)->network == Network::NetID::DeviceStatus);
|
||||||
|
if(!isHeartbeat)
|
||||||
|
return;
|
||||||
|
{
|
||||||
|
std::lock_guard lk(mutex);
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
cv.notify_one();
|
||||||
|
}));
|
||||||
|
Lifetime cbLifetime([&] {
|
||||||
|
device.com->removeMessageCallback(cbHandle);
|
||||||
|
});
|
||||||
|
while(true) {
|
||||||
|
std::unique_lock lk(mutex);
|
||||||
|
if(mode == Mode::Active) {
|
||||||
|
if(cv.wait_for(lk, std::chrono::milliseconds(100), [&] { return stop; })) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
device.com->sendCommand(Command::RequestStatusUpdate);
|
||||||
|
}
|
||||||
|
if(!cv.wait_for(lk, std::chrono::seconds(2), [&] { return status || stop; })) {
|
||||||
|
// we disconnect instead of close because it indicates to the user that a cleanup is still required (our thread join)
|
||||||
|
device.report(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
|
||||||
|
device.com->driver->setIsDisconnected(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(stop)
|
||||||
|
break;
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,13 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "icsneo/icsnVC40.h"
|
#include "icsneo/icsnVC40.h"
|
||||||
|
|
||||||
|
// Vehicle Spy 3.26.3.9 removed these legacy settings structure definitions from
|
||||||
|
// icsnVC40.h. The corresponding functions only ever treat them as opaque
|
||||||
|
// buffers, so forward declarations keep the existing API/ABI intact.
|
||||||
|
typedef struct _SFireSettings SFireSettings;
|
||||||
|
typedef struct _SVCAN3Settings SVCAN3Settings;
|
||||||
|
typedef struct _SVCANRFSettings SVCANRFSettings;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool LoadDLLAPI(HINSTANCE &hAPIDLL);
|
bool LoadDLLAPI(HINSTANCE &hAPIDLL);
|
||||||
|
|||||||
@@ -545,15 +545,13 @@ int LegacyDLLExport icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg,
|
|||||||
void LegacyDLLExport icsneoGetISO15765Status(void* hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus,
|
void LegacyDLLExport icsneoGetISO15765Status(void* hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus,
|
||||||
int* lTxStatus, int* lRxStatus)
|
int* lTxStatus, int* lRxStatus)
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// Not supported
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LegacyDLLExport icsneoSetISO15765RxParameters(void* hObject, int lNetwork, int lEnable, spyFilterLong* pFF_CFMsgFilter,
|
void LegacyDLLExport icsneoSetISO15765RxParameters(void* hObject, int lNetwork, int lEnable, spyFilterLong* pFF_CFMsgFilter,
|
||||||
icsSpyMessage* pTxMsg, int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent)
|
icsSpyMessage* pTxMsg, int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent)
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// Not supported
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LegacyDLLExport icsneoGetRTC(void* hObject, icsSpyTime* time)
|
int LegacyDLLExport icsneoGetRTC(void* hObject, icsSpyTime* time)
|
||||||
@@ -835,26 +833,25 @@ int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, char* szErrorDescriptio
|
|||||||
//ISO15765-2 Functions
|
//ISO15765-2 Functions
|
||||||
int LegacyDLLExport icsneoISO15765_EnableNetworks(void* hObject, unsigned long ulNetworks)
|
int LegacyDLLExport icsneoISO15765_EnableNetworks(void* hObject, unsigned long ulNetworks)
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// Not supported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LegacyDLLExport icsneoISO15765_DisableNetworks(void* hObject)
|
int LegacyDLLExport icsneoISO15765_DisableNetworks(void* hObject)
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// Not supported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LegacyDLLExport icsneoISO15765_TransmitMessage(void* hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage* pMsg,
|
int LegacyDLLExport icsneoISO15765_TransmitMessage(void* hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage* pMsg, unsigned long ulBlockingTimeout)
|
||||||
unsigned long ulBlockingTimeout)
|
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// Not supported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LegacyDLLExport icsneoISO15765_ReceiveMessage(void* hObject, int ulNetworkID, stCM_ISO157652_RxMessage* pMsg)
|
int LegacyDLLExport icsneoISO15765_ReceiveMessage(void* hObject, int ulNetworkID, stCM_ISO157652_RxMessage* pMsg)
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// Not supported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1035,10 +1032,10 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void* hObject, EPlasmaIonVnetCha
|
|||||||
case NEODEVICE_ION:
|
case NEODEVICE_ION:
|
||||||
*pDeviceSettingsType = DeviceFire2SettingsType; //defaults to FIRE2 vnets with libicsneo - no firevnets!
|
*pDeviceSettingsType = DeviceFire2SettingsType; //defaults to FIRE2 vnets with libicsneo - no firevnets!
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_VCAN3:
|
case NEODEVICE_VCAN3_DEPRECATED:
|
||||||
*pDeviceSettingsType = DeviceVCAN3SettingsType;
|
*pDeviceSettingsType = DeviceVCAN3SettingsTypeDeprecated;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_FIRE:
|
case NEODEVICE_FIRE_DEPRECATED:
|
||||||
*pDeviceSettingsType = DeviceFireSettingsType;
|
*pDeviceSettingsType = DeviceFireSettingsType;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_FIRE2:
|
case NEODEVICE_FIRE2:
|
||||||
@@ -1061,17 +1058,17 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void* hObject, EPlasmaIonVnetCha
|
|||||||
case NEODEVICE_VIVIDCAN:
|
case NEODEVICE_VIVIDCAN:
|
||||||
*pDeviceSettingsType = DeviceVividCANSettingsType;
|
*pDeviceSettingsType = DeviceVividCANSettingsType;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_ECU_AVB:
|
case NEODEVICE_ECU_AVB_DEPRECATED:
|
||||||
*pDeviceSettingsType = DeviceECU_AVBSettingsType;
|
*pDeviceSettingsType = DeviceECU_AVBSettingsTypeDeprecated;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_RADSUPERMOON:
|
case NEODEVICE_RADSUPERMOON_DEPRECATED:
|
||||||
*pDeviceSettingsType = DeviceRADSuperMoonSettingsType;
|
*pDeviceSettingsType = DeviceRADSuperMoonSettingsTypeDeprecated;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_RADMOON2:
|
case NEODEVICE_RADMOON2:
|
||||||
*pDeviceSettingsType = DeviceRADMoon2SettingsType;
|
*pDeviceSettingsType = DeviceRADMoon2SettingsType;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_RADGIGALOG:
|
case NEODEVICE_RADGIGALOG_DEPRECATED:
|
||||||
*pDeviceSettingsType = DeviceRADGigalogSettingsType;
|
*pDeviceSettingsType = DeviceRADGigalogSettingsTypeDeprecated;
|
||||||
break;
|
break;
|
||||||
case NEODEVICE_RADMOON3:
|
case NEODEVICE_RADMOON3:
|
||||||
*pDeviceSettingsType = DeviceRADMoon3SettingsType;
|
*pDeviceSettingsType = DeviceRADMoon3SettingsType;
|
||||||
@@ -1088,6 +1085,8 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void* hObject, EPlasmaIonVnetCha
|
|||||||
case NEODEVICE_FIRE3_FLEXRAY:
|
case NEODEVICE_FIRE3_FLEXRAY:
|
||||||
*pDeviceSettingsType = DeviceFire3FlexraySettingsType;
|
*pDeviceSettingsType = DeviceFire3FlexraySettingsType;
|
||||||
break;
|
break;
|
||||||
|
case NEODEVICE_RAD_BMS:
|
||||||
|
*pDeviceSettingsType = DeviceRADBMSSettingsType;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1283,10 +1282,11 @@ int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short L
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
|
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
|
||||||
|
const auto& cmd = static_cast<icsneo::J2534Command>(*CmdBuf);
|
||||||
|
|
||||||
switch (*CmdBuf)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case J2534NVCMD_SetNetworkBaudRate:
|
case icsneo::J2534Command::SetNetworkBaudRate:
|
||||||
|
|
||||||
pTmp = (uint64_t *)&CmdBuf[1];
|
pTmp = (uint64_t *)&CmdBuf[1];
|
||||||
NetworkID = (uint16_t)*pTmp;
|
NetworkID = (uint16_t)*pTmp;
|
||||||
@@ -1296,7 +1296,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short L
|
|||||||
iRetVal = 0;
|
iRetVal = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case J2534NVCMD_GetNetworkBaudRate:
|
case icsneo::J2534Command::GetNetworkBaudRate:
|
||||||
{
|
{
|
||||||
pTmp = (uint64_t *)&CmdBuf[1];
|
pTmp = (uint64_t *)&CmdBuf[1];
|
||||||
NetworkID = (uint16_t)*pTmp;
|
NetworkID = (uint16_t)*pTmp;
|
||||||
@@ -1309,7 +1309,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short L
|
|||||||
*pTmp = static_cast<uint64_t>(ret);
|
*pTmp = static_cast<uint64_t>(ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case J2534NVCMD_SetCANFDRate:
|
case icsneo::J2534Command::SetCANFDRate:
|
||||||
|
|
||||||
pTmp = (uint64_t *)&CmdBuf[1];
|
pTmp = (uint64_t *)&CmdBuf[1];
|
||||||
NetworkID = (uint16_t)*pTmp;
|
NetworkID = (uint16_t)*pTmp;
|
||||||
@@ -1320,7 +1320,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short L
|
|||||||
iRetVal = 0;
|
iRetVal = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case J2534NVCMD_GetCANFDRate:
|
case icsneo::J2534Command::GetCANFDRate:
|
||||||
|
|
||||||
pTmp = (uint64_t *)&CmdBuf[1];
|
pTmp = (uint64_t *)&CmdBuf[1];
|
||||||
NetworkID = (uint16_t)*pTmp;
|
NetworkID = (uint16_t)*pTmp;
|
||||||
@@ -1330,7 +1330,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short L
|
|||||||
*pTmp = icsneo_getFDBaudrate(device, NetworkID);
|
*pTmp = icsneo_getFDBaudrate(device, NetworkID);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case J2534NVCMD_GetCANFDTermination:
|
case icsneo::J2534Command::GetCANFDTermination:
|
||||||
|
|
||||||
pTmp = (uint64_t *)&CmdBuf[1];
|
pTmp = (uint64_t *)&CmdBuf[1];
|
||||||
NetworkID = (uint16_t)*pTmp;
|
NetworkID = (uint16_t)*pTmp;
|
||||||
@@ -1366,7 +1366,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short L
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case J2534NVCMD_SetCANFDTermination:
|
case icsneo::J2534Command::SetCANFDTermination:
|
||||||
|
|
||||||
pTmp = (uint64_t *)&CmdBuf[1];
|
pTmp = (uint64_t *)&CmdBuf[1];
|
||||||
NetworkID = (uint16_t)*pTmp;
|
NetworkID = (uint16_t)*pTmp;
|
||||||
@@ -1420,11 +1420,9 @@ int LegacyDLLExport icsneoEnableBusVoltageMonitor(void* hObject, unsigned int en
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LegacyDLLExport icsneoISO15765_TransmitMessageEx(void* hObject,
|
int LegacyDLLExport icsneoISO15765_TransmitMessageEx(void* hObject, unsigned long ulNetworkID, ISO15765_2015_TxMessage* pMsg, unsigned long ulBlockingTimeout)
|
||||||
unsigned long ulNetworkID,
|
|
||||||
ISO15765_2015_TxMessage* pMsg,
|
|
||||||
unsigned long ulBlockingTimeout)
|
|
||||||
{
|
{
|
||||||
|
// Not supported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ else()
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
pybind11
|
pybind11
|
||||||
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
||||||
GIT_TAG v2.13.6
|
GIT_TAG v3.0.3
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(pybind11)
|
FetchContent_MakeAvailable(pybind11)
|
||||||
endif()
|
endif()
|
||||||
@@ -22,6 +22,7 @@ pybind11_add_module(icsneopy
|
|||||||
icsneopy/device/devicetype.cpp
|
icsneopy/device/devicetype.cpp
|
||||||
icsneopy/communication/network.cpp
|
icsneopy/communication/network.cpp
|
||||||
icsneopy/communication/io.cpp
|
icsneopy/communication/io.cpp
|
||||||
|
icsneopy/communication/livedata.cpp
|
||||||
icsneopy/communication/message/message.cpp
|
icsneopy/communication/message/message.cpp
|
||||||
icsneopy/communication/message/canmessage.cpp
|
icsneopy/communication/message/canmessage.cpp
|
||||||
icsneopy/communication/message/canerrormessage.cpp
|
icsneopy/communication/message/canerrormessage.cpp
|
||||||
@@ -30,15 +31,19 @@ pybind11_add_module(icsneopy
|
|||||||
icsneopy/communication/message/tc10statusmessage.cpp
|
icsneopy/communication/message/tc10statusmessage.cpp
|
||||||
icsneopy/communication/message/mdiomessage.cpp
|
icsneopy/communication/message/mdiomessage.cpp
|
||||||
icsneopy/communication/message/gptpstatusmessage.cpp
|
icsneopy/communication/message/gptpstatusmessage.cpp
|
||||||
|
icsneopy/communication/message/allmacaddressesmessage.cpp
|
||||||
|
icsneopy/communication/message/apperrormessage.cpp
|
||||||
icsneopy/communication/message/ethernetstatusmessage.cpp
|
icsneopy/communication/message/ethernetstatusmessage.cpp
|
||||||
icsneopy/communication/message/spimessage.cpp
|
icsneopy/communication/message/spimessage.cpp
|
||||||
icsneopy/communication/message/scriptstatusmessage.cpp
|
icsneopy/communication/message/scriptstatusmessage.cpp
|
||||||
icsneopy/communication/message/ethphymessage.cpp
|
icsneopy/communication/message/ethphymessage.cpp
|
||||||
|
icsneopy/communication/message/livedatamessage.cpp
|
||||||
icsneopy/communication/message/callback/messagecallback.cpp
|
icsneopy/communication/message/callback/messagecallback.cpp
|
||||||
icsneopy/communication/message/filter/messagefilter.cpp
|
icsneopy/communication/message/filter/messagefilter.cpp
|
||||||
icsneopy/core/macseccfg.cpp
|
icsneopy/core/macseccfg.cpp
|
||||||
icsneopy/flexray/flexray.cpp
|
icsneopy/flexray/flexray.cpp
|
||||||
icsneopy/disk/diskdriver.cpp
|
icsneopy/disk/diskdriver.cpp
|
||||||
|
icsneopy/disk/diskdetails.cpp
|
||||||
icsneopy/device/chipid.cpp
|
icsneopy/device/chipid.cpp
|
||||||
icsneopy/device/versionreport.cpp
|
icsneopy/device/versionreport.cpp
|
||||||
icsneopy/device/device.cpp
|
icsneopy/device/device.cpp
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
#include "icsneo/api/event.h"
|
#include "icsneo/api/event.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_event(pybind11::module_& m) {
|
void init_event(pybind11::module_& m) {
|
||||||
pybind11::class_<APIEvent, std::shared_ptr<APIEvent>> apiEvent(m, "APIEvent");
|
pybind11::classh<APIEvent> apiEvent(m, "APIEvent");
|
||||||
pybind11::enum_<APIEvent::Type>(apiEvent, "Type")
|
pybind11::native_enum<APIEvent::Type>(apiEvent, "Type", "enum.IntEnum")
|
||||||
.value("Any", APIEvent::Type::Any)
|
.value("Any", APIEvent::Type::Any)
|
||||||
.value("InvalidNeoDevice", APIEvent::Type::InvalidNeoDevice)
|
.value("InvalidNeoDevice", APIEvent::Type::InvalidNeoDevice)
|
||||||
.value("RequiredParameterNull", APIEvent::Type::RequiredParameterNull)
|
.value("RequiredParameterNull", APIEvent::Type::RequiredParameterNull)
|
||||||
@@ -125,6 +126,7 @@ void init_event(pybind11::module_& m) {
|
|||||||
.value("ServdPollError", APIEvent::Type::ServdPollError)
|
.value("ServdPollError", APIEvent::Type::ServdPollError)
|
||||||
.value("ServdNoDataError", APIEvent::Type::ServdNoDataError)
|
.value("ServdNoDataError", APIEvent::Type::ServdNoDataError)
|
||||||
.value("ServdJoinMulticastError", APIEvent::Type::ServdJoinMulticastError)
|
.value("ServdJoinMulticastError", APIEvent::Type::ServdJoinMulticastError)
|
||||||
|
.value("ServdNotReachable", APIEvent::Type::ServdNotReachable)
|
||||||
.value("DXXErrorSys", APIEvent::Type::DXXErrorSys)
|
.value("DXXErrorSys", APIEvent::Type::DXXErrorSys)
|
||||||
.value("DXXErrorInt", APIEvent::Type::DXXErrorInt)
|
.value("DXXErrorInt", APIEvent::Type::DXXErrorInt)
|
||||||
.value("DXXErrorOverflow", APIEvent::Type::DXXErrorOverflow)
|
.value("DXXErrorOverflow", APIEvent::Type::DXXErrorOverflow)
|
||||||
@@ -132,13 +134,15 @@ void init_event(pybind11::module_& m) {
|
|||||||
.value("DXXErrorArg", APIEvent::Type::DXXErrorArg)
|
.value("DXXErrorArg", APIEvent::Type::DXXErrorArg)
|
||||||
.value("NoErrorFound", APIEvent::Type::NoErrorFound)
|
.value("NoErrorFound", APIEvent::Type::NoErrorFound)
|
||||||
.value("TooManyEvents", APIEvent::Type::TooManyEvents)
|
.value("TooManyEvents", APIEvent::Type::TooManyEvents)
|
||||||
.value("Unknown", APIEvent::Type::Unknown);
|
.value("Unknown", APIEvent::Type::Unknown)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
pybind11::enum_<APIEvent::Severity>(apiEvent, "Severity")
|
pybind11::native_enum<APIEvent::Severity>(apiEvent, "Severity", "enum.IntEnum")
|
||||||
.value("Any", APIEvent::Severity::Any)
|
.value("Any", APIEvent::Severity::Any)
|
||||||
.value("EventInfo", APIEvent::Severity::EventInfo)
|
.value("EventInfo", APIEvent::Severity::EventInfo)
|
||||||
.value("EventWarning", APIEvent::Severity::EventWarning)
|
.value("EventWarning", APIEvent::Severity::EventWarning)
|
||||||
.value("Error", APIEvent::Severity::Error);
|
.value("Error", APIEvent::Severity::Error)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
apiEvent
|
apiEvent
|
||||||
.def("get_type", &APIEvent::getType)
|
.def("get_type", &APIEvent::getType)
|
||||||
@@ -147,7 +151,7 @@ void init_event(pybind11::module_& m) {
|
|||||||
.def("describe", &APIEvent::describe)
|
.def("describe", &APIEvent::describe)
|
||||||
.def("__repr__", &APIEvent::describe);
|
.def("__repr__", &APIEvent::describe);
|
||||||
|
|
||||||
pybind11::class_<EventFilter, std::shared_ptr<EventFilter>>(m, "EventFilter")
|
pybind11::classh<EventFilter>(m, "EventFilter")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def(pybind11::init<APIEvent::Type>())
|
.def(pybind11::init<APIEvent::Type>())
|
||||||
.def(pybind11::init<APIEvent::Severity>())
|
.def(pybind11::init<APIEvent::Severity>())
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_eventcallback(pybind11::module_& m) {
|
void init_eventcallback(pybind11::module_& m) {
|
||||||
pybind11::class_<EventCallback>(m, "EventCallback")
|
pybind11::classh<EventCallback>(m, "EventCallback")
|
||||||
.def(pybind11::init<EventCallback::fn_eventCallback, EventFilter>())
|
.def(pybind11::init<EventCallback::fn_eventCallback, EventFilter>())
|
||||||
.def(pybind11::init<EventCallback::fn_eventCallback>());
|
.def(pybind11::init<EventCallback::fn_eventCallback>());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_eventmanager(pybind11::module_& m) {
|
void init_eventmanager(pybind11::module_& m) {
|
||||||
pybind11::class_<EventManager>(m, "EventManager")
|
pybind11::classh<EventManager>(m, "EventManager")
|
||||||
.def_static("get_instance", &EventManager::GetInstance, pybind11::return_value_policy::reference)
|
.def_static("get_instance", &EventManager::GetInstance, pybind11::return_value_policy::reference)
|
||||||
.def("add_event_callback", &EventManager::addEventCallback)
|
.def("add_event_callback", &EventManager::addEventCallback)
|
||||||
.def("remove_event_callback", &EventManager::removeEventCallback)
|
.def("remove_event_callback", &EventManager::removeEventCallback)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_version(pybind11::module_& m) {
|
void init_version(pybind11::module_& m) {
|
||||||
pybind11::class_<neoversion_t>(m, "NeoVersion")
|
pybind11::classh<neoversion_t>(m, "NeoVersion")
|
||||||
.def_readonly("major", &neoversion_t::major)
|
.def_readonly("major", &neoversion_t::major)
|
||||||
.def_readonly("minor", &neoversion_t::minor)
|
.def_readonly("minor", &neoversion_t::minor)
|
||||||
.def_readonly("patch", &neoversion_t::patch)
|
.def_readonly("patch", &neoversion_t::patch)
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/livedata.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_livedata(pybind11::module_& m) {
|
||||||
|
// LiveDataValue struct
|
||||||
|
pybind11::classh<LiveDataValue>(m, "LiveDataValue")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("value", &LiveDataValue::value);
|
||||||
|
|
||||||
|
// LiveDataArgument struct
|
||||||
|
pybind11::classh<LiveDataArgument>(m, "LiveDataArgument")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("object_type", &LiveDataArgument::objectType)
|
||||||
|
.def_readwrite("object_index", &LiveDataArgument::objectIndex)
|
||||||
|
.def_readwrite("signal_index", &LiveDataArgument::signalIndex)
|
||||||
|
.def_readwrite("value_type", &LiveDataArgument::valueType);
|
||||||
|
|
||||||
|
// LiveDataCommand enum
|
||||||
|
pybind11::native_enum<LiveDataCommand>(m, "LiveDataCommand", "enum.IntEnum")
|
||||||
|
.value("STATUS", LiveDataCommand::STATUS)
|
||||||
|
.value("SUBSCRIBE", LiveDataCommand::SUBSCRIBE)
|
||||||
|
.value("UNSUBSCRIBE", LiveDataCommand::UNSUBSCRIBE)
|
||||||
|
.value("RESPONSE", LiveDataCommand::RESPONSE)
|
||||||
|
.value("CLEAR_ALL", LiveDataCommand::CLEAR_ALL)
|
||||||
|
.value("SET_VALUE", LiveDataCommand::SET_VALUE)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
|
// LiveDataStatus enum
|
||||||
|
pybind11::native_enum<LiveDataStatus>(m, "LiveDataStatus", "enum.IntEnum")
|
||||||
|
.value("SUCCESS", LiveDataStatus::SUCCESS)
|
||||||
|
.value("ERR_UNKNOWN_COMMAND", LiveDataStatus::ERR_UNKNOWN_COMMAND)
|
||||||
|
.value("ERR_HANDLE", LiveDataStatus::ERR_HANDLE)
|
||||||
|
.value("ERR_DUPLICATE", LiveDataStatus::ERR_DUPLICATE)
|
||||||
|
.value("ERR_FULL", LiveDataStatus::ERR_FULL)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
|
// LiveDataObjectType enum
|
||||||
|
pybind11::enum_<LiveDataObjectType>(m, "LiveDataObjectType")
|
||||||
|
.value("MISC", LiveDataObjectType::MISC)
|
||||||
|
.value("SNA", LiveDataObjectType::SNA)
|
||||||
|
.export_values();
|
||||||
|
|
||||||
|
// LiveDataValueType enum
|
||||||
|
pybind11::native_enum<LiveDataValueType>(m, "LiveDataValueType", "enum.IntEnum")
|
||||||
|
.value("GPS_LATITUDE", LiveDataValueType::GPS_LATITUDE)
|
||||||
|
.value("GPS_LONGITUDE", LiveDataValueType::GPS_LONGITUDE)
|
||||||
|
.value("GPS_ALTITUDE", LiveDataValueType::GPS_ALTITUDE)
|
||||||
|
.value("GPS_SPEED", LiveDataValueType::GPS_SPEED)
|
||||||
|
.value("GPS_VALID", LiveDataValueType::GPS_VALID)
|
||||||
|
.value("GPS_ENABLE", LiveDataValueType::GPS_ENABLE)
|
||||||
|
.value("MANUAL_TRIGGER", LiveDataValueType::MANUAL_TRIGGER)
|
||||||
|
.value("TIME_SINCE_MSG", LiveDataValueType::TIME_SINCE_MSG)
|
||||||
|
.value("GPS_ACCURACY", LiveDataValueType::GPS_ACCURACY)
|
||||||
|
.value("GPS_BEARING", LiveDataValueType::GPS_BEARING)
|
||||||
|
.value("GPS_TIME", LiveDataValueType::GPS_TIME)
|
||||||
|
.value("GPS_TIME_VALID", LiveDataValueType::GPS_TIME_VALID)
|
||||||
|
.value("DAQ_ENABLE", LiveDataValueType::DAQ_ENABLE)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
|
// LiveDataUtil namespace functions
|
||||||
|
m.def("get_new_handle", &LiveDataUtil::getNewHandle,
|
||||||
|
"Generate a new unique LiveData handle");
|
||||||
|
|
||||||
|
m.def("livedata_value_to_double", &LiveDataUtil::liveDataValueToDouble,
|
||||||
|
pybind11::arg("val"),
|
||||||
|
"Convert LiveDataValue to double (32.32 fixed-point to floating-point)");
|
||||||
|
|
||||||
|
m.def("livedata_double_to_value", &LiveDataUtil::liveDataDoubleToValue,
|
||||||
|
pybind11::arg("d"),
|
||||||
|
"Convert double to LiveDataValue (32.32 fixed-point format). Returns LiveDataValue or None on failure.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/allmacaddressesmessage.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_allmacaddressesmessage(pybind11::module_& m) {
|
||||||
|
pybind11::classh<AllMACAddressesMessage, Message>(m, "AllMACAddressesMessage")
|
||||||
|
.def_readonly("addresses", &AllMACAddressesMessage::addresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/apperrormessage.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_errortypes(pybind11::module_& m) {
|
||||||
|
pybind11::native_enum<AppErrorType>(m, "AppErrorType", "enum.IntEnum")
|
||||||
|
.value("RxMessagesFull", AppErrorType::AppErrorRxMessagesFull)
|
||||||
|
.value("TxMessagesFull", AppErrorType::AppErrorTxMessagesFull)
|
||||||
|
.value("TxReportMessagesFull", AppErrorType::AppErrorTxReportMessagesFull)
|
||||||
|
.value("BadCommWithDspIC", AppErrorType::AppErrorBadCommWithDspIC)
|
||||||
|
.value("DriverOverflow", AppErrorType::AppErrorDriverOverflow)
|
||||||
|
.value("PCBuffOverflow", AppErrorType::AppErrorPCBuffOverflow)
|
||||||
|
.value("PCChksumError", AppErrorType::AppErrorPCChksumError)
|
||||||
|
.value("PCMissedByte", AppErrorType::AppErrorPCMissedByte)
|
||||||
|
.value("PCOverrunError", AppErrorType::AppErrorPCOverrunError)
|
||||||
|
.value("SettingFailure", AppErrorType::AppErrorSettingFailure)
|
||||||
|
.value("TooManySelectedNetworks", AppErrorType::AppErrorTooManySelectedNetworks)
|
||||||
|
.value("NetworkNotEnabled", AppErrorType::AppErrorNetworkNotEnabled)
|
||||||
|
.value("RtcNotCorrect", AppErrorType::AppErrorRtcNotCorrect)
|
||||||
|
.value("LoadedDefaultSettings", AppErrorType::AppErrorLoadedDefaultSettings)
|
||||||
|
.value("FeatureNotUnlocked", AppErrorType::AppErrorFeatureNotUnlocked)
|
||||||
|
.value("FeatureRtcCmdDropped", AppErrorType::AppErrorFeatureRtcCmdDropped)
|
||||||
|
.value("TxMessagesFlushed", AppErrorType::AppErrorTxMessagesFlushed)
|
||||||
|
.value("TxMessagesHalfFull", AppErrorType::AppErrorTxMessagesHalfFull)
|
||||||
|
.value("NetworkNotValid", AppErrorType::AppErrorNetworkNotValid)
|
||||||
|
.value("TxInterfaceNotImplemented", AppErrorType::AppErrorTxInterfaceNotImplemented)
|
||||||
|
.value("TxMessagesCommEnableIsOff", AppErrorType::AppErrorTxMessagesCommEnableIsOff)
|
||||||
|
.value("RxFilterMatchCountExceeded", AppErrorType::AppErrorRxFilterMatchCountExceeded)
|
||||||
|
.value("EthPreemptionNotEnabled", AppErrorType::AppErrorEthPreemptionNotEnabled)
|
||||||
|
.value("TxNotSupportedInMode", AppErrorType::AppErrorTxNotSupportedInMode)
|
||||||
|
.value("JumboFramesNotSupported", AppErrorType::AppErrorJumboFramesNotSupported)
|
||||||
|
.value("EthernetIpFragment", AppErrorType::AppErrorEthernetIpFragment)
|
||||||
|
.value("TxMessagesUnderrun", AppErrorType::AppErrorTxMessagesUnderrun)
|
||||||
|
.value("DeviceFanFailure", AppErrorType::AppErrorDeviceFanFailure)
|
||||||
|
.value("DeviceOvertemperature", AppErrorType::AppErrorDeviceOvertemperature)
|
||||||
|
.value("TxMessageIndexOutOfRange", AppErrorType::AppErrorTxMessageIndexOutOfRange)
|
||||||
|
.value("UndersizedFrameDropped", AppErrorType::AppErrorUndersizedFrameDropped)
|
||||||
|
.value("OversizedFrameDropped", AppErrorType::AppErrorOversizedFrameDropped)
|
||||||
|
.value("WatchdogEvent", AppErrorType::AppErrorWatchdogEvent)
|
||||||
|
.value("SystemClockFailure", AppErrorType::AppErrorSystemClockFailure)
|
||||||
|
.value("SystemClockRecovered", AppErrorType::AppErrorSystemClockRecovered)
|
||||||
|
.value("SystemPeripheralReset", AppErrorType::AppErrorSystemPeripheralReset)
|
||||||
|
.value("SystemCommunicationFailure", AppErrorType::AppErrorSystemCommunicationFailure)
|
||||||
|
.value("TxMessagesUnsupportedSourceOrPacketId", AppErrorType::AppErrorTxMessagesUnsupportedSourceOrPacketId)
|
||||||
|
.value("WbmsManagerConnectFailed", AppErrorType::AppErrorWbmsManagerConnectFailed)
|
||||||
|
.value("WbmsManagerConnectBadState", AppErrorType::AppErrorWbmsManagerConnectBadState)
|
||||||
|
.value("WbmsManagerConnectTimeout", AppErrorType::AppErrorWbmsManagerConnectTimeout)
|
||||||
|
.value("FailedToInitializeLoggerDisk", AppErrorType::AppErrorFailedToInitializeLoggerDisk)
|
||||||
|
.value("InvalidSetting", AppErrorType::AppErrorInvalidSetting)
|
||||||
|
.value("SystemFailureRequestedReset", AppErrorType::AppErrorSystemFailureRequestedReset)
|
||||||
|
.value("PortKeyMistmatch", AppErrorType::AppErrorPortKeyMistmatch)
|
||||||
|
.value("BusFailure", AppErrorType::AppErrorBusFailure)
|
||||||
|
.value("TapOverflow", AppErrorType::AppErrorTapOverflow)
|
||||||
|
.value("EthTxNoLink", AppErrorType::AppErrorEthTxNoLink)
|
||||||
|
.value("ErrorBufferOverflow", AppErrorType::AppErrorErrorBufferOverflow)
|
||||||
|
.value("NoError", AppErrorType::AppNoError)
|
||||||
|
.finalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_apperrormessage(pybind11::module_& m) {
|
||||||
|
init_errortypes(m);
|
||||||
|
pybind11::classh<AppErrorMessage, Message>(m, "AppErrorMessage")
|
||||||
|
.def("get_app_error_type", &AppErrorMessage::getAppErrorType)
|
||||||
|
.def("get_app_error_string", &AppErrorMessage::getAppErrorString);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_messagecallback(pybind11::module_& m) {
|
void init_messagecallback(pybind11::module_& m) {
|
||||||
pybind11::class_<MessageCallback, std::shared_ptr<MessageCallback>>(m, "MessageCallback")
|
pybind11::classh<MessageCallback>(m, "MessageCallback")
|
||||||
.def(pybind11::init<MessageCallback::fn_messageCallback, std::shared_ptr<MessageFilter>>());
|
.def(pybind11::init<MessageCallback::fn_messageCallback, std::shared_ptr<MessageFilter>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
#include "icsneo/communication/message/canerrormessage.h"
|
#include "icsneo/communication/message/canerrormessage.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_errorcodes(pybind11::module_& m) {
|
void init_errorcodes(pybind11::module_& m) {
|
||||||
pybind11::enum_<CANErrorCode>(m, "CANErrorCode")
|
pybind11::native_enum<CANErrorCode>(m, "CANErrorCode", "enum.IntEnum")
|
||||||
.value("NoError", CANErrorCode::NoError)
|
.value("NoError", CANErrorCode::NoError)
|
||||||
.value("StuffError", CANErrorCode::StuffError)
|
.value("StuffError", CANErrorCode::StuffError)
|
||||||
.value("FormError", CANErrorCode::FormError)
|
.value("FormError", CANErrorCode::FormError)
|
||||||
@@ -15,12 +16,13 @@ void init_errorcodes(pybind11::module_& m) {
|
|||||||
.value("Bit1Error", CANErrorCode::Bit1Error)
|
.value("Bit1Error", CANErrorCode::Bit1Error)
|
||||||
.value("Bit0Error", CANErrorCode::Bit0Error)
|
.value("Bit0Error", CANErrorCode::Bit0Error)
|
||||||
.value("CRCError", CANErrorCode::CRCError)
|
.value("CRCError", CANErrorCode::CRCError)
|
||||||
.value("NoChange", CANErrorCode::NoChange);
|
.value("NoChange", CANErrorCode::NoChange)
|
||||||
|
.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_canerrormessage(pybind11::module_& m) {
|
void init_canerrormessage(pybind11::module_& m) {
|
||||||
init_errorcodes(m);
|
init_errorcodes(m);
|
||||||
pybind11::class_<CANErrorMessage, std::shared_ptr<CANErrorMessage>, Message>(m, "CANErrorMessage")
|
pybind11::classh<CANErrorMessage, Message>(m, "CANErrorMessage")
|
||||||
.def_readonly("network", &CANErrorMessage::network)
|
.def_readonly("network", &CANErrorMessage::network)
|
||||||
.def_readonly("transmitErrorCount", &CANErrorMessage::transmitErrorCount)
|
.def_readonly("transmitErrorCount", &CANErrorMessage::transmitErrorCount)
|
||||||
.def_readonly("receiveErrorCount", &CANErrorMessage::receiveErrorCount)
|
.def_readonly("receiveErrorCount", &CANErrorMessage::receiveErrorCount)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_canmessage(pybind11::module_& m) {
|
void init_canmessage(pybind11::module_& m) {
|
||||||
pybind11::class_<CANMessage, std::shared_ptr<CANMessage>, Frame>(m, "CANMessage")
|
pybind11::classh<CANMessage, Frame>(m, "CANMessage")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("arbid", &CANMessage::arbid)
|
.def_readwrite("arbid", &CANMessage::arbid)
|
||||||
.def_readwrite("dlcOnWire", &CANMessage::dlcOnWire)
|
.def_readwrite("dlcOnWire", &CANMessage::dlcOnWire)
|
||||||
@@ -15,7 +15,10 @@ void init_canmessage(pybind11::module_& m) {
|
|||||||
.def_readwrite("isExtended", &CANMessage::isExtended)
|
.def_readwrite("isExtended", &CANMessage::isExtended)
|
||||||
.def_readwrite("isCANFD", &CANMessage::isCANFD)
|
.def_readwrite("isCANFD", &CANMessage::isCANFD)
|
||||||
.def_readwrite("baudrateSwitch", &CANMessage::baudrateSwitch)
|
.def_readwrite("baudrateSwitch", &CANMessage::baudrateSwitch)
|
||||||
.def_readwrite("errorStateIndicator", &CANMessage::errorStateIndicator);
|
.def_readwrite("errorStateIndicator", &CANMessage::errorStateIndicator)
|
||||||
|
.def_readwrite("txAborted", &CANMessage::txAborted)
|
||||||
|
.def_readwrite("txLostArb", &CANMessage::txLostArb)
|
||||||
|
.def_readwrite("txError", &CANMessage::txError);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|||||||
@@ -7,21 +7,29 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_ethernetmessage(pybind11::module_& m) {
|
void init_ethernetmessage(pybind11::module_& m) {
|
||||||
pybind11::class_<MACAddress>(m, "MACAddress")
|
pybind11::classh<EthernetMessage::T1S>(m, "EthernetMessageT1S")
|
||||||
.def("to_string", &MACAddress::toString)
|
.def(pybind11::init())
|
||||||
.def("__repr__", &MACAddress::toString);
|
.def_readwrite("isSymbol", &EthernetMessage::T1S::isSymbol)
|
||||||
|
.def_readwrite("isBurst", &EthernetMessage::T1S::isBurst)
|
||||||
pybind11::class_<EthernetMessage, std::shared_ptr<EthernetMessage>, Frame>(m, "EthernetMessage")
|
.def_readwrite("txCollision", &EthernetMessage::T1S::txCollision)
|
||||||
|
.def_readwrite("isWake", &EthernetMessage::T1S::isWake)
|
||||||
|
.def_readwrite("nodeId", &EthernetMessage::T1S::nodeId)
|
||||||
|
.def_readwrite("burstCount", &EthernetMessage::T1S::burstCount)
|
||||||
|
.def_readwrite("symbolType", &EthernetMessage::T1S::symbolType);
|
||||||
|
|
||||||
|
pybind11::classh<EthernetMessage, Frame>(m, "EthernetMessage")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled)
|
|
||||||
.def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags)
|
|
||||||
.def_readwrite("fcs", &EthernetMessage::fcs)
|
.def_readwrite("fcs", &EthernetMessage::fcs)
|
||||||
.def_readwrite("frameTooShort", &EthernetMessage::frameTooShort)
|
.def_readwrite("frameTooShort", &EthernetMessage::frameTooShort)
|
||||||
.def_readwrite("noPadding", &EthernetMessage::noPadding)
|
.def_readwrite("noPadding", &EthernetMessage::noPadding)
|
||||||
.def("get_destination_mac", &EthernetMessage::getDestinationMAC, pybind11::return_value_policy::reference)
|
.def_readwrite("fcsVerified", &EthernetMessage::fcsVerified)
|
||||||
.def("get_source_mac", &EthernetMessage::getSourceMAC, pybind11::return_value_policy::reference)
|
.def_readwrite("txAborted", &EthernetMessage::txAborted)
|
||||||
|
.def_readwrite("crcError", &EthernetMessage::crcError)
|
||||||
|
.def_readwrite("t1s", &EthernetMessage::t1s)
|
||||||
|
.def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags)
|
||||||
|
.def("get_destination_mac", &EthernetMessage::getDestinationMAC)
|
||||||
|
.def("get_source_mac", &EthernetMessage::getSourceMAC)
|
||||||
.def("get_ether_type", &EthernetMessage::getEtherType);
|
.def("get_ether_type", &EthernetMessage::getEtherType);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_ethernetstatusmessage(pybind11::module_& m) {
|
void init_ethernetstatusmessage(pybind11::module_& m) {
|
||||||
pybind11::class_<EthernetStatusMessage, std::shared_ptr<EthernetStatusMessage>, Message> ethernetStatusMessage(m, "EthernetStatusMessage");
|
pybind11::classh<EthernetStatusMessage, RawMessage> ethernetStatusMessage(m, "EthernetStatusMessage");
|
||||||
|
|
||||||
pybind11::enum_<EthernetStatusMessage::LinkSpeed>(ethernetStatusMessage, "LinkSpeed")
|
pybind11::enum_<EthernetStatusMessage::LinkSpeed>(ethernetStatusMessage, "LinkSpeed")
|
||||||
.value("LinkSpeedAuto", EthernetStatusMessage::LinkSpeed::LinkSpeedAuto)
|
.value("LinkSpeedAuto", EthernetStatusMessage::LinkSpeed::LinkSpeedAuto)
|
||||||
|
|||||||
@@ -7,7 +7,17 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_ethphymessage(pybind11::module_& m) {
|
void init_ethphymessage(pybind11::module_& m) {
|
||||||
pybind11::class_<PhyMessage, std::shared_ptr<PhyMessage>>(m, "PhyMessage")
|
pybind11::classh<Clause22Message>(m, "Clause22Message")
|
||||||
|
.def_readwrite("phyAddr", &Clause22Message::phyAddr)
|
||||||
|
.def_readwrite("page", &Clause22Message::page)
|
||||||
|
.def_readwrite("regAddr", &Clause22Message::regAddr)
|
||||||
|
.def_readwrite("regVal", &Clause22Message::regVal);
|
||||||
|
pybind11::classh<Clause45Message>(m, "Clause45Message")
|
||||||
|
.def_readwrite("port", &Clause45Message::port)
|
||||||
|
.def_readwrite("device", &Clause45Message::device)
|
||||||
|
.def_readwrite("regAddr", &Clause45Message::regAddr)
|
||||||
|
.def_readwrite("regVal", &Clause45Message::regVal);
|
||||||
|
pybind11::classh<PhyMessage>(m, "PhyMessage")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("Enabled", &PhyMessage::Enabled)
|
.def_readwrite("Enabled", &PhyMessage::Enabled)
|
||||||
.def_readwrite("WriteEnable", &PhyMessage::WriteEnable)
|
.def_readwrite("WriteEnable", &PhyMessage::WriteEnable)
|
||||||
@@ -16,19 +26,7 @@ void init_ethphymessage(pybind11::module_& m) {
|
|||||||
.def_readwrite("BusIndex", &PhyMessage::BusIndex)
|
.def_readwrite("BusIndex", &PhyMessage::BusIndex)
|
||||||
.def_readwrite("Clause22", &PhyMessage::Clause22)
|
.def_readwrite("Clause22", &PhyMessage::Clause22)
|
||||||
.def_readwrite("Clause45", &PhyMessage::Clause45);
|
.def_readwrite("Clause45", &PhyMessage::Clause45);
|
||||||
pybind11::class_<Clause22Message>(m, "Clause22Message")
|
pybind11::classh<EthPhyMessage, Message>(m, "EthPhyMessage")
|
||||||
.def(pybind11::init())
|
|
||||||
.def_readwrite("phyAddr", &Clause22Message::phyAddr)
|
|
||||||
.def_readwrite("page", &Clause22Message::page)
|
|
||||||
.def_readwrite("regAddr", &Clause22Message::regAddr)
|
|
||||||
.def_readwrite("regVal", &Clause22Message::regVal);
|
|
||||||
pybind11::class_<Clause45Message>(m, "Clause45Message")
|
|
||||||
.def(pybind11::init())
|
|
||||||
.def_readwrite("port", &Clause45Message::port)
|
|
||||||
.def_readwrite("device", &Clause45Message::device)
|
|
||||||
.def_readwrite("regAddr", &Clause45Message::regAddr)
|
|
||||||
.def_readwrite("regVal", &Clause45Message::regVal);
|
|
||||||
pybind11::class_<EthPhyMessage, std::shared_ptr<EthPhyMessage>, Message>(m, "EthPhyMessage")
|
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("messages", &EthPhyMessage::messages);
|
.def_readwrite("messages", &EthPhyMessage::messages);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_messagefilter(pybind11::module_& m) {
|
void init_messagefilter(pybind11::module_& m) {
|
||||||
pybind11::class_<MessageFilter, std::shared_ptr<MessageFilter>>(m, "MessageFilter")
|
pybind11::classh<MessageFilter>(m, "MessageFilter")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def(pybind11::init<Message::Type>())
|
.def(pybind11::init<Message::Type>())
|
||||||
.def(pybind11::init<Network::NetID>());
|
.def(pybind11::init<Network::NetID>());
|
||||||
|
|||||||
@@ -7,40 +7,40 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_gptpstatusmessage(pybind11::module_& m) {
|
void init_gptpstatusmessage(pybind11::module_& m) {
|
||||||
pybind11::class_<GPTPStatus, std::shared_ptr<GPTPStatus>, Message> gptpStatus(m, "GPTPStatus");
|
pybind11::classh<GPTPStatus, Message> gptpStatus(m, "GPTPStatus");
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::Timestamp>(gptpStatus, "Timestamp")
|
pybind11::classh<GPTPStatus::Timestamp>(gptpStatus, "Timestamp")
|
||||||
.def_readonly("seconds", &GPTPStatus::Timestamp::seconds)
|
.def_readonly("seconds", &GPTPStatus::Timestamp::seconds)
|
||||||
.def_readonly("nanoseconds", &GPTPStatus::Timestamp::nanoseconds)
|
.def_readonly("nanoseconds", &GPTPStatus::Timestamp::nanoseconds)
|
||||||
.def("to_seconds", &GPTPStatus::Timestamp::toSeconds, pybind11::call_guard<pybind11::gil_scoped_release>());
|
.def("to_seconds", &GPTPStatus::Timestamp::toSeconds, pybind11::call_guard<pybind11::gil_scoped_release>());
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::ScaledNanoSeconds>(gptpStatus, "ScaledNanoSeconds")
|
pybind11::classh<GPTPStatus::ScaledNanoSeconds>(gptpStatus, "ScaledNanoSeconds")
|
||||||
.def_readonly("nanoseconds_msb", &GPTPStatus::ScaledNanoSeconds::nanosecondsMSB)
|
.def_readonly("nanoseconds_msb", &GPTPStatus::ScaledNanoSeconds::nanosecondsMSB)
|
||||||
.def_readonly("nanoseconds_lsb", &GPTPStatus::ScaledNanoSeconds::nanosecondsLSB)
|
.def_readonly("nanoseconds_lsb", &GPTPStatus::ScaledNanoSeconds::nanosecondsLSB)
|
||||||
.def_readonly("fractional_nanoseconds", &GPTPStatus::ScaledNanoSeconds::fractionalNanoseconds);
|
.def_readonly("fractional_nanoseconds", &GPTPStatus::ScaledNanoSeconds::fractionalNanoseconds);
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::PortID>(gptpStatus, "PortID")
|
pybind11::classh<GPTPStatus::PortID>(gptpStatus, "PortID")
|
||||||
.def_readonly("clock_identity", &GPTPStatus::PortID::clockIdentity)
|
.def_readonly("clock_identity", &GPTPStatus::PortID::clockIdentity)
|
||||||
.def_readonly("port_number", &GPTPStatus::PortID::portNumber);
|
.def_readonly("port_number", &GPTPStatus::PortID::portNumber);
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::ClockQuality>(gptpStatus, "ClockQuality")
|
pybind11::classh<GPTPStatus::ClockQuality>(gptpStatus, "ClockQuality")
|
||||||
.def_readonly("clock_class", &GPTPStatus::ClockQuality::clockClass)
|
.def_readonly("clock_class", &GPTPStatus::ClockQuality::clockClass)
|
||||||
.def_readonly("clock_accuracy", &GPTPStatus::ClockQuality::clockAccuracy)
|
.def_readonly("clock_accuracy", &GPTPStatus::ClockQuality::clockAccuracy)
|
||||||
.def_readonly("offset_scaled_log_variance", &GPTPStatus::ClockQuality::offsetScaledLogVariance);
|
.def_readonly("offset_scaled_log_variance", &GPTPStatus::ClockQuality::offsetScaledLogVariance);
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::SystemID>(gptpStatus, "SystemID")
|
pybind11::classh<GPTPStatus::SystemID>(gptpStatus, "SystemID")
|
||||||
.def_readonly("priority1", &GPTPStatus::SystemID::priority1)
|
.def_readonly("priority1", &GPTPStatus::SystemID::priority1)
|
||||||
.def_readonly("clock_quality", &GPTPStatus::SystemID::clockQuality)
|
.def_readonly("clock_quality", &GPTPStatus::SystemID::clockQuality)
|
||||||
.def_readonly("priority2", &GPTPStatus::SystemID::priority2)
|
.def_readonly("priority2", &GPTPStatus::SystemID::priority2)
|
||||||
.def_readonly("clock_id", &GPTPStatus::SystemID::clockID);
|
.def_readonly("clock_id", &GPTPStatus::SystemID::clockID);
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::PriorityVector>(gptpStatus, "PriorityVector")
|
pybind11::classh<GPTPStatus::PriorityVector>(gptpStatus, "PriorityVector")
|
||||||
.def_readonly("sys_id", &GPTPStatus::PriorityVector::sysID)
|
.def_readonly("sys_id", &GPTPStatus::PriorityVector::sysID)
|
||||||
.def_readonly("steps_removed", &GPTPStatus::PriorityVector::stepsRemoved)
|
.def_readonly("steps_removed", &GPTPStatus::PriorityVector::stepsRemoved)
|
||||||
.def_readonly("port_id", &GPTPStatus::PriorityVector::portID)
|
.def_readonly("port_id", &GPTPStatus::PriorityVector::portID)
|
||||||
.def_readonly("port_number", &GPTPStatus::PriorityVector::portNumber);
|
.def_readonly("port_number", &GPTPStatus::PriorityVector::portNumber);
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::ParentDS>(gptpStatus, "ParentDS")
|
pybind11::classh<GPTPStatus::ParentDS>(gptpStatus, "ParentDS")
|
||||||
.def_readonly("parent_port_identity", &GPTPStatus::ParentDS::parentPortIdentity)
|
.def_readonly("parent_port_identity", &GPTPStatus::ParentDS::parentPortIdentity)
|
||||||
.def_readonly("cumulative_rate_ratio", &GPTPStatus::ParentDS::cumulativeRateRatio)
|
.def_readonly("cumulative_rate_ratio", &GPTPStatus::ParentDS::cumulativeRateRatio)
|
||||||
.def_readonly("grandmaster_identity", &GPTPStatus::ParentDS::grandmasterIdentity)
|
.def_readonly("grandmaster_identity", &GPTPStatus::ParentDS::grandmasterIdentity)
|
||||||
@@ -50,7 +50,7 @@ void init_gptpstatusmessage(pybind11::module_& m) {
|
|||||||
.def_readonly("gm_priority1", &GPTPStatus::ParentDS::gmPriority1)
|
.def_readonly("gm_priority1", &GPTPStatus::ParentDS::gmPriority1)
|
||||||
.def_readonly("gm_priority2", &GPTPStatus::ParentDS::gmPriority2);
|
.def_readonly("gm_priority2", &GPTPStatus::ParentDS::gmPriority2);
|
||||||
|
|
||||||
pybind11::class_<GPTPStatus::CurrentDS>(gptpStatus, "CurrentDS")
|
pybind11::classh<GPTPStatus::CurrentDS>(gptpStatus, "CurrentDS")
|
||||||
.def_readonly("steps_removed", &GPTPStatus::CurrentDS::stepsRemoved)
|
.def_readonly("steps_removed", &GPTPStatus::CurrentDS::stepsRemoved)
|
||||||
.def_readonly("offset_from_master", &GPTPStatus::CurrentDS::offsetFromMaster)
|
.def_readonly("offset_from_master", &GPTPStatus::CurrentDS::offsetFromMaster)
|
||||||
.def_readonly("lastgm_phase_change", &GPTPStatus::CurrentDS::lastgmPhaseChange)
|
.def_readonly("lastgm_phase_change", &GPTPStatus::CurrentDS::lastgmPhaseChange)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_linmessage(pybind11::module_& m) {
|
void init_linmessage(pybind11::module_& m) {
|
||||||
pybind11::class_<LINErrorFlags>(m, "LINErrorFlags")
|
pybind11::classh<LINErrorFlags>(m, "LINErrorFlags")
|
||||||
.def_readwrite("ErrRxBreakOnly", &LINErrorFlags::ErrRxBreakOnly)
|
.def_readwrite("ErrRxBreakOnly", &LINErrorFlags::ErrRxBreakOnly)
|
||||||
.def_readwrite("ErrRxBreakSyncOnly", &LINErrorFlags::ErrRxBreakSyncOnly)
|
.def_readwrite("ErrRxBreakSyncOnly", &LINErrorFlags::ErrRxBreakSyncOnly)
|
||||||
.def_readwrite("ErrTxRxMismatch", &LINErrorFlags::ErrTxRxMismatch)
|
.def_readwrite("ErrTxRxMismatch", &LINErrorFlags::ErrTxRxMismatch)
|
||||||
@@ -20,7 +20,7 @@ void init_linmessage(pybind11::module_& m) {
|
|||||||
.def_readwrite("ErrFrameResponderData", &LINErrorFlags::ErrFrameResponderData)
|
.def_readwrite("ErrFrameResponderData", &LINErrorFlags::ErrFrameResponderData)
|
||||||
.def_readwrite("ErrChecksumMatch", &LINErrorFlags::ErrChecksumMatch);
|
.def_readwrite("ErrChecksumMatch", &LINErrorFlags::ErrChecksumMatch);
|
||||||
|
|
||||||
pybind11::class_<LINStatusFlags>(m, "LINStatusFlags")
|
pybind11::classh<LINStatusFlags>(m, "LINStatusFlags")
|
||||||
.def_readwrite("TxChecksumEnhanced", &LINStatusFlags::TxChecksumEnhanced)
|
.def_readwrite("TxChecksumEnhanced", &LINStatusFlags::TxChecksumEnhanced)
|
||||||
.def_readwrite("TxCommander", &LINStatusFlags::TxCommander)
|
.def_readwrite("TxCommander", &LINStatusFlags::TxCommander)
|
||||||
.def_readwrite("TxResponder", &LINStatusFlags::TxResponder)
|
.def_readwrite("TxResponder", &LINStatusFlags::TxResponder)
|
||||||
@@ -30,7 +30,7 @@ void init_linmessage(pybind11::module_& m) {
|
|||||||
.def_readwrite("BusRecovered", &LINStatusFlags::BusRecovered)
|
.def_readwrite("BusRecovered", &LINStatusFlags::BusRecovered)
|
||||||
.def_readwrite("BreakOnly", &LINStatusFlags::BreakOnly);
|
.def_readwrite("BreakOnly", &LINStatusFlags::BreakOnly);
|
||||||
|
|
||||||
pybind11::class_<LINMessage, std::shared_ptr<LINMessage>, Frame> linMessage(m, "LINMessage");
|
pybind11::classh<LINMessage, Frame> linMessage(m, "LINMessage");
|
||||||
|
|
||||||
pybind11::enum_<LINMessage::Type>(linMessage, "Type")
|
pybind11::enum_<LINMessage::Type>(linMessage, "Type")
|
||||||
.value("NOT_SET", LINMessage::Type::NOT_SET)
|
.value("NOT_SET", LINMessage::Type::NOT_SET)
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/chrono.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/livedatamessage.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_livedatamessage(pybind11::module_& m) {
|
||||||
|
// LiveDataMessage base class
|
||||||
|
pybind11::classh<LiveDataMessage, RawMessage>(m, "LiveDataMessage")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("handle", &LiveDataMessage::handle)
|
||||||
|
.def_readwrite("cmd", &LiveDataMessage::cmd);
|
||||||
|
|
||||||
|
// LiveDataCommandMessage (for subscribe/unsubscribe)
|
||||||
|
pybind11::classh<LiveDataCommandMessage, LiveDataMessage>(m, "LiveDataCommandMessage")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("update_period", &LiveDataCommandMessage::updatePeriod)
|
||||||
|
.def_readwrite("expiration_time", &LiveDataCommandMessage::expirationTime)
|
||||||
|
.def_readwrite("args", &LiveDataCommandMessage::args)
|
||||||
|
.def("append_signal_arg", &LiveDataCommandMessage::appendSignalArg,
|
||||||
|
pybind11::arg("value_type"),
|
||||||
|
"Append a signal argument to the command message");
|
||||||
|
|
||||||
|
// LiveDataValueMessage (received values)
|
||||||
|
pybind11::classh<LiveDataValueMessage, LiveDataMessage>(m, "LiveDataValueMessage")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("num_args", &LiveDataValueMessage::numArgs)
|
||||||
|
.def_readwrite("values", &LiveDataValueMessage::values);
|
||||||
|
|
||||||
|
// LiveDataStatusMessage (status responses)
|
||||||
|
pybind11::classh<LiveDataStatusMessage, LiveDataMessage>(m, "LiveDataStatusMessage")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("requested_command", &LiveDataStatusMessage::requestedCommand)
|
||||||
|
.def_readwrite("status", &LiveDataStatusMessage::status);
|
||||||
|
|
||||||
|
// LiveDataSetValueMessage (for setting values)
|
||||||
|
pybind11::classh<LiveDataSetValueMessage, LiveDataMessage>(m, "LiveDataSetValueMessage")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def_readwrite("args", &LiveDataSetValueMessage::args)
|
||||||
|
.def_readwrite("values", &LiveDataSetValueMessage::values)
|
||||||
|
.def("append_set_value", &LiveDataSetValueMessage::appendSetValue,
|
||||||
|
pybind11::arg("value_type"),
|
||||||
|
pybind11::arg("value"),
|
||||||
|
"Append a value to set in the message");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_mdiomessage(pybind11::module_& m) {
|
void init_mdiomessage(pybind11::module_& m) {
|
||||||
pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, Frame> mdioMessage(m, "MDIOMessage");
|
pybind11::classh<MDIOMessage, Frame> mdioMessage(m, "MDIOMessage");
|
||||||
pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause")
|
pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause")
|
||||||
.value("Clause45", MDIOMessage::Clause::Clause45)
|
.value("Clause45", MDIOMessage::Clause::Clause45)
|
||||||
.value("Clause22", MDIOMessage::Clause::Clause22);
|
.value("Clause22", MDIOMessage::Clause::Clause22);
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
#include "icsneo/communication/message/message.h"
|
#include "icsneo/communication/message/message.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_message(pybind11::module_& m) {
|
void init_message(pybind11::module_& m) {
|
||||||
pybind11::class_<Message, std::shared_ptr<Message>> message(m, "Message");
|
// Using py::smart_holder for safer lifetime management
|
||||||
pybind11::enum_<Message::Type>(message, "Type")
|
pybind11::classh<Message> message(m, "Message");
|
||||||
|
pybind11::native_enum<Message::Type>(message, "Type", "enum.IntEnum")
|
||||||
.value("Frame", Message::Type::Frame)
|
.value("Frame", Message::Type::Frame)
|
||||||
.value("CANErrorCount", Message::Type::CANErrorCount)
|
.value("CANErrorCount", Message::Type::CANErrorCount)
|
||||||
.value("CANError", Message::Type::CANError)
|
.value("CANError", Message::Type::CANError)
|
||||||
@@ -34,17 +36,18 @@ void init_message(pybind11::module_& m) {
|
|||||||
.value("TC10Status", Message::Type::TC10Status)
|
.value("TC10Status", Message::Type::TC10Status)
|
||||||
.value("AppError", Message::Type::AppError)
|
.value("AppError", Message::Type::AppError)
|
||||||
.value("GPTPStatus", Message::Type::GPTPStatus)
|
.value("GPTPStatus", Message::Type::GPTPStatus)
|
||||||
.value("EthernetStatus", Message::Type::EthernetStatus);
|
.value("EthernetStatus", Message::Type::EthernetStatus)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
message.def(pybind11::init<Message::Type>());
|
message.def(pybind11::init<Message::Type>());
|
||||||
message.def_readonly("type", &Message::type);
|
message.def_readonly("type", &Message::type);
|
||||||
message.def_readwrite("timestamp", &Message::timestamp);
|
message.def_readwrite("timestamp", &Message::timestamp);
|
||||||
|
|
||||||
pybind11::class_<RawMessage, std::shared_ptr<RawMessage>, Message>(m, "RawMessage")
|
pybind11::classh<RawMessage, Message>(m, "RawMessage")
|
||||||
.def_readwrite("network", &RawMessage::network)
|
.def_readwrite("network", &RawMessage::network)
|
||||||
.def_readwrite("data", &RawMessage::data);
|
.def_readwrite("data", &RawMessage::data);
|
||||||
|
|
||||||
pybind11::class_<Frame, std::shared_ptr<Frame>, RawMessage>(m, "Frame")
|
pybind11::classh<Frame, RawMessage>(m, "Frame")
|
||||||
.def_readwrite("description", &Frame::description)
|
.def_readwrite("description", &Frame::description)
|
||||||
.def_readwrite("transmitted", &Frame::transmitted)
|
.def_readwrite("transmitted", &Frame::transmitted)
|
||||||
.def_readwrite("error", &Frame::error);
|
.def_readwrite("error", &Frame::error);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_scriptstatusmessage(pybind11::module_& m) {
|
void init_scriptstatusmessage(pybind11::module_& m) {
|
||||||
pybind11::class_<ScriptStatusMessage, std::shared_ptr<ScriptStatusMessage>, Message>(m, "ScriptStatusMessage")
|
pybind11::classh<ScriptStatusMessage, Message>(m, "ScriptStatusMessage")
|
||||||
.def_readonly("isEncrypted", &ScriptStatusMessage::isEncrypted)
|
.def_readonly("isEncrypted", &ScriptStatusMessage::isEncrypted)
|
||||||
.def_readonly("isCoreminiRunning", &ScriptStatusMessage::isCoreminiRunning)
|
.def_readonly("isCoreminiRunning", &ScriptStatusMessage::isCoreminiRunning)
|
||||||
.def_readonly("sectorOverflows", &ScriptStatusMessage::sectorOverflows)
|
.def_readonly("sectorOverflows", &ScriptStatusMessage::sectorOverflows)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_spimessage(pybind11::module_& m) {
|
void init_spimessage(pybind11::module_& m) {
|
||||||
pybind11::class_<SPIMessage, std::shared_ptr<SPIMessage>, Frame> spiMessage(m, "SPIMessage");
|
pybind11::classh<SPIMessage, Frame> spiMessage(m, "SPIMessage");
|
||||||
pybind11::enum_<SPIMessage::Direction>(spiMessage, "Direction")
|
pybind11::enum_<SPIMessage::Direction>(spiMessage, "Direction")
|
||||||
.value("Write", SPIMessage::Direction::Write)
|
.value("Write", SPIMessage::Direction::Write)
|
||||||
.value("Read", SPIMessage::Direction::Read);
|
.value("Read", SPIMessage::Direction::Read);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ void init_tc10statusmessage(pybind11::module_& m) {
|
|||||||
.value("SleepFailed", TC10SleepStatus::SleepFailed)
|
.value("SleepFailed", TC10SleepStatus::SleepFailed)
|
||||||
.value("SleepAborted", TC10SleepStatus::SleepAborted);
|
.value("SleepAborted", TC10SleepStatus::SleepAborted);
|
||||||
|
|
||||||
pybind11::class_<TC10StatusMessage, std::shared_ptr<TC10StatusMessage>, Message>(m, "TC10StatusMessage")
|
pybind11::classh<TC10StatusMessage, Message>(m, "TC10StatusMessage")
|
||||||
.def_readonly("wakeStatus", &TC10StatusMessage::wakeStatus)
|
.def_readonly("wakeStatus", &TC10StatusMessage::wakeStatus)
|
||||||
.def_readonly("sleepStatus", &TC10StatusMessage::sleepStatus);
|
.def_readonly("sleepStatus", &TC10StatusMessage::sleepStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
#include "icsneo/communication/network.h"
|
#include "icsneo/communication/network.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_network(pybind11::module_& m) {
|
void init_network(pybind11::module_& m) {
|
||||||
pybind11::class_<Network> network(m, "Network");
|
pybind11::classh<Network> network(m, "Network");
|
||||||
|
|
||||||
pybind11::enum_<Network::NetID>(network, "NetID")
|
pybind11::native_enum<Network::NetID>(network, "NetID", "enum.IntEnum")
|
||||||
.value("Device", Network::NetID::Device)
|
.value("Device", Network::NetID::Device)
|
||||||
.value("DWCAN_01", Network::NetID::DWCAN_01)
|
.value("DWCAN_01", Network::NetID::DWCAN_01)
|
||||||
.value("DWCAN_08", Network::NetID::DWCAN_08)
|
.value("DWCAN_08", Network::NetID::DWCAN_08)
|
||||||
@@ -166,9 +167,10 @@ void init_network(pybind11::module_& m) {
|
|||||||
.value("LIN_15", Network::NetID::LIN_15)
|
.value("LIN_15", Network::NetID::LIN_15)
|
||||||
.value("LIN_16", Network::NetID::LIN_16)
|
.value("LIN_16", Network::NetID::LIN_16)
|
||||||
.value("Any", Network::NetID::Any)
|
.value("Any", Network::NetID::Any)
|
||||||
.value("Invalid", Network::NetID::Invalid);
|
.value("Invalid", Network::NetID::Invalid)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
pybind11::enum_<Network::Type>(network, "Type")
|
pybind11::native_enum<Network::Type>(network, "Type", "enum.Enum")
|
||||||
.value("Invalid", Network::Type::Invalid)
|
.value("Invalid", Network::Type::Invalid)
|
||||||
.value("Internal", Network::Type::Internal)
|
.value("Internal", Network::Type::Internal)
|
||||||
.value("CAN", Network::Type::CAN)
|
.value("CAN", Network::Type::CAN)
|
||||||
@@ -185,7 +187,8 @@ void init_network(pybind11::module_& m) {
|
|||||||
.value("MDIO", Network::Type::MDIO)
|
.value("MDIO", Network::Type::MDIO)
|
||||||
.value("AutomotiveEthernet", Network::Type::AutomotiveEthernet)
|
.value("AutomotiveEthernet", Network::Type::AutomotiveEthernet)
|
||||||
.value("Any", Network::Type::Any)
|
.value("Any", Network::Type::Any)
|
||||||
.value("Other", Network::Type::Other);
|
.value("Other", Network::Type::Other)
|
||||||
|
.finalize();
|
||||||
|
|
||||||
network
|
network
|
||||||
.def(pybind11::init<Network::NetID>())
|
.def(pybind11::init<Network::NetID>())
|
||||||
|
|||||||
@@ -35,17 +35,17 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.value("GCM_AES_128_XPN", MACsecCipherSuite::GcmAes128Xpn)
|
.value("GCM_AES_128_XPN", MACsecCipherSuite::GcmAes128Xpn)
|
||||||
.value("GCM_AES_256_XPN", MACsecCipherSuite::GcmAes256Xpn);
|
.value("GCM_AES_256_XPN", MACsecCipherSuite::GcmAes256Xpn);
|
||||||
|
|
||||||
pybind11::class_<MACsecVLANTag, std::shared_ptr<MACsecVLANTag>>(m, "MACsecVLANTag")
|
pybind11::classh<MACsecVLANTag>(m, "MACsecVLANTag")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("vid", &MACsecVLANTag::vid)
|
.def_readwrite("vid", &MACsecVLANTag::vid)
|
||||||
.def_readwrite("pri_cfi", &MACsecVLANTag::priCfi);
|
.def_readwrite("pri_cfi", &MACsecVLANTag::priCfi);
|
||||||
|
|
||||||
pybind11::class_<MACsecMPLSOuter, std::shared_ptr<MACsecMPLSOuter>>(m, "MACsecMPLSOuter")
|
pybind11::classh<MACsecMPLSOuter>(m, "MACsecMPLSOuter")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("mpls_label", &MACsecMPLSOuter::mplsLabel)
|
.def_readwrite("mpls_label", &MACsecMPLSOuter::mplsLabel)
|
||||||
.def_readwrite("exp", &MACsecMPLSOuter::exp);
|
.def_readwrite("exp", &MACsecMPLSOuter::exp);
|
||||||
|
|
||||||
pybind11::class_<MACsecTci, std::shared_ptr<MACsecTci>>(m, "MACsecTci")
|
pybind11::classh<MACsecTci>(m, "MACsecTci")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("es", &MACsecTci::es)
|
.def_readwrite("es", &MACsecTci::es)
|
||||||
.def_readwrite("sc", &MACsecTci::sc)
|
.def_readwrite("sc", &MACsecTci::sc)
|
||||||
@@ -53,7 +53,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.def_readwrite("e", &MACsecTci::e)
|
.def_readwrite("e", &MACsecTci::e)
|
||||||
.def_readwrite("c", &MACsecTci::c);
|
.def_readwrite("c", &MACsecTci::c);
|
||||||
|
|
||||||
pybind11::class_<MACsecRxRule, std::shared_ptr<MACsecRxRule>>(m, "MACsecRxRule")
|
pybind11::classh<MACsecRxRule>(m, "MACsecRxRule")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("key_mac_da", &MACsecRxRule::keyMacDa)
|
.def_readwrite("key_mac_da", &MACsecRxRule::keyMacDa)
|
||||||
.def_readwrite("mask_mac_da", &MACsecRxRule::maskMacDa)
|
.def_readwrite("mask_mac_da", &MACsecRxRule::maskMacDa)
|
||||||
@@ -85,7 +85,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.def_readwrite("mask_express", &MACsecRxRule::maskExpress)
|
.def_readwrite("mask_express", &MACsecRxRule::maskExpress)
|
||||||
.def_readwrite("is_mpls", &MACsecRxRule::isMpls);
|
.def_readwrite("is_mpls", &MACsecRxRule::isMpls);
|
||||||
|
|
||||||
pybind11::class_<MACsecTxSecY, std::shared_ptr<MACsecTxSecY>>(m, "MACsecTxSecY")
|
pybind11::classh<MACsecTxSecY>(m, "MACsecTxSecY")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("enable_control_port", &MACsecTxSecY::enableControlPort)
|
.def_readwrite("enable_control_port", &MACsecTxSecY::enableControlPort)
|
||||||
.def_readwrite("cipher", &MACsecTxSecY::cipher)
|
.def_readwrite("cipher", &MACsecTxSecY::cipher)
|
||||||
@@ -99,7 +99,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.def_readwrite("auxiliary_policy", &MACsecTxSecY::auxiliaryPolicy)
|
.def_readwrite("auxiliary_policy", &MACsecTxSecY::auxiliaryPolicy)
|
||||||
.def_readwrite("sci", &MACsecTxSecY::sci);
|
.def_readwrite("sci", &MACsecTxSecY::sci);
|
||||||
|
|
||||||
pybind11::class_<MACsecRxSecY, std::shared_ptr<MACsecRxSecY>>(m, "MACsecRxSecY")
|
pybind11::classh<MACsecRxSecY>(m, "MACsecRxSecY")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("enable_control_port", &MACsecRxSecY::enableControlPort)
|
.def_readwrite("enable_control_port", &MACsecRxSecY::enableControlPort)
|
||||||
.def_readwrite("frame_validation", &MACsecRxSecY::frameValidation)
|
.def_readwrite("frame_validation", &MACsecRxSecY::frameValidation)
|
||||||
@@ -112,7 +112,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.def_readwrite("is_control_packet", &MACsecRxSecY::isControlPacket)
|
.def_readwrite("is_control_packet", &MACsecRxSecY::isControlPacket)
|
||||||
.def_readwrite("sci", &MACsecRxSecY::sci);
|
.def_readwrite("sci", &MACsecRxSecY::sci);
|
||||||
|
|
||||||
pybind11::class_<MACsecTxSa, std::shared_ptr<MACsecTxSa>>(m, "MACsecTxSa")
|
pybind11::classh<MACsecTxSa>(m, "MACsecTxSa")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("sak", &MACsecTxSa::sak)
|
.def_readwrite("sak", &MACsecTxSa::sak)
|
||||||
.def_readwrite("hash_key", &MACsecTxSa::hashKey)
|
.def_readwrite("hash_key", &MACsecTxSa::hashKey)
|
||||||
@@ -121,7 +121,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.def_readwrite("next_pn", &MACsecTxSa::nextPn)
|
.def_readwrite("next_pn", &MACsecTxSa::nextPn)
|
||||||
.def_readwrite("an", &MACsecTxSa::an);
|
.def_readwrite("an", &MACsecTxSa::an);
|
||||||
|
|
||||||
pybind11::class_<MACsecRxSa, std::shared_ptr<MACsecRxSa>>(m, "MACsecRxSa")
|
pybind11::classh<MACsecRxSa>(m, "MACsecRxSa")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("sak", &MACsecRxSa::sak)
|
.def_readwrite("sak", &MACsecRxSa::sak)
|
||||||
.def_readwrite("hash_key", &MACsecRxSa::hashKey)
|
.def_readwrite("hash_key", &MACsecRxSa::hashKey)
|
||||||
@@ -129,7 +129,7 @@ void init_macsecconfig(pybind11::module_ & m)
|
|||||||
.def_readwrite("ssci", &MACsecRxSa::ssci)
|
.def_readwrite("ssci", &MACsecRxSa::ssci)
|
||||||
.def_readwrite("next_pn", &MACsecRxSa::nextPn);
|
.def_readwrite("next_pn", &MACsecRxSa::nextPn);
|
||||||
|
|
||||||
pybind11::class_<MACsecConfig, std::shared_ptr<MACsecConfig>>(m, "MACsecConfig")
|
pybind11::classh<MACsecConfig>(m, "MACsecConfig")
|
||||||
.def(pybind11::init<icsneo::DeviceType>())
|
.def(pybind11::init<icsneo::DeviceType>())
|
||||||
.def("add_rx_secy", &MACsecConfig::addRxSecY, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("add_rx_secy", &MACsecConfig::addRxSecY, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("add_tx_secY", &MACsecConfig::addTxSecY, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("add_tx_secY", &MACsecConfig::addTxSecY, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
#include "icsneo/device/chipid.h"
|
#include "icsneo/device/chipid.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_chipid(pybind11::module_& m) {
|
void init_chipid(pybind11::module_& m) {
|
||||||
pybind11::enum_<ChipID>(m, "ChipID")
|
pybind11::native_enum<ChipID>(m, "ChipID", "enum.IntEnum")
|
||||||
.value("neoVIFIRE_MCHIP", ChipID::neoVIFIRE_MCHIP)
|
.value("neoVIFIRE_MCHIP", ChipID::neoVIFIRE_MCHIP)
|
||||||
.value("neoVIFIRE_LCHIP", ChipID::neoVIFIRE_LCHIP)
|
.value("neoVIFIRE_LCHIP", ChipID::neoVIFIRE_LCHIP)
|
||||||
.value("neoVIFIRE_UCHIP", ChipID::neoVIFIRE_UCHIP)
|
.value("neoVIFIRE_UCHIP", ChipID::neoVIFIRE_UCHIP)
|
||||||
@@ -102,7 +103,7 @@ void init_chipid(pybind11::module_& m) {
|
|||||||
.value("neoOBD2Dev_MCHIP", ChipID::neoOBD2Dev_MCHIP)
|
.value("neoOBD2Dev_MCHIP", ChipID::neoOBD2Dev_MCHIP)
|
||||||
.value("neoOBD2Dev_SCHIP", ChipID::neoOBD2Dev_SCHIP)
|
.value("neoOBD2Dev_SCHIP", ChipID::neoOBD2Dev_SCHIP)
|
||||||
.value("neoOBD2SIMDoIP_MCHIP", ChipID::neoOBD2SIMDoIP_MCHIP)
|
.value("neoOBD2SIMDoIP_MCHIP", ChipID::neoOBD2SIMDoIP_MCHIP)
|
||||||
.value("SFPModule_MCHIP", ChipID::SFPModule_MCHIP)
|
.value("SFPModule_88q2112_MCHIP", ChipID::SFPModule_88q2112_MCHIP)
|
||||||
.value("RADEpsilonT_MCHIP", ChipID::RADEpsilonT_MCHIP)
|
.value("RADEpsilonT_MCHIP", ChipID::RADEpsilonT_MCHIP)
|
||||||
.value("RADEpsilonExpress_MCHIP", ChipID::RADEpsilonExpress_MCHIP)
|
.value("RADEpsilonExpress_MCHIP", ChipID::RADEpsilonExpress_MCHIP)
|
||||||
.value("RADProxima_MCHIP", ChipID::RADProxima_MCHIP)
|
.value("RADProxima_MCHIP", ChipID::RADProxima_MCHIP)
|
||||||
@@ -110,7 +111,7 @@ void init_chipid(pybind11::module_& m) {
|
|||||||
.value("RAD_GALAXY_2_ZMPCHIP_ID", ChipID::RAD_GALAXY_2_ZMPCHIP_ID)
|
.value("RAD_GALAXY_2_ZMPCHIP_ID", ChipID::RAD_GALAXY_2_ZMPCHIP_ID)
|
||||||
.value("NewDevice59_MCHIP", ChipID::NewDevice59_MCHIP)
|
.value("NewDevice59_MCHIP", ChipID::NewDevice59_MCHIP)
|
||||||
.value("RADMoon2_Z7010_ZYNQ", ChipID::RADMoon2_Z7010_ZYNQ)
|
.value("RADMoon2_Z7010_ZYNQ", ChipID::RADMoon2_Z7010_ZYNQ)
|
||||||
.value("neoVIFIRE2_CORE_SG4", ChipID::neoVIFIRE2_CORE_SG4)
|
.value("neoVIFIRE2_Core_SG4", ChipID::neoVIFIRE2_Core_SG4)
|
||||||
.value("RADBMS_MCHIP", ChipID::RADBMS_MCHIP)
|
.value("RADBMS_MCHIP", ChipID::RADBMS_MCHIP)
|
||||||
.value("RADMoon2_ZL_MCHIP", ChipID::RADMoon2_ZL_MCHIP)
|
.value("RADMoon2_ZL_MCHIP", ChipID::RADMoon2_ZL_MCHIP)
|
||||||
.value("RADGigastar_USBZ_Z7010_ZYNQ", ChipID::RADGigastar_USBZ_Z7010_ZYNQ)
|
.value("RADGigastar_USBZ_Z7010_ZYNQ", ChipID::RADGigastar_USBZ_Z7010_ZYNQ)
|
||||||
@@ -119,18 +120,23 @@ void init_chipid(pybind11::module_& m) {
|
|||||||
.value("VEM_01_8DW_ZCHIP", ChipID::VEM_01_8DW_ZCHIP)
|
.value("VEM_01_8DW_ZCHIP", ChipID::VEM_01_8DW_ZCHIP)
|
||||||
.value("RADGalaxy_FFG_Zynq", ChipID::RADGalaxy_FFG_Zynq)
|
.value("RADGalaxy_FFG_Zynq", ChipID::RADGalaxy_FFG_Zynq)
|
||||||
.value("RADMoon3_MCHIP", ChipID::RADMoon3_MCHIP)
|
.value("RADMoon3_MCHIP", ChipID::RADMoon3_MCHIP)
|
||||||
.value("RADComet_ZYNQ", ChipID::RADComet_ZYNQ)
|
.value("RADComet2_ZYNQ", ChipID::RADComet2_ZYNQ)
|
||||||
.value("VEM_02_FR_ZCHIP", ChipID::VEM_02_FR_ZCHIP)
|
.value("VEM_02_FR_ZCHIP", ChipID::VEM_02_FR_ZCHIP)
|
||||||
.value("RADA2B_REVB_ZCHIP", ChipID::RADA2B_REVB_ZCHIP)
|
.value("RADA2B_REVB_ZCHIP", ChipID::RADA2B_REVB_ZCHIP)
|
||||||
.value("RADGigastar_FFG_ZYNQ", ChipID::RADGigastar_FFG_ZYNQ)
|
.value("RADGigastar_FFG_ZYNQ", ChipID::RADGigastar_FFG_ZYNQ)
|
||||||
.value("VEM_02_FR_FCHIP", ChipID::VEM_02_FR_FCHIP)
|
.value("VEM_02_FR_FCHIP", ChipID::VEM_02_FR_FCHIP)
|
||||||
.value("Connect_ZCHIP", ChipID::Connect_ZCHIP)
|
.value("Connect_ZCHIP", ChipID::Connect_ZCHIP)
|
||||||
|
.value("SFPModule_88q2221_MCHIP", ChipID::SFPModule_88q2221_MCHIP)
|
||||||
.value("RADGALAXY2_SYSMON_CHIP", ChipID::RADGALAXY2_SYSMON_CHIP)
|
.value("RADGALAXY2_SYSMON_CHIP", ChipID::RADGALAXY2_SYSMON_CHIP)
|
||||||
|
.value("SFPModule_88q3244_MCHIP", ChipID::SFPModule_88q3244_MCHIP)
|
||||||
.value("RADCOMET3_ZCHIP", ChipID::RADCOMET3_ZCHIP)
|
.value("RADCOMET3_ZCHIP", ChipID::RADCOMET3_ZCHIP)
|
||||||
.value("Connect_LINUX", ChipID::Connect_LINUX)
|
.value("Connect_LINUX", ChipID::Connect_LINUX)
|
||||||
|
.value("SFPModule_lan8670_MCHIP", ChipID::SFPModule_lan8670_MCHIP)
|
||||||
.value("RADGigastar2_ZYNQ", ChipID::RADGigastar2_ZYNQ)
|
.value("RADGigastar2_ZYNQ", ChipID::RADGigastar2_ZYNQ)
|
||||||
|
.value("SFPModule_ent11100_MCHIP", ChipID::SFPModule_ent11100_MCHIP)
|
||||||
.value("RADGemini_MCHIP", ChipID::RADGemini_MCHIP)
|
.value("RADGemini_MCHIP", ChipID::RADGemini_MCHIP)
|
||||||
.value("Invalid", ChipID::Invalid);
|
.value("Invalid", ChipID::Invalid)
|
||||||
|
.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
|
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/extensions/deviceextension.h"
|
#include "icsneo/device/extensions/deviceextension.h"
|
||||||
|
#include "icsneo/disk/diskdetails.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_device(pybind11::module_& m) {
|
void init_device(pybind11::module_& m) {
|
||||||
pybind11::class_<Device, std::shared_ptr<Device>>(m, "Device")
|
pybind11::classh<Device>(m, "Device")
|
||||||
.def("__repr__", &Device::describe)
|
.def("__repr__", &Device::describe)
|
||||||
.def("add_message_callback", &Device::addMessageCallback, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("add_message_callback", &Device::addMessageCallback, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("clear_script", &Device::clearScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("clear_script", &Device::clearScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
@@ -31,6 +32,8 @@ void init_device(pybind11::module_& m) {
|
|||||||
.def("get_script_status", &Device::getScriptStatus, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_script_status", &Device::getScriptStatus, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_serial_number", &Device::getSerialNumber)
|
.def("get_serial_number", &Device::getSerialNumber)
|
||||||
.def("get_serial", &Device::getSerial)
|
.def("get_serial", &Device::getSerial)
|
||||||
|
.def("get_pcb_serial", &Device::getPCBSerial, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_mac_addresses", &Device::getMACAddresses, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference)
|
.def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference)
|
||||||
.def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference)
|
.def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference)
|
||||||
.def("get_tc10_status", &Device::getTC10Status, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_tc10_status", &Device::getTC10Status, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
@@ -49,14 +52,26 @@ void init_device(pybind11::module_& m) {
|
|||||||
.def("set_digital_io", pybind11::overload_cast<IO, size_t, bool>(&Device::setDigitalIO), pybind11::arg("type"), pybind11::arg("number"), pybind11::arg("value"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("set_digital_io", pybind11::overload_cast<IO, size_t, bool>(&Device::setDigitalIO), pybind11::arg("type"), pybind11::arg("number"), pybind11::arg("value"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("set_polling_message_limit", &Device::setPollingMessageLimit)
|
.def("set_polling_message_limit", &Device::setPollingMessageLimit)
|
||||||
.def("set_rtc", &Device::setRTC, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("set_rtc", &Device::setRTC, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("reboot", &Device::reboot, pybind11::arg("safe") = false, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("start_script", &Device::startScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("start_script", &Device::startScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("stop_script", &Device::stopScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("stop_script", &Device::stopScript, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("supports_tc10", &Device::supportsTC10)
|
.def("supports_tc10", &Device::supportsTC10)
|
||||||
|
.def("supports_reboot", &Device::supportsReboot)
|
||||||
|
.def("supports_live_data", &Device::supportsLiveData)
|
||||||
|
.def("subscribe_live_data", &Device::subscribeLiveData, pybind11::arg("message"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("unsubscribe_live_data", &Device::unsubscribeLiveData, pybind11::arg("handle"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("clear_all_live_data", &Device::clearAllLiveData, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_value_live_data", &Device::setValueLiveData, pybind11::arg("message"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("transmit", pybind11::overload_cast<std::shared_ptr<Frame>>(&Device::transmit), pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("transmit", pybind11::overload_cast<std::shared_ptr<Frame>>(&Device::transmit), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("upload_coremini", [](Device& device, std::string& path, Disk::MemoryType memType) { std::ifstream ifs(path, std::ios::binary); return device.uploadCoremini(ifs, memType); }, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("upload_coremini", [](Device& device, std::string& path, Disk::MemoryType memType) { std::ifstream ifs(path, std::ios::binary); return device.uploadCoremini(ifs, memType); }, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("write_macsec_config", &Device::writeMACsecConfig, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("write_macsec_config", &Device::writeMACsecConfig, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("send_eth_phy_msg", &Device::sendEthPhyMsg, pybind11::arg("message"), pybind11::arg("timeout") = std::chrono::milliseconds(50), pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("send_eth_phy_msg", &Device::sendEthPhyMsg, pybind11::arg("message"), pybind11::arg("timeout") = std::chrono::milliseconds(50), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_chip_versions", &Device::getChipVersions, pybind11::arg("refreshComponents") = true, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_chip_versions", &Device::getChipVersions, pybind11::arg("refreshComponents") = true, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("supports_disk_formatting", &Device::supportsDiskFormatting, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_disk_count", &Device::getDiskCount, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_disk_details", &Device::getDiskDetails, pybind11::arg("timeout") = std::chrono::milliseconds(100), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("force_disk_config_update", &Device::forceDiskConfigUpdate, pybind11::arg("config"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("format_disk", [](Device& device, const DiskDetails& config) -> bool { return device.formatDisk(config); }, pybind11::arg("config"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def_readonly("settings", &Device::settings);
|
.def_readonly("settings", &Device::settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/native_enum.h>
|
||||||
|
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_devicetype(pybind11::module_& m) {
|
void init_devicetype(pybind11::module_& m) {
|
||||||
pybind11::class_<DeviceType> deviceType(m, "DeviceType");
|
pybind11::classh<DeviceType> deviceType(m, "DeviceType");
|
||||||
pybind11::enum_<DeviceType::Enum>(deviceType, "Enum")
|
pybind11::native_enum<DeviceType::Enum>(deviceType, "Enum", "enum.IntEnum")
|
||||||
.value("Unknown", DeviceType::Enum::Unknown)
|
.value("Unknown", DeviceType::Enum::Unknown)
|
||||||
.value("BLUE", DeviceType::Enum::BLUE)
|
.value("BLUE", DeviceType::Enum::BLUE)
|
||||||
.value("ECU_AVB", DeviceType::Enum::ECU_AVB)
|
.value("ECU_AVB", DeviceType::Enum::ECU_AVB)
|
||||||
@@ -35,9 +36,10 @@ void init_devicetype(pybind11::module_& m) {
|
|||||||
.value("RADEpsilon", DeviceType::Enum::RADEpsilon)
|
.value("RADEpsilon", DeviceType::Enum::RADEpsilon)
|
||||||
.value("RADEpsilonXL", DeviceType::Enum::RADEpsilonXL)
|
.value("RADEpsilonXL", DeviceType::Enum::RADEpsilonXL)
|
||||||
.value("RADGalaxy2", DeviceType::Enum::RADGalaxy2)
|
.value("RADGalaxy2", DeviceType::Enum::RADGalaxy2)
|
||||||
|
.value("RADwBMS", DeviceType::Enum::RADwBMS)
|
||||||
.value("RADMoon3", DeviceType::Enum::RADMoon3)
|
.value("RADMoon3", DeviceType::Enum::RADMoon3)
|
||||||
.value("RADGemini", DeviceType::Enum::RADGemini)
|
.value("RADGemini", DeviceType::Enum::RADGemini)
|
||||||
.value("RADComet", DeviceType::Enum::RADComet)
|
.value("RADComet2", DeviceType::Enum::RADComet2)
|
||||||
.value("FIRE3_FlexRay", DeviceType::Enum::FIRE3_FlexRay)
|
.value("FIRE3_FlexRay", DeviceType::Enum::FIRE3_FlexRay)
|
||||||
.value("FIRE3_T1S_LIN", DeviceType::Enum::FIRE3_T1S_LIN)
|
.value("FIRE3_T1S_LIN", DeviceType::Enum::FIRE3_T1S_LIN)
|
||||||
.value("FIRE3_T1S_SENT", DeviceType::Enum::FIRE3_T1S_SENT)
|
.value("FIRE3_T1S_SENT", DeviceType::Enum::FIRE3_T1S_SENT)
|
||||||
@@ -70,7 +72,8 @@ void init_devicetype(pybind11::module_& m) {
|
|||||||
.value("RADGalaxy", DeviceType::Enum::RADGalaxy)
|
.value("RADGalaxy", DeviceType::Enum::RADGalaxy)
|
||||||
.value("RADStar2", DeviceType::Enum::RADStar2)
|
.value("RADStar2", DeviceType::Enum::RADStar2)
|
||||||
.value("VividCAN", DeviceType::Enum::VividCAN)
|
.value("VividCAN", DeviceType::Enum::VividCAN)
|
||||||
.value("OBD2_SIM", DeviceType::Enum::OBD2_SIM);
|
.value("OBD2_SIM", DeviceType::Enum::OBD2_SIM)
|
||||||
|
.finalize();
|
||||||
deviceType.def(pybind11::init<DeviceType::Enum>());
|
deviceType.def(pybind11::init<DeviceType::Enum>());
|
||||||
deviceType.def("get_device_type", &DeviceType::getDeviceType);
|
deviceType.def("get_device_type", &DeviceType::getDeviceType);
|
||||||
deviceType.def("get_generic_product_name", &DeviceType::getGenericProductName);
|
deviceType.def("get_generic_product_name", &DeviceType::getGenericProductName);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_deviceextension(pybind11::module_& m) {
|
void init_deviceextension(pybind11::module_& m) {
|
||||||
pybind11::class_<DeviceExtension, std::shared_ptr<DeviceExtension>>(m, "DeviceExtension")
|
pybind11::classh<DeviceExtension>(m, "DeviceExtension")
|
||||||
.def("get_name", &DeviceExtension::getName);
|
.def("get_name", &DeviceExtension::getName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,35 +12,152 @@ namespace icsneo {
|
|||||||
|
|
||||||
struct DeviceSettingsNamespace {
|
struct DeviceSettingsNamespace {
|
||||||
using EthLinkMode = AELinkMode;
|
using EthLinkMode = AELinkMode;
|
||||||
using LinkSpeed = EthLinkSpeed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_idevicesettings(pybind11::module_& m) {
|
void init_idevicesettings(pybind11::module_& m) {
|
||||||
pybind11::class_<DeviceSettingsNamespace> settings(m, "Settings");
|
pybind11::classh<DeviceSettingsNamespace> settings(m, "Settings");
|
||||||
|
|
||||||
pybind11::enum_<DeviceSettingsNamespace::EthLinkMode>(settings, "EthernetLinkMode")
|
pybind11::enum_<DeviceSettingsNamespace::EthLinkMode>(settings, "EthernetLinkMode")
|
||||||
.value("Auto", DeviceSettingsNamespace::EthLinkMode::AE_LINK_AUTO)
|
.value("Auto", DeviceSettingsNamespace::EthLinkMode::AE_LINK_AUTO)
|
||||||
.value("Slave", DeviceSettingsNamespace::EthLinkMode::AE_LINK_SLAVE)
|
.value("Slave", DeviceSettingsNamespace::EthLinkMode::AE_LINK_SLAVE)
|
||||||
.value("Master", DeviceSettingsNamespace::EthLinkMode::AE_LINK_MASTER);
|
.value("Master", DeviceSettingsNamespace::EthLinkMode::AE_LINK_MASTER);
|
||||||
|
|
||||||
pybind11::enum_<DeviceSettingsNamespace::LinkSpeed>(settings, "EthernetLinkSpeed")
|
pybind11::enum_<EthPhyLinkMode>(settings, "PhyLinkMode")
|
||||||
.value("Speed10M", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_10)
|
.value("ETH_LINK_MODE_AUTO_NEGOTIATION", ETH_LINK_MODE_AUTO_NEGOTIATION)
|
||||||
.value("Speed100M", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_100)
|
.value("ETH_LINK_MODE_10MBPS_HALFDUPLEX", ETH_LINK_MODE_10MBPS_HALFDUPLEX)
|
||||||
.value("Speed1G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_1000)
|
.value("ETH_LINK_MODE_10MBPS_FULLDUPLEX", ETH_LINK_MODE_10MBPS_FULLDUPLEX)
|
||||||
.value("Speed2_5G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_2500)
|
.value("ETH_LINK_MODE_100MBPS_HALFDUPLEX", ETH_LINK_MODE_100MBPS_HALFDUPLEX)
|
||||||
.value("Speed5G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_5000)
|
.value("ETH_LINK_MODE_100MBPS_FULLDUPLEX", ETH_LINK_MODE_100MBPS_FULLDUPLEX)
|
||||||
.value("Speed10G", DeviceSettingsNamespace::LinkSpeed::ETH_SPEED_10000);
|
.value("ETH_LINK_MODE_1GBPS_HALFDUPLEX", ETH_LINK_MODE_1GBPS_HALFDUPLEX)
|
||||||
|
.value("ETH_LINK_MODE_1GBPS_FULLDUPLEX", ETH_LINK_MODE_1GBPS_FULLDUPLEX)
|
||||||
|
.value("ETH_LINK_MODE_2_5GBPS_FULLDUPLEX", ETH_LINK_MODE_2_5GBPS_FULLDUPLEX)
|
||||||
|
.value("ETH_LINK_MODE_5GBPS_FULLDUPLEX", ETH_LINK_MODE_5GBPS_FULLDUPLEX)
|
||||||
|
.value("ETH_LINK_MODE_10GBPS_FULLDUPLEX", ETH_LINK_MODE_10GBPS_FULLDUPLEX);
|
||||||
|
|
||||||
pybind11::class_<IDeviceSettings, std::shared_ptr<IDeviceSettings>>(m, "IDeviceSettings")
|
pybind11::enum_<LINMode>(settings, "LINMode")
|
||||||
|
.value("Sleep", LINMode::SLEEP_MODE)
|
||||||
|
.value("Slow", LINMode::SLOW_MODE)
|
||||||
|
.value("Normal", LINMode::NORMAL_MODE)
|
||||||
|
.value("Fast", LINMode::FAST_MODE);
|
||||||
|
|
||||||
|
pybind11::enum_<RADGPTPProfile>(settings, "GPTPProfile")
|
||||||
|
.value("Standard", RADGPTPProfile::RAD_GPTP_PROFILE_STANDARD)
|
||||||
|
.value("Automotive", RADGPTPProfile::RAD_GPTP_PROFILE_AUTOMOTIVE);
|
||||||
|
|
||||||
|
pybind11::enum_<RADGPTPRole>(settings, "GPTPRole")
|
||||||
|
.value("Disabled", RADGPTPRole::RAD_GPTP_ROLE_DISABLED)
|
||||||
|
.value("Passive", RADGPTPRole::RAD_GPTP_ROLE_PASSIVE)
|
||||||
|
.value("Master", RADGPTPRole::RAD_GPTP_ROLE_MASTER)
|
||||||
|
.value("Slave", RADGPTPRole::RAD_GPTP_ROLE_SLAVE);
|
||||||
|
|
||||||
|
pybind11::enum_<MiscIOAnalogVoltage>(settings, "MiscIOAnalogVoltage")
|
||||||
|
.value("V0", MiscIOAnalogVoltage::V0)
|
||||||
|
.value("V1", MiscIOAnalogVoltage::V1)
|
||||||
|
.value("V2", MiscIOAnalogVoltage::V2)
|
||||||
|
.value("V3", MiscIOAnalogVoltage::V3)
|
||||||
|
.value("V4", MiscIOAnalogVoltage::V4)
|
||||||
|
.value("V5", MiscIOAnalogVoltage::V5);
|
||||||
|
|
||||||
|
pybind11::enum_<LinuxConfigurationPort>(settings, "LinuxConfigurationPort")
|
||||||
|
.value("USB", LinuxConfigurationPort::USB)
|
||||||
|
.value("ETH01", LinuxConfigurationPort::ETH01);
|
||||||
|
|
||||||
|
pybind11::classh<IDeviceSettings>(m, "IDeviceSettings")
|
||||||
.def("apply", &IDeviceSettings::apply, pybind11::arg("temporary") = 0, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("apply", &IDeviceSettings::apply, pybind11::arg("temporary") = 0, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("apply_defaults", &IDeviceSettings::applyDefaults, pybind11::arg("temporary") = 0, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("apply_defaults", &IDeviceSettings::applyDefaults, pybind11::arg("temporary") = 0, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("refresh", &IDeviceSettings::refresh, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// Baudrate methods
|
||||||
|
.def("get_baudrate", &IDeviceSettings::getBaudrateFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_baudrate", &IDeviceSettings::setBaudrateFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_fd_baudrate", &IDeviceSettings::getFDBaudrateFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_fd_baudrate", &IDeviceSettings::setFDBaudrateFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// Termination methods
|
||||||
|
.def("is_termination_supported", &IDeviceSettings::isTerminationSupportedFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("can_termination_be_enabled", &IDeviceSettings::canTerminationBeEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("is_termination_enabled", &IDeviceSettings::isTerminationEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_termination", &IDeviceSettings::setTerminationFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_termination_groups", &IDeviceSettings::getTerminationGroups, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// LIN methods
|
||||||
|
.def("is_commander_resistor_enabled", &IDeviceSettings::isCommanderResistorEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_commander_resistor", &IDeviceSettings::setCommanderResistorFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_lin_mode", &IDeviceSettings::getLINModeFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_lin_mode", &IDeviceSettings::setLINModeFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_lin_commander_response_time", &IDeviceSettings::getLINCommanderResponseTimeFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_lin_commander_response_time", &IDeviceSettings::setLINCommanderResponseTimeFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// Ethernet PHY methods (index-based for switch devices)
|
||||||
.def("get_phy_enable", &IDeviceSettings::getPhyEnable, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_phy_enable", &IDeviceSettings::getPhyEnable, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_phy_mode", &IDeviceSettings::getPhyMode, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_phy_mode", &IDeviceSettings::getPhyMode, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_phy_speed", &IDeviceSettings::getPhySpeed, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_phy_speed", &IDeviceSettings::getPhySpeed, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("set_phy_enable", &IDeviceSettings::setPhyEnable, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("set_phy_enable", &IDeviceSettings::setPhyEnable, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("set_phy_mode", &IDeviceSettings::setPhyMode, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("set_phy_mode", &IDeviceSettings::setPhyMode, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("set_phy_speed", &IDeviceSettings::setPhySpeed, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("set_phy_speed", &IDeviceSettings::setPhySpeed, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("refresh", &IDeviceSettings::refresh, pybind11::call_guard<pybind11::gil_scoped_release>());
|
|
||||||
|
// Ethernet PHY methods (network-based for multi-interface devices)
|
||||||
|
.def("get_phy_enable_for", &IDeviceSettings::getPhyEnableFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_phy_role_for", &IDeviceSettings::getPhyRoleFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_phy_link_mode_for", &IDeviceSettings::getPhyLinkModeFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_phy_enable_for", &IDeviceSettings::setPhyEnableFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_phy_role_for", &IDeviceSettings::setPhyRoleFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_phy_link_mode_for", &IDeviceSettings::setPhyLinkModeFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_supported_phy_link_modes_for", &IDeviceSettings::getSupportedPhyLinkModesFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// 10BASE-T1S methods
|
||||||
|
.def("is_t1s_plca_enabled", &IDeviceSettings::isT1SPLCAEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_plca", &IDeviceSettings::setT1SPLCAFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_local_id", &IDeviceSettings::getT1SLocalIDFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_local_id", &IDeviceSettings::setT1SLocalIDFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_max_nodes", &IDeviceSettings::getT1SMaxNodesFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_max_nodes", &IDeviceSettings::setT1SMaxNodesFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_tx_opp_timer", &IDeviceSettings::getT1STxOppTimerFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_tx_opp_timer", &IDeviceSettings::setT1STxOppTimerFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_max_burst", &IDeviceSettings::getT1SMaxBurstFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_max_burst", &IDeviceSettings::setT1SMaxBurstFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_burst_timer", &IDeviceSettings::getT1SBurstTimerFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_burst_timer", &IDeviceSettings::setT1SBurstTimerFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_local_id_alternate", &IDeviceSettings::getT1SLocalIDAlternateFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_local_id_alternate", &IDeviceSettings::setT1SLocalIDAlternateFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("is_t1s_termination_enabled", &IDeviceSettings::isT1STerminationEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_termination", &IDeviceSettings::setT1STerminationFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("is_t1s_bus_decoding_beacons_enabled", &IDeviceSettings::isT1SBusDecodingBeaconsEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_bus_decoding_beacons", &IDeviceSettings::setT1SBusDecodingBeaconsFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("is_t1s_bus_decoding_all_enabled", &IDeviceSettings::isT1SBusDecodingAllEnabledFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_bus_decoding_all", &IDeviceSettings::setT1SBusDecodingAllFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_multi_id_enable_mask", &IDeviceSettings::getT1SMultiIDEnableMaskFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_multi_id_enable_mask", &IDeviceSettings::setT1SMultiIDEnableMaskFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_t1s_multi_id", &IDeviceSettings::getT1SMultiIDFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_t1s_multi_id", &IDeviceSettings::setT1SMultiIDFor, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
.def("set_misc_io_analog_output_enabled", &IDeviceSettings::setMiscIOAnalogOutputEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_misc_io_analog_output", &IDeviceSettings::setMiscIOAnalogOutput, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// Performance blast
|
||||||
|
.def("is_perf_test_enabled", &IDeviceSettings::isPerfTestEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_perf_test_enable", &IDeviceSettings::setPerfTestEnable, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
// gPTP methods
|
||||||
|
.def("get_gptp_profile", &IDeviceSettings::getGPTPProfile, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_gptp_profile", &IDeviceSettings::setGPTPProfile, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_gptp_role", &IDeviceSettings::getGPTPRole, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_gptp_role", &IDeviceSettings::setGPTPRole, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_gptp_enabled_port", &IDeviceSettings::getGPTPEnabledPort, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_gptp_enabled_port", &IDeviceSettings::setGPTPEnabledPort, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("is_gptp_clock_syntonization_enabled", &IDeviceSettings::isGPTPClockSyntonizationEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_gptp_clock_syntonization_enabled", &IDeviceSettings::setGPTPClockSyntonizationEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// Linux operating-system settings (Fire3 family devices)
|
||||||
|
.def("get_linux_boot_enabled", &IDeviceSettings::getLinuxBootEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_linux_boot_enabled", &IDeviceSettings::setLinuxBootEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_external_wifi_antenna_enabled", &IDeviceSettings::getExternalWifiAntennaEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_external_wifi_antenna_enabled", &IDeviceSettings::setExternalWifiAntennaEnabled, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_linux_configuration_port", &IDeviceSettings::getLinuxConfigurationPort, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("set_linux_configuration_port", &IDeviceSettings::setLinuxConfigurationPort, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
|
||||||
|
// Status properties
|
||||||
|
.def_readonly("disabled", &IDeviceSettings::disabled)
|
||||||
|
.def_readonly("readonly", &IDeviceSettings::readonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
void init_versionreport(pybind11::module_& m) {
|
void init_versionreport(pybind11::module_& m) {
|
||||||
pybind11::class_<VersionReport>(m, "VersionReport")
|
pybind11::classh<VersionReport>(m, "VersionReport")
|
||||||
.def_readonly("id", &VersionReport::id)
|
.def_readonly("id", &VersionReport::id)
|
||||||
.def_readonly("name", &VersionReport::name)
|
.def_readonly("name", &VersionReport::name)
|
||||||
.def_readonly("major", &VersionReport::major)
|
.def_readonly("major", &VersionReport::major)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
|
||||||
|
#include "icsneo/disk/diskdetails.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_diskdetails(pybind11::module_& m) {
|
||||||
|
pybind11::enum_<DiskLayout>(m, "DiskLayout")
|
||||||
|
.value("Spanned", DiskLayout::Spanned)
|
||||||
|
.value("RAID0", DiskLayout::RAID0);
|
||||||
|
|
||||||
|
pybind11::classh<DiskInfo>(m, "DiskInfo")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("present", &DiskInfo::present)
|
||||||
|
.def_readwrite("initialized", &DiskInfo::initialized)
|
||||||
|
.def_readwrite("formatted", &DiskInfo::formatted)
|
||||||
|
.def_readwrite("sectors", &DiskInfo::sectors)
|
||||||
|
.def_readwrite("bytes_per_sector", &DiskInfo::bytesPerSector)
|
||||||
|
.def("size", &DiskInfo::size);
|
||||||
|
|
||||||
|
pybind11::classh<DiskDetails>(m, "DiskDetails")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("layout", &DiskDetails::layout)
|
||||||
|
.def_readwrite("full_format", &DiskDetails::fullFormat)
|
||||||
|
.def_readwrite("disks", &DiskDetails::disks);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -13,7 +13,7 @@ struct DiskNamespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void init_diskdriver(pybind11::module_& m) {
|
void init_diskdriver(pybind11::module_& m) {
|
||||||
pybind11::class_<DiskNamespace> disk(m, "Disk");
|
pybind11::classh<DiskNamespace> disk(m, "Disk");
|
||||||
pybind11::enum_<Disk::Access>(disk, "Access")
|
pybind11::enum_<Disk::Access>(disk, "Access")
|
||||||
.value("None", Disk::Access::None)
|
.value("None", Disk::Access::None)
|
||||||
.value("EntireCard", Disk::Access::EntireCard)
|
.value("EntireCard", Disk::Access::EntireCard)
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ struct ClusterNamespace {
|
|||||||
using SPPType = icsneo::FlexRay::Cluster::SPPType;
|
using SPPType = icsneo::FlexRay::Cluster::SPPType;
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
void init_extension(pybind11::classh<FlexRayNamespace>& c) {
|
||||||
pybind11::class_<MessageBuffer, std::shared_ptr<MessageBuffer>>(c, "MessageBuffer")
|
pybind11::classh<MessageBuffer>(c, "MessageBuffer")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("is_dynamic", &MessageBuffer::isDynamic)
|
.def_readwrite("is_dynamic", &MessageBuffer::isDynamic)
|
||||||
.def_readwrite("is_sync", &MessageBuffer::isSync)
|
.def_readwrite("is_sync", &MessageBuffer::isSync)
|
||||||
@@ -39,7 +39,7 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||||||
.def_readwrite("cycle_repetition", &MessageBuffer::cycleRepetition)
|
.def_readwrite("cycle_repetition", &MessageBuffer::cycleRepetition)
|
||||||
.def_readwrite("continuous_mode", &MessageBuffer::continuousMode);
|
.def_readwrite("continuous_mode", &MessageBuffer::continuousMode);
|
||||||
|
|
||||||
auto controller = pybind11::class_<Controller, std::shared_ptr<Controller>>(c, "Controller")
|
auto controller = pybind11::classh<Controller>(c, "Controller")
|
||||||
.def("get_network", &Controller::getNetwork)
|
.def("get_network", &Controller::getNetwork)
|
||||||
.def("get_configuration", &Controller::getConfiguration)
|
.def("get_configuration", &Controller::getConfiguration)
|
||||||
.def("set_configuration", &Controller::setConfiguration)
|
.def("set_configuration", &Controller::setConfiguration)
|
||||||
@@ -59,11 +59,12 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||||||
.def("freeze", &Controller::freeze)
|
.def("freeze", &Controller::freeze)
|
||||||
.def("trigger_mts", &Controller::triggerMTS);
|
.def("trigger_mts", &Controller::triggerMTS);
|
||||||
|
|
||||||
pybind11::class_<Controller::Configuration>(controller, "Configuration")
|
pybind11::classh<Controller::Configuration>(controller, "Configuration")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("accept_startup_range_microticks", &Controller::Configuration::AcceptStartupRangeMicroticks)
|
.def_readwrite("accept_startup_range_microticks", &Controller::Configuration::AcceptStartupRangeMicroticks)
|
||||||
.def_readwrite("allow_passive_to_active_cycle_pairs", &Controller::Configuration::AllowPassiveToActiveCyclePairs)
|
.def_readwrite("allow_passive_to_active_cycle_pairs", &Controller::Configuration::AllowPassiveToActiveCyclePairs)
|
||||||
.def_readwrite("cluster_drift_damping", &Controller::Configuration::ClusterDriftDamping)
|
.def_readwrite("cluster_drift_damping", &Controller::Configuration::ClusterDriftDamping)
|
||||||
|
.def_readwrite("allow_halt_due_to_clock", &Controller::Configuration::AllowHaltDueToClock)
|
||||||
.def_readwrite("channel_a", &Controller::Configuration::ChannelA)
|
.def_readwrite("channel_a", &Controller::Configuration::ChannelA)
|
||||||
.def_readwrite("channel_b", &Controller::Configuration::ChannelB)
|
.def_readwrite("channel_b", &Controller::Configuration::ChannelB)
|
||||||
.def_readwrite("decoding_correction_microticks", &Controller::Configuration::DecodingCorrectionMicroticks)
|
.def_readwrite("decoding_correction_microticks", &Controller::Configuration::DecodingCorrectionMicroticks)
|
||||||
@@ -74,6 +75,7 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||||||
.def_readwrite("extern_offset_correction_microticks", &Controller::Configuration::ExternOffsetCorrectionMicroticks)
|
.def_readwrite("extern_offset_correction_microticks", &Controller::Configuration::ExternOffsetCorrectionMicroticks)
|
||||||
.def_readwrite("extern_rate_correction_microticks", &Controller::Configuration::ExternRateCorrectionMicroticks)
|
.def_readwrite("extern_rate_correction_microticks", &Controller::Configuration::ExternRateCorrectionMicroticks)
|
||||||
.def_readwrite("key_slot_id", &Controller::Configuration::KeySlotID)
|
.def_readwrite("key_slot_id", &Controller::Configuration::KeySlotID)
|
||||||
|
.def_readwrite("key_slot_only_enabled", &Controller::Configuration::KeySlotOnlyEnabled)
|
||||||
.def_readwrite("key_slot_used_for_startup", &Controller::Configuration::KeySlotUsedForStartup)
|
.def_readwrite("key_slot_used_for_startup", &Controller::Configuration::KeySlotUsedForStartup)
|
||||||
.def_readwrite("key_slot_used_for_sync", &Controller::Configuration::KeySlotUsedForSync)
|
.def_readwrite("key_slot_used_for_sync", &Controller::Configuration::KeySlotUsedForSync)
|
||||||
.def_readwrite("latest_tx_minislot", &Controller::Configuration::LatestTxMinislot)
|
.def_readwrite("latest_tx_minislot", &Controller::Configuration::LatestTxMinislot)
|
||||||
@@ -93,7 +95,7 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||||||
.def_readwrite("wakeup_on_channel_b", &Controller::Configuration::WakeupOnChannelB);
|
.def_readwrite("wakeup_on_channel_b", &Controller::Configuration::WakeupOnChannelB);
|
||||||
|
|
||||||
// Dummy class for cluster namespace
|
// Dummy class for cluster namespace
|
||||||
pybind11::class_<ClusterNamespace> cluster(c, "Cluster");
|
pybind11::classh<ClusterNamespace> cluster(c, "Cluster");
|
||||||
|
|
||||||
pybind11::enum_<Cluster::SpeedType>(cluster, "SpeedType")
|
pybind11::enum_<Cluster::SpeedType>(cluster, "SpeedType")
|
||||||
.value("FLEXRAY_BAUDRATE_10M", Cluster::SpeedType::FLEXRAY_BAUDRATE_10M)
|
.value("FLEXRAY_BAUDRATE_10M", Cluster::SpeedType::FLEXRAY_BAUDRATE_10M)
|
||||||
@@ -107,13 +109,14 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||||||
.value("FLEXRAY_SPP_6", Cluster::SPPType::FLEXRAY_SPP_6)
|
.value("FLEXRAY_SPP_6", Cluster::SPPType::FLEXRAY_SPP_6)
|
||||||
.value("FLEXRAY_SPP_5_ALT", Cluster::SPPType::FLEXRAY_SPP_5_ALT);
|
.value("FLEXRAY_SPP_5_ALT", Cluster::SPPType::FLEXRAY_SPP_5_ALT);
|
||||||
|
|
||||||
pybind11::class_<Cluster::Configuration>(cluster, "Configuration")
|
pybind11::classh<Cluster::Configuration>(cluster, "Configuration")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("speed", &Cluster::Configuration::Speed)
|
.def_readwrite("speed", &Cluster::Configuration::Speed)
|
||||||
.def_readwrite("strobe_point_position", &Cluster::Configuration::StrobePointPosition)
|
.def_readwrite("strobe_point_position", &Cluster::Configuration::StrobePointPosition)
|
||||||
.def_readwrite("action_point_offset", &Cluster::Configuration::ActionPointOffset)
|
.def_readwrite("action_point_offset", &Cluster::Configuration::ActionPointOffset)
|
||||||
.def_readwrite("casr_x_low_max", &Cluster::Configuration::CASRxLowMax)
|
.def_readwrite("casr_x_low_max", &Cluster::Configuration::CASRxLowMax)
|
||||||
.def_readwrite("cold_start_attempts", &Cluster::Configuration::ColdStartAttempts)
|
.def_readwrite("cold_start_attempts", &Cluster::Configuration::ColdStartAttempts)
|
||||||
|
.def_readwrite("cycle_duration_micro_sec", &Cluster::Configuration::CycleDurationMicroSec)
|
||||||
.def_readwrite("dynamic_slot_idle_phase_minislots", &Cluster::Configuration::DynamicSlotIdlePhaseMinislots)
|
.def_readwrite("dynamic_slot_idle_phase_minislots", &Cluster::Configuration::DynamicSlotIdlePhaseMinislots)
|
||||||
.def_readwrite("listen_noise_macroticks", &Cluster::Configuration::ListenNoiseMacroticks)
|
.def_readwrite("listen_noise_macroticks", &Cluster::Configuration::ListenNoiseMacroticks)
|
||||||
.def_readwrite("macroticks_per_cycle", &Cluster::Configuration::MacroticksPerCycle)
|
.def_readwrite("macroticks_per_cycle", &Cluster::Configuration::MacroticksPerCycle)
|
||||||
@@ -143,7 +146,7 @@ void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
|||||||
} // namespace FlexRay
|
} // namespace FlexRay
|
||||||
|
|
||||||
void init_flexraymessage(pybind11::module_& m) {
|
void init_flexraymessage(pybind11::module_& m) {
|
||||||
pybind11::class_<FlexRayMessage, std::shared_ptr<FlexRayMessage>, Frame>(m, "FlexRayMessage")
|
pybind11::classh<FlexRayMessage, Frame>(m, "FlexRayMessage")
|
||||||
.def(pybind11::init())
|
.def(pybind11::init())
|
||||||
.def_readwrite("slotid", &FlexRayMessage::slotid)
|
.def_readwrite("slotid", &FlexRayMessage::slotid)
|
||||||
.def_readwrite("tsslen", &FlexRayMessage::tsslen)
|
.def_readwrite("tsslen", &FlexRayMessage::tsslen)
|
||||||
@@ -159,14 +162,15 @@ void init_flexraymessage(pybind11::module_& m) {
|
|||||||
.def_readwrite("sync_frame", &FlexRayMessage::sync)
|
.def_readwrite("sync_frame", &FlexRayMessage::sync)
|
||||||
.def_readwrite("startup_frame", &FlexRayMessage::startup)
|
.def_readwrite("startup_frame", &FlexRayMessage::startup)
|
||||||
.def_readwrite("dynamic_frame", &FlexRayMessage::dynamic)
|
.def_readwrite("dynamic_frame", &FlexRayMessage::dynamic)
|
||||||
.def_readwrite("cycle", &FlexRayMessage::cycle);
|
.def_readwrite("cycle", &FlexRayMessage::cycle)
|
||||||
|
.def_readwrite("cycle_repetition", &FlexRayMessage::cycleRepetition);
|
||||||
|
|
||||||
//// TODO: Eliminate FlexRayControlMessage class references in controller class and eliminate getStatus function in bindings
|
//// TODO: Eliminate FlexRayControlMessage class references in controller class and eliminate getStatus function in bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_flexray(pybind11::module_& m) {
|
void init_flexray(pybind11::module_& m) {
|
||||||
// Dummy class to act as FlexRay namespace
|
// Dummy class to act as FlexRay namespace
|
||||||
pybind11::class_<FlexRayNamespace> flexray(m, "FlexRay");
|
pybind11::classh<FlexRayNamespace> flexray(m, "FlexRay");
|
||||||
|
|
||||||
pybind11::enum_<FlexRayNamespace::Symbol>(flexray, "Symbol")
|
pybind11::enum_<FlexRayNamespace::Symbol>(flexray, "Symbol")
|
||||||
.value("None", FlexRayNamespace::Symbol::None)
|
.value("None", FlexRayNamespace::Symbol::None)
|
||||||
|
|||||||
@@ -19,12 +19,15 @@ void init_ethernetmessage(pybind11::module_&);
|
|||||||
void init_linmessage(pybind11::module_&);
|
void init_linmessage(pybind11::module_&);
|
||||||
void init_tc10statusmessage(pybind11::module_&);
|
void init_tc10statusmessage(pybind11::module_&);
|
||||||
void init_gptpstatusmessage(pybind11::module_&);
|
void init_gptpstatusmessage(pybind11::module_&);
|
||||||
|
void init_allmacaddressesmessage(pybind11::module_&);
|
||||||
|
void init_apperrormessage(pybind11::module_&);
|
||||||
void init_mdiomessage(pybind11::module_&);
|
void init_mdiomessage(pybind11::module_&);
|
||||||
void init_spimessage(pybind11::module_&);
|
void init_spimessage(pybind11::module_&);
|
||||||
void init_ethernetstatusmessage(pybind11::module_&);
|
void init_ethernetstatusmessage(pybind11::module_&);
|
||||||
void init_macsecconfig(pybind11::module_&);
|
void init_macsecconfig(pybind11::module_&);
|
||||||
void init_scriptstatusmessage(pybind11::module_&);
|
void init_scriptstatusmessage(pybind11::module_&);
|
||||||
void init_diskdriver(pybind11::module_&);
|
void init_diskdriver(pybind11::module_&);
|
||||||
|
void init_diskdetails(pybind11::module_&);
|
||||||
void init_deviceextension(pybind11::module_&);
|
void init_deviceextension(pybind11::module_&);
|
||||||
void init_chipid(pybind11::module_&);
|
void init_chipid(pybind11::module_&);
|
||||||
void init_versionreport(pybind11::module_&);
|
void init_versionreport(pybind11::module_&);
|
||||||
@@ -35,6 +38,8 @@ void init_version(pybind11::module_&);
|
|||||||
void init_flexray(pybind11::module_& m);
|
void init_flexray(pybind11::module_& m);
|
||||||
void init_idevicesettings(pybind11::module_&);
|
void init_idevicesettings(pybind11::module_&);
|
||||||
void init_ethphymessage(pybind11::module_&);
|
void init_ethphymessage(pybind11::module_&);
|
||||||
|
void init_livedata(pybind11::module_&);
|
||||||
|
void init_livedatamessage(pybind11::module_&);
|
||||||
|
|
||||||
PYBIND11_MODULE(icsneopy, m) {
|
PYBIND11_MODULE(icsneopy, m) {
|
||||||
pybind11::options options;
|
pybind11::options options;
|
||||||
@@ -48,6 +53,7 @@ PYBIND11_MODULE(icsneopy, m) {
|
|||||||
init_devicetype(m);
|
init_devicetype(m);
|
||||||
init_network(m);
|
init_network(m);
|
||||||
init_io(m);
|
init_io(m);
|
||||||
|
init_livedata(m);
|
||||||
init_message(m);
|
init_message(m);
|
||||||
init_canmessage(m);
|
init_canmessage(m);
|
||||||
init_canerrormessage(m);
|
init_canerrormessage(m);
|
||||||
@@ -55,14 +61,18 @@ PYBIND11_MODULE(icsneopy, m) {
|
|||||||
init_linmessage(m);
|
init_linmessage(m);
|
||||||
init_tc10statusmessage(m);
|
init_tc10statusmessage(m);
|
||||||
init_gptpstatusmessage(m);
|
init_gptpstatusmessage(m);
|
||||||
|
init_allmacaddressesmessage(m);
|
||||||
|
init_apperrormessage(m);
|
||||||
init_mdiomessage(m);
|
init_mdiomessage(m);
|
||||||
init_ethernetstatusmessage(m);
|
init_ethernetstatusmessage(m);
|
||||||
init_macsecconfig(m);
|
init_macsecconfig(m);
|
||||||
init_scriptstatusmessage(m);
|
init_scriptstatusmessage(m);
|
||||||
init_spimessage(m);
|
init_spimessage(m);
|
||||||
|
init_livedatamessage(m);
|
||||||
init_messagefilter(m);
|
init_messagefilter(m);
|
||||||
init_messagecallback(m);
|
init_messagecallback(m);
|
||||||
init_diskdriver(m);
|
init_diskdriver(m);
|
||||||
|
init_diskdetails(m);
|
||||||
init_flexray(m);
|
init_flexray(m);
|
||||||
init_ethphymessage(m);
|
init_ethphymessage(m);
|
||||||
init_chipid(m);
|
init_chipid(m);
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DLIBICSNEO_BUILD_EXAMPLES=ON \
|
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DLIBICSNEO_BUILD_EXAMPLES=ON -DLIBICSNEO_BUILD_UNIT_TESTS=ON -DLIBICSNEO_ENABLE_TCP=OFF || exit 1
|
||||||
-DLIBICSNEO_BUILD_UNIT_TESTS=ON -DLIBICSNEO_ENABLE_TCP=OFF || exit 1
|
|
||||||
|
|
||||||
cmake --build build || exit 1
|
cmake --build build || exit 1
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
mkdir build >nul 2>&1
|
mkdir build >nul 2>&1
|
||||||
|
|
||||||
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DLIBICSNEO_BUILD_UNIT_TESTS=ON ^
|
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DLIBICSNEO_BUILD_UNIT_TESTS=ON-DLIBICSNEO_ENABLE_TCP=ON || exit /b 1
|
||||||
-DLIBICSNEO_ENABLE_TCP=ON || exit /b 1
|
|
||||||
|
|
||||||
cmake --build build || exit /b 1
|
cmake --build build || exit /b 1
|
||||||
|
|||||||
@@ -21,10 +21,15 @@
|
|||||||
#include "icsneo/communication/message/hardwareinfo.h"
|
#include "icsneo/communication/message/hardwareinfo.h"
|
||||||
#include "icsneo/communication/message/tc10statusmessage.h"
|
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||||
#include "icsneo/communication/message/gptpstatusmessage.h"
|
#include "icsneo/communication/message/gptpstatusmessage.h"
|
||||||
|
#include "icsneo/communication/message/allmacaddressesmessage.h"
|
||||||
#include "icsneo/communication/message/apperrormessage.h"
|
#include "icsneo/communication/message/apperrormessage.h"
|
||||||
#include "icsneo/communication/message/ethernetstatusmessage.h"
|
#include "icsneo/communication/message/ethernetstatusmessage.h"
|
||||||
#include "icsneo/communication/message/networkmutexmessage.h"
|
#include "icsneo/communication/message/networkmutexmessage.h"
|
||||||
#include "icsneo/communication/message/clientidmessage.h"
|
#include "icsneo/communication/message/clientidmessage.h"
|
||||||
|
#include "icsneo/communication/message/mfgconfigmessage.h"
|
||||||
|
#include "icsneo/communication/message/spiportkeymessage.h"
|
||||||
|
#include "icsneo/communication/message/genericapidatamessage.h"
|
||||||
|
#include "icsneo/communication/message/genericapistatusmessage.h"
|
||||||
#include "icsneo/communication/command.h"
|
#include "icsneo/communication/command.h"
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/communication/packet/canpacket.h"
|
#include "icsneo/communication/packet/canpacket.h"
|
||||||
@@ -39,6 +44,7 @@
|
|||||||
#include "icsneo/communication/packet/i2cpacket.h"
|
#include "icsneo/communication/packet/i2cpacket.h"
|
||||||
#include "icsneo/communication/packet/scriptstatuspacket.h"
|
#include "icsneo/communication/packet/scriptstatuspacket.h"
|
||||||
#include "icsneo/communication/packet/linpacket.h"
|
#include "icsneo/communication/packet/linpacket.h"
|
||||||
|
#include "icsneo/communication/message/iso15765message.h"
|
||||||
#include "icsneo/communication/packet/componentversionpacket.h"
|
#include "icsneo/communication/packet/componentversionpacket.h"
|
||||||
#include "icsneo/communication/packet/supportedfeaturespacket.h"
|
#include "icsneo/communication/packet/supportedfeaturespacket.h"
|
||||||
#include "icsneo/communication/packet/mdiopacket.h"
|
#include "icsneo/communication/packet/mdiopacket.h"
|
||||||
@@ -326,19 +332,35 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
case ExtendedCommand::GenericBinaryInfo:
|
case ExtendedCommand::GenericBinaryInfo:
|
||||||
result = GenericBinaryStatusPacket::DecodeToMessage(packet->data);
|
result = GenericBinaryStatusPacket::DecodeToMessage(packet->data);
|
||||||
return true;
|
return true;
|
||||||
|
case ExtendedCommand::SoftwareUpdate: {
|
||||||
|
result = std::make_shared<ExtendedResponseMessage>(ExtendedCommand::SoftwareUpdate, ExtendedResponse::OperationPending, packet->data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case ExtendedCommand::GenericReturn: {
|
case ExtendedCommand::GenericReturn: {
|
||||||
if(packet->data.size() < sizeof(ExtendedResponseMessage::PackedGenericResponse))
|
if(packet->data.size() < sizeof(ExtendedResponseMessage::PackedGenericResponse))
|
||||||
break;
|
break;
|
||||||
const auto& packedResp = *reinterpret_cast<ExtendedResponseMessage::PackedGenericResponse*>(packet->data.data());
|
const auto& packedResp = *reinterpret_cast<ExtendedResponseMessage::PackedGenericResponse*>(packet->data.data());
|
||||||
result = std::make_shared<ExtendedResponseMessage>(packedResp.command, packedResp.returnCode);
|
result = std::make_shared<ExtendedResponseMessage>(packedResp.command, packedResp.returnCode, packet->data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case ExtendedCommand::LiveData:
|
case ExtendedCommand::LiveData:
|
||||||
result = HardwareLiveDataPacket::DecodeToMessage(packet->data, report);
|
result = HardwareLiveDataPacket::DecodeToMessage(packet->data, report);
|
||||||
return true;
|
return true;
|
||||||
|
case ExtendedCommand::ExecuteSPIPortKeyOperation:
|
||||||
|
result = SPIPortKeyMessage::DecodeToMessage(packet->data);
|
||||||
|
return true;
|
||||||
|
case ExtendedCommand::ReadGenericAPIData:
|
||||||
|
result = GenericAPIDataMessage::DecodeToMessage(packet->data);
|
||||||
|
return true;
|
||||||
|
case ExtendedCommand::ReadGenericAPIStatus:
|
||||||
|
result = GenericAPIStatusMessage::DecodeToMessage(packet->data);
|
||||||
|
return true;
|
||||||
case ExtendedCommand::GetTC10Status:
|
case ExtendedCommand::GetTC10Status:
|
||||||
result = TC10StatusMessage::DecodeToMessage(packet->data);
|
result = TC10StatusMessage::DecodeToMessage(packet->data);
|
||||||
return true;
|
return true;
|
||||||
|
case ExtendedCommand::GetAllMACAddresses:
|
||||||
|
result = AllMACAddressesMessage::DecodeToMessage(packet->data);
|
||||||
|
return true;
|
||||||
case ExtendedCommand::GetGPTPStatus: {
|
case ExtendedCommand::GetGPTPStatus: {
|
||||||
result = GPTPStatus::DecodeToMessage(packet->data, report);
|
result = GPTPStatus::DecodeToMessage(packet->data, report);
|
||||||
return true;
|
return true;
|
||||||
@@ -351,6 +373,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
);
|
);
|
||||||
protoapi::Id protoId = protoapi::getProtoId(responseBody.data(), responseBody.size());
|
protoapi::Id protoId = protoapi::getProtoId(responseBody.data(), responseBody.size());
|
||||||
switch(protoId) {
|
switch(protoId) {
|
||||||
|
case protoapi::Id::MfgConfig:
|
||||||
|
result = MfgConfigMessage::DecodeToMessage(responseBody);
|
||||||
|
return true;
|
||||||
case protoapi::Id::NetworkMutex:
|
case protoapi::Id::NetworkMutex:
|
||||||
result = NetworkMutexMessage::DecodeToMessage(responseBody);
|
result = NetworkMutexMessage::DecodeToMessage(responseBody);
|
||||||
return true;
|
return true;
|
||||||
@@ -455,6 +480,14 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case Command::J2534Command: {
|
||||||
|
result = J2534CommandMessage::decodeToMessage(packet->data);
|
||||||
|
if(!result) {
|
||||||
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
auto msg = std::make_shared<Main51Message>();
|
auto msg = std::make_shared<Main51Message>();
|
||||||
msg->command = Command(packet->data[0]);
|
msg->command = Command(packet->data[0]);
|
||||||
@@ -555,6 +588,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the moment other types of messages will automatically be decoded as raw messages
|
// For the moment other types of messages will automatically be decoded as raw messages
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Network::Type::Internal:
|
||||||
case Network::Type::CAN:
|
case Network::Type::CAN:
|
||||||
case Network::Type::SWCAN:
|
case Network::Type::SWCAN:
|
||||||
case Network::Type::LSFTCAN: {
|
case Network::Type::LSFTCAN: {
|
||||||
@@ -233,7 +234,9 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
|||||||
result = packetizer.packetWrap(result, false);
|
result = packetizer.packetWrap(result, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
default:
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return false; // The message was not a properly formed Message
|
||||||
}
|
}
|
||||||
|
|
||||||
// Early returns may mean we don't reach this far, check the type you're concerned with
|
// Early returns may mean we don't reach this far, check the type you're concerned with
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ double liveDataValueToDouble(const LiveDataValue& val) {
|
|||||||
return val.value * liveDataFixedPointToDouble;
|
return val.value * liveDataFixedPointToDouble;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool liveDataDoubleToValue(const double& dFloat, LiveDataValue& value) {
|
std::optional<LiveDataValue> liveDataDoubleToValue(const double& dFloat) {
|
||||||
|
LiveDataValue value;
|
||||||
union {
|
union {
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@@ -56,23 +57,23 @@ bool liveDataDoubleToValue(const double& dFloat, LiveDataValue& value) {
|
|||||||
value.value = CminiFixedPt.ValueLarge;
|
value.value = CminiFixedPt.ValueLarge;
|
||||||
|
|
||||||
if(dFloat == (double)0.0)
|
if(dFloat == (double)0.0)
|
||||||
return true;
|
return value;
|
||||||
|
|
||||||
//check if double can be stored as 32.32
|
//check if double can be stored as 32.32
|
||||||
// 0x1 0000 0000 0000 0000 * CM_FIXED_POINT_TO_DOUBLEVALUE = 0x1 0000 0000
|
// 0x1 0000 0000 0000 0000 * CM_FIXED_POINT_TO_DOUBLEVALUE = 0x1 0000 0000
|
||||||
if(dFloat > INT32_MAX_DOUBLE || dFloat < INT32_MIN_DOUBLE) {
|
if(dFloat > INT32_MAX_DOUBLE || dFloat < INT32_MIN_DOUBLE) {
|
||||||
EventManager::GetInstance().add(APIEvent::Type::FixedPointOverflow, APIEvent::Severity::Error);
|
EventManager::GetInstance().add(APIEvent::Type::FixedPointOverflow, APIEvent::Severity::Error);
|
||||||
return false;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use absolute value for minimum fixed point check
|
// Use absolute value for minimum fixed point check
|
||||||
double absFloat = (dFloat < 0.0) ? -dFloat : dFloat;
|
double absFloat = (dFloat < 0.0) ? -dFloat : dFloat;
|
||||||
if(absFloat < MIN_FIXED_POINT_DOUBLE) {
|
if(absFloat < MIN_FIXED_POINT_DOUBLE) {
|
||||||
EventManager::GetInstance().add(APIEvent::Type::FixedPointPrecision, APIEvent::Severity::Error);
|
EventManager::GetInstance().add(APIEvent::Type::FixedPointPrecision, APIEvent::Severity::Error);
|
||||||
return false;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace LiveDataUtil
|
} // namespace LiveDataUtil
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ void A2BMessage::setChannelSample(Direction dir, uint8_t channel, size_t frame,
|
|||||||
case PCMType::L24:
|
case PCMType::L24:
|
||||||
sampleToSet = sampleToSet << 8;
|
sampleToSet = sampleToSet << 8;
|
||||||
break;
|
break;
|
||||||
|
case PCMType::L32:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(channelSize16) {
|
if(channelSize16) {
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#include "icsneo/communication/message/allmacaddressesmessage.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
#include "icsneo/communication/network.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
struct ResponseHeader {
|
||||||
|
ExtendedCommand command;
|
||||||
|
uint16_t length;
|
||||||
|
uint16_t count;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MacAddrEntryPacket {
|
||||||
|
uint16_t networkId;
|
||||||
|
uint8_t address[MACAddressLength];
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
std::shared_ptr<AllMACAddressesMessage> AllMACAddressesMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
if(bytestream.size() < sizeof(ResponseHeader))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const auto* hdr = reinterpret_cast<const ResponseHeader*>(bytestream.data());
|
||||||
|
|
||||||
|
if(hdr->command != ExtendedCommand::GetAllMACAddresses)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if(hdr->count > MaxMACAddressCount)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const size_t required = sizeof(ResponseHeader) + hdr->count * sizeof(MacAddrEntryPacket);
|
||||||
|
if(bytestream.size() < required)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto msg = std::make_shared<AllMACAddressesMessage>();
|
||||||
|
|
||||||
|
const auto* entries = reinterpret_cast<const MacAddrEntryPacket*>(bytestream.data() + sizeof(ResponseHeader));
|
||||||
|
for(uint16_t i = 0; i < hdr->count; ++i) {
|
||||||
|
// The firmware sends CoreMini network IDs — convert to NetID for consistent use in libicsneo
|
||||||
|
Network::NetID netId = Network::GetNetIDFromCoreMiniNetwork(static_cast<Network::CoreMini>(entries[i].networkId));
|
||||||
|
auto addr = entries[i].address;
|
||||||
|
MACAddress arrAddr;
|
||||||
|
std::copy(addr, addr + MACAddressLength, arrAddr.begin());
|
||||||
|
msg->addresses.emplace(std::make_pair(netId, arrAddr));
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ struct Packet {
|
|||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
std::shared_ptr<Message> EthernetStatusMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
std::shared_ptr<RawMessage> EthernetStatusMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
if(bytestream.size() < sizeof(Packet)) {
|
if(bytestream.size() < sizeof(Packet)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -76,5 +76,5 @@ std::shared_ptr<Message> EthernetStatusMessage::DecodeToMessage(const std::vecto
|
|||||||
break;
|
break;
|
||||||
default: return nullptr;
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
return std::make_shared<EthernetStatusMessage>(packet->network, packet->state, speed, packet->duplex, mode);
|
return std::make_shared<EthernetStatusMessage>(packet->network, packet->state != 0, speed, packet->duplex != 0, mode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
|
|||||||
|
|
||||||
bool EthPhyMessage::appendPhyMessage(std::shared_ptr<PhyMessage> message)
|
bool EthPhyMessage::appendPhyMessage(std::shared_ptr<PhyMessage> message)
|
||||||
{
|
{
|
||||||
if(message != nullptr)
|
if(message)
|
||||||
{
|
{
|
||||||
messages.push_back(message);
|
messages.push_back(message);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#include "icsneo/communication/message/genericapidatamessage.h"
|
||||||
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<GenericAPIDataMessage> GenericAPIDataMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
if(bytestream.size() < sizeof(ExtendedResponseMessage::ResponseHeader))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const auto* hdr = reinterpret_cast<const ExtendedResponseMessage::ResponseHeader*>(bytestream.data());
|
||||||
|
|
||||||
|
if(hdr->command != ExtendedCommand::ReadGenericAPIData)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const size_t required = sizeof(ExtendedResponseMessage::ResponseHeader) + sizeof(GenericAPIDataHeader);
|
||||||
|
if(bytestream.size() < required)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto msg = std::make_shared<GenericAPIDataMessage>();
|
||||||
|
|
||||||
|
const auto* packet = reinterpret_cast<const GenericAPIDataPacket*>(bytestream.data() + sizeof(ExtendedResponseMessage::ResponseHeader));
|
||||||
|
|
||||||
|
msg->functionId = packet->header.functionId;
|
||||||
|
msg->buffer.resize(packet->header.bufferLength);
|
||||||
|
std::copy(packet->buffer, packet->buffer + packet->header.bufferLength, msg->buffer.data());
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#include "icsneo/communication/message/genericapistatusmessage.h"
|
||||||
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<GenericAPIStatusMessage> GenericAPIStatusMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
if(bytestream.size() < sizeof(ExtendedResponseMessage::ResponseHeader))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const auto* hdr = reinterpret_cast<const ExtendedResponseMessage::ResponseHeader*>(bytestream.data());
|
||||||
|
|
||||||
|
if(hdr->command != ExtendedCommand::ReadGenericAPIStatus)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const size_t required = sizeof(ExtendedResponseMessage::ResponseHeader) + sizeof(GenericAPIStatusResponsePacket);
|
||||||
|
if(bytestream.size() < required)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto msg = std::make_shared<GenericAPIStatusMessage>();
|
||||||
|
|
||||||
|
const auto* packet = reinterpret_cast<const GenericAPIStatusResponsePacket*>(bytestream.data() + sizeof(ExtendedResponseMessage::ResponseHeader));
|
||||||
|
|
||||||
|
msg->functionId = packet->functionId;
|
||||||
|
msg->finishedProcessing = static_cast<bool>(packet->finishedProcessing);
|
||||||
|
msg->functionError = packet->functionError;
|
||||||
|
msg->callbackError = packet->callbackError;
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
@@ -0,0 +1,337 @@
|
|||||||
|
#include "icsneo/communication/message/iso15765message.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<J2534CommandMessage> J2534CommandMessage::decodeToMessage(const std::vector<uint8_t>& data) {
|
||||||
|
if(data.size() < 2)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto msg = std::make_shared<J2534CommandMessage>((J2534Command)data[1]);
|
||||||
|
if(data.size() > 2)
|
||||||
|
msg->setArgumentData(std::vector<uint8_t>(data.begin() + 2, data.end()));
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t J2534CommandMessage::read16LE(size_t o) const {
|
||||||
|
return (uint16_t)((uint16_t)argumentData[o] | ((uint16_t)argumentData[o + 1] << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534CommandMessage::write16LE(size_t o, uint16_t v) {
|
||||||
|
argumentData[o] = (uint8_t)(v & 0xFF);
|
||||||
|
argumentData[o + 1] = (uint8_t)((v >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t J2534CommandMessage::read16BE(size_t o) const {
|
||||||
|
return (uint16_t)(((uint16_t)argumentData[o] << 8) | argumentData[o + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534CommandMessage::write16BE(size_t o, uint16_t v) {
|
||||||
|
argumentData[o] = (uint8_t)((v >> 8) & 0xFF);
|
||||||
|
argumentData[o + 1] = (uint8_t)(v & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534CommandMessage::writeBits16LE(size_t o, unsigned bitPos, unsigned bitCount, uint32_t value) {
|
||||||
|
const uint16_t mask = (uint16_t)(((1u << bitCount) - 1u) << bitPos);
|
||||||
|
uint16_t word = read16LE(o);
|
||||||
|
word = (uint16_t)((word & ~mask) | (((value << bitPos) & mask)));
|
||||||
|
write16LE(o, word);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t J2534CommandMessage::read32LE(size_t o) const {
|
||||||
|
return (uint32_t)argumentData[o]
|
||||||
|
| ((uint32_t)argumentData[o + 1] << 8)
|
||||||
|
| ((uint32_t)argumentData[o + 2] << 16)
|
||||||
|
| ((uint32_t)argumentData[o + 3] << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534CommandMessage::write32LE(size_t o, uint32_t v) {
|
||||||
|
argumentData[o] = (uint8_t)(v & 0xFF);
|
||||||
|
argumentData[o + 1] = (uint8_t)((v >> 8) & 0xFF);
|
||||||
|
argumentData[o + 2] = (uint8_t)((v >> 16) & 0xFF);
|
||||||
|
argumentData[o + 3] = (uint8_t)((v >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t J2534CommandMessage::read32BE(size_t o) const {
|
||||||
|
return ((uint32_t)argumentData[o] << 24) | ((uint32_t)argumentData[o + 1] << 16)
|
||||||
|
| ((uint32_t)argumentData[o + 2] << 8) | (uint32_t)argumentData[o + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534CommandMessage::write32BE(size_t o, uint32_t v) {
|
||||||
|
argumentData[o] = (uint8_t)((v >> 24) & 0xFF);
|
||||||
|
argumentData[o + 1] = (uint8_t)((v >> 16) & 0xFF);
|
||||||
|
argumentData[o + 2] = (uint8_t)((v >> 8) & 0xFF);
|
||||||
|
argumentData[o + 3] = (uint8_t)(v & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
J2534_RxCanFilter J2534SetupCanRxFilteringMessage::getRxCanFilter() const {
|
||||||
|
constexpr size_t filterSize = sizeof(J2534_RxCanFilter::fb);
|
||||||
|
J2534_RxCanFilter filter = {};
|
||||||
|
if(argumentData.size() >= (10 + filterSize))
|
||||||
|
{
|
||||||
|
filter.idx = (argumentData[2] << 8) | argumentData[3];
|
||||||
|
filter.enabled = (argumentData[4] << 8) | argumentData[5];
|
||||||
|
filter.filterCount = (argumentData[6] << 8) | argumentData[7];
|
||||||
|
filter.fb = *((MessageFilterBytes*)(argumentData.data() + 8));
|
||||||
|
filter.networkId = (argumentData[8 + filterSize] << 8) | argumentData[9 + filterSize];
|
||||||
|
}
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534SetupCanRxFilteringMessage::setRxCanFilter(const J2534_RxCanFilter& filter) {
|
||||||
|
argumentData.resize(10 + sizeof(filter.fb));
|
||||||
|
argumentData[2] = (filter.idx >> 8) & 0xFF;
|
||||||
|
argumentData[3] = filter.idx & 0xFF;
|
||||||
|
argumentData[4] = (filter.enabled >> 8) & 0xFF;
|
||||||
|
argumentData[5] = filter.enabled & 0xFF;
|
||||||
|
argumentData[6] = (filter.filterCount >> 8) & 0xFF;
|
||||||
|
argumentData[7] = filter.filterCount & 0xFF;
|
||||||
|
*((MessageFilterBytes*)(argumentData.data() + 8)) = filter.fb;
|
||||||
|
argumentData[8 + sizeof(filter.fb)] = (filter.networkId >> 8) & 0xFF;
|
||||||
|
argumentData[9 + sizeof(filter.fb)] = filter.networkId & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
J2534SetupIso15765FlowControlMessage::J2534SetupIso15765FlowControlMessage()
|
||||||
|
: J2534CommandMessage(J2534Command::SetupIso15765RxFilter) {
|
||||||
|
argumentData.resize(MessageSize);
|
||||||
|
// Bytes [0..1] were populated by the base constructor. Everything else starts at zero
|
||||||
|
// (matches the previous behavior which zeroed the flt region and left the rest of the
|
||||||
|
// caller-supplied struct as-is; typical callers value-initialized their struct too).
|
||||||
|
for(size_t i = 2; i < MessageSize; ++i)
|
||||||
|
argumentData[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2534SetupIso15765FlowControlMessage::rebuildFilterBytes(void) {
|
||||||
|
// Zero the 28-byte flt region.
|
||||||
|
for(size_t i = 0; i < FltSize; ++i)
|
||||||
|
argumentData[FltOffset + i] = 0;
|
||||||
|
|
||||||
|
const uint32_t id = read32LE(IdOffset);
|
||||||
|
const uint32_t idMask = read32LE(IdMaskOffset);
|
||||||
|
const bool is29Bit = getFlagBit(FlagId29BitEnable);
|
||||||
|
const bool extAddr = getFlagBit(FlagExtAddressEnable);
|
||||||
|
const uint8_t extAddrByte = argumentData[ExtAddrOffset];
|
||||||
|
|
||||||
|
// CoreMiniMessageFilterBytes has an interleaved layout:
|
||||||
|
// uiFilterMask0 at flt+0, uiFilterID0 at flt+2
|
||||||
|
// uiFilterMask1 at flt+4, uiFilterID1 at flt+6
|
||||||
|
// uiFilterMask2 at flt+8, uiFilterID2 at flt+10
|
||||||
|
// datalink.uiFilterMask3 at flt+12, datalink.uiFilterID3 at flt+14
|
||||||
|
//
|
||||||
|
// CoreMiniMsgBitsCAN bit layout within each 16-bit unit:
|
||||||
|
// unit0: IDE(bit0), SRR(bit1), SID(bits2-12), NETWORKINDEX(bits13-15)
|
||||||
|
// unit1: EID(bits0-11), TXMSG(bit12), ...
|
||||||
|
// unit2: DLC(bits0-3), ..., RTR(bit9), EID2(bits10-15)
|
||||||
|
const size_t MaskUnit0 = FltOffset + 0;
|
||||||
|
const size_t MaskUnit1 = FltOffset + 4;
|
||||||
|
const size_t MaskUnit2 = FltOffset + 8;
|
||||||
|
const size_t ValueUnit0 = FltOffset + 2;
|
||||||
|
const size_t ValueUnit1 = FltOffset + 6;
|
||||||
|
const size_t ValueUnit2 = FltOffset + 10;
|
||||||
|
|
||||||
|
// filter arbid: pMask->IDE = 1
|
||||||
|
writeBits16LE(MaskUnit0, /*bit*/0, /*width*/1, 1);
|
||||||
|
|
||||||
|
if(is29Bit) {
|
||||||
|
// pValue->IDE = 1; pValue->SID = (id >> 18) & 0x7FF
|
||||||
|
writeBits16LE(ValueUnit0, 0, 1, 1);
|
||||||
|
writeBits16LE(ValueUnit0, 2, 11, (id >> 18) & 0x7FF);
|
||||||
|
// pValue->EID = (id >> 6) & 0xFFF
|
||||||
|
writeBits16LE(ValueUnit1, 0, 12, (id >> 6) & 0xFFF);
|
||||||
|
// pValue->EID2 = id & 0x3F
|
||||||
|
writeBits16LE(ValueUnit2, 10, 6, id & 0x3F);
|
||||||
|
// pMask->SID = (id_mask >> 18) & 0x7FF
|
||||||
|
writeBits16LE(MaskUnit0, 2, 11, (idMask >> 18) & 0x7FF);
|
||||||
|
// pMask->EID = (id_mask >> 6) & 0xFFF (overlaps pValue->{IDE,SID} storage)
|
||||||
|
writeBits16LE(MaskUnit1, 0, 12, (idMask >> 6) & 0xFFF);
|
||||||
|
// pMask->EID2 = id_mask & 0x3F (overlaps pValue->EID storage)
|
||||||
|
writeBits16LE(MaskUnit2, 10, 6, idMask & 0x3F);
|
||||||
|
} else {
|
||||||
|
// pValue->IDE = 0 (already zero); pValue->SID = id
|
||||||
|
writeBits16LE(ValueUnit0, 2, 11, id & 0x7FF);
|
||||||
|
// pMask->SID = id_mask
|
||||||
|
writeBits16LE(MaskUnit0, 2, 11, idMask & 0x7FF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extended-address filter: writes into the datalink.uiFilterID3 / uiFilterMask3 bytes.
|
||||||
|
// uiFilterMask3 = flt[12..13] = wire[37..38]
|
||||||
|
// uiFilterID3 = flt[14..15] = wire[39..40]
|
||||||
|
if(extAddr) {
|
||||||
|
const size_t kValueBytes = FltOffset + 14; // uiFilterID3
|
||||||
|
const size_t kMaskBytes = FltOffset + 12; // uiFilterMask3
|
||||||
|
argumentData[kValueBytes + 0] = extAddrByte;
|
||||||
|
argumentData[kMaskBytes + 0] = 0xFF;
|
||||||
|
argumentData[kValueBytes + 1] = 0;
|
||||||
|
argumentData[kMaskBytes + 1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t J2534SetupIso15765FlowControlMessage::getIdx(void) const { return read16LE(IdxOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setIdx(uint16_t idx) { write16LE(IdxOffset, idx); }
|
||||||
|
|
||||||
|
uint16_t J2534SetupIso15765FlowControlMessage::getCoreMiniId(void) const { return read16LE(CoreMiniOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setCoreMiniId(uint16_t coreMiniId) { write16LE(CoreMiniOffset, coreMiniId); }
|
||||||
|
|
||||||
|
uint8_t J2534SetupIso15765FlowControlMessage::getPadding(void) const { return argumentData[PaddingOffset]; }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setPadding(uint8_t padding) { argumentData[PaddingOffset] = padding; }
|
||||||
|
|
||||||
|
uint32_t J2534SetupIso15765FlowControlMessage::getId(void) const { return read32LE(IdOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setId(uint32_t id) { write32LE(IdOffset, id); rebuildFilterBytes(); }
|
||||||
|
|
||||||
|
uint32_t J2534SetupIso15765FlowControlMessage::getIdMask(void) const { return read32LE(IdMaskOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setIdMask(uint32_t idMask) { write32LE(IdMaskOffset, idMask); rebuildFilterBytes(); }
|
||||||
|
|
||||||
|
uint32_t J2534SetupIso15765FlowControlMessage::getFcId(void) const { return read32LE(FcIdOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setFcId(uint32_t fcId) { write32LE(FcIdOffset, fcId); }
|
||||||
|
|
||||||
|
uint8_t J2534SetupIso15765FlowControlMessage::getFlowControlExtendedAddress(void) const { return argumentData[FcExtAddrOffset]; }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setFlowControlExtendedAddress(uint8_t addr) { argumentData[FcExtAddrOffset] = addr; }
|
||||||
|
|
||||||
|
uint8_t J2534SetupIso15765FlowControlMessage::getExtendedAddress(void) const { return argumentData[ExtAddrOffset]; }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setExtendedAddress(uint8_t addr) { argumentData[ExtAddrOffset] = addr; rebuildFilterBytes(); }
|
||||||
|
|
||||||
|
uint8_t J2534SetupIso15765FlowControlMessage::getBlockSize(void) const { return argumentData[BlockSizeOffset]; }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setBlockSize(uint8_t blockSize) { argumentData[BlockSizeOffset] = blockSize; }
|
||||||
|
|
||||||
|
uint8_t J2534SetupIso15765FlowControlMessage::getStMin(void) const { return argumentData[StMinOffset]; }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setStMin(uint8_t stMin) { argumentData[StMinOffset] = stMin; }
|
||||||
|
|
||||||
|
uint16_t J2534SetupIso15765FlowControlMessage::getCfTimeout(void) const { return read16LE(CfTimeoutOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setCfTimeout(uint16_t cfTimeout) { write16LE(CfTimeoutOffset, cfTimeout); }
|
||||||
|
|
||||||
|
uint32_t J2534SetupIso15765FlowControlMessage::getFlags(void) const { return read32LE(FlagsOffset); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setFlags(uint32_t flags) { write32LE(FlagsOffset, flags); rebuildFilterBytes(); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getEnable(void) const { return getFlagBit(FlagEnable); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setEnable(bool enable) { setFlagBit(FlagEnable, enable); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getIs29BitEnabled(void) const { return getFlagBit(FlagId29BitEnable); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setIs29BitEnabled(bool enable) { setFlagBit(FlagId29BitEnable, enable); rebuildFilterBytes(); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getIsFc29BitEnabled(void) const { return getFlagBit(FlagFcId29BitEnable); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setIsFc29BitEnabled(bool enable) { setFlagBit(FlagFcId29BitEnable, enable); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getExtAddressEnabled(void) const { return getFlagBit(FlagExtAddressEnable); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setExtAddressEnabled(bool enable) { setFlagBit(FlagExtAddressEnable, enable); rebuildFilterBytes(); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getFcExtAddressEnabled(void) const { return getFlagBit(FlagFcExtAddressEnable); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setFcExtAddressEnabled(bool enable) { setFlagBit(FlagFcExtAddressEnable, enable); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getFlowControlTransmissionEnabled(void) const { return getFlagBit(FlagEnableFlowControlTransmit); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setFlowControlTransmissionEnabled(bool enable) { setFlagBit(FlagEnableFlowControlTransmit, enable); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getPaddingEnabled(void) const { return getFlagBit(FlagPaddingEnable); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setPaddingEnabled(bool enable) { setFlagBit(FlagPaddingEnable, enable); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getIsCanFd(void) const { return getFlagBit(FlagIsCanFd); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setIsCanFd(bool enable) { setFlagBit(FlagIsCanFd, enable); }
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getIsBrsEnabled(void) const { return getFlagBit(FlagIsBrsEnabled); }
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setIsBrsEnabled(bool enable) { setFlagBit(FlagIsBrsEnabled, enable); }
|
||||||
|
|
||||||
|
void J2534SetupIso15765FlowControlMessage::setFlagBit(uint32_t mask, bool enable) {
|
||||||
|
uint32_t f = read32LE(FlagsOffset);
|
||||||
|
if(enable) f |= mask;
|
||||||
|
else f &= ~mask;
|
||||||
|
write32LE(FlagsOffset, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool J2534SetupIso15765FlowControlMessage::getFlagBit(uint32_t mask) const {
|
||||||
|
return (read32LE(FlagsOffset) & mask) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t Iso15765TxSetupMessage::getIdx(void) const { return read16LE(SetupIdxOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setIdx(uint16_t idx) { write16LE(SetupIdxOffset, idx); }
|
||||||
|
|
||||||
|
uint16_t Iso15765TxSetupMessage::getCoreMiniId(void) const { return read16LE(SetupCoreMiniOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setCoreMiniId(uint16_t coreMiniId) { write16LE(SetupCoreMiniOffset, coreMiniId); }
|
||||||
|
|
||||||
|
uint32_t Iso15765TxSetupMessage::getMessageLength(void) const { return read32LE(SetupMsgLenOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setMessageLength(uint32_t messageLength) { write32LE(SetupMsgLenOffset, messageLength); }
|
||||||
|
|
||||||
|
uint8_t Iso15765TxSetupMessage::getPadding(void) const { return argumentData[SetupPaddingOffset]; }
|
||||||
|
void Iso15765TxSetupMessage::setPadding(uint8_t padding) { argumentData[SetupPaddingOffset] = padding; }
|
||||||
|
|
||||||
|
uint8_t Iso15765TxSetupMessage::getTxDl(void) const { return argumentData[SetupTxDlOffset]; }
|
||||||
|
void Iso15765TxSetupMessage::setTxDl(uint8_t txDl) { argumentData[SetupTxDlOffset] = txDl; }
|
||||||
|
|
||||||
|
uint32_t Iso15765TxSetupMessage::getId(void) const { return read32LE(SetupIdOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setId(uint32_t id) { write32LE(SetupIdOffset, id); }
|
||||||
|
|
||||||
|
uint32_t Iso15765TxSetupMessage::getFcId(void) const { return read32LE(SetupFcIdOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setFcId(uint32_t fcId) { write32LE(SetupFcIdOffset, fcId); }
|
||||||
|
|
||||||
|
uint32_t Iso15765TxSetupMessage::getFcIdMask(void) const { return read32LE(SetupFcIdMaskOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setFcIdMask(uint32_t fcIdMask) { write32LE(SetupFcIdMaskOffset, fcIdMask); }
|
||||||
|
|
||||||
|
uint8_t Iso15765TxSetupMessage::getFlowControlExtendedAddress(void) const { return argumentData[SetupFcExtAddrOffset]; }
|
||||||
|
void Iso15765TxSetupMessage::setFlowControlExtendedAddress(uint8_t addr) { argumentData[SetupFcExtAddrOffset] = addr; }
|
||||||
|
|
||||||
|
uint8_t Iso15765TxSetupMessage::getExtendedAddress(void) const { return argumentData[SetupExtAddrOffset]; }
|
||||||
|
void Iso15765TxSetupMessage::setExtendedAddress(uint8_t addr) { argumentData[SetupExtAddrOffset] = addr; }
|
||||||
|
|
||||||
|
uint16_t Iso15765TxSetupMessage::getFsTimeout(void) const { return read16LE(SetupFsTimeoutOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setFsTimeout(uint16_t timeout) { write16LE(SetupFsTimeoutOffset, timeout); }
|
||||||
|
|
||||||
|
uint16_t Iso15765TxSetupMessage::getFsWait(void) const { return read16LE(SetupFsWaitOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setFsWait(uint16_t wait) { write16LE(SetupFsWaitOffset, wait); }
|
||||||
|
|
||||||
|
uint32_t Iso15765TxSetupMessage::getFlags(void) const { return read32LE(SetupFlagsOffset); }
|
||||||
|
void Iso15765TxSetupMessage::setFlags(uint32_t flags) { write32LE(SetupFlagsOffset, flags); }
|
||||||
|
|
||||||
|
uint8_t Iso15765TxSetupMessage::getStMin(void) const { return argumentData[SetupStMinOffset]; }
|
||||||
|
void Iso15765TxSetupMessage::setStMin(uint8_t stMin) { argumentData[SetupStMinOffset] = stMin; }
|
||||||
|
|
||||||
|
uint8_t Iso15765TxSetupMessage::getBlockSize(void) const { return argumentData[SetupBlockSizeOffset]; }
|
||||||
|
void Iso15765TxSetupMessage::setBlockSize(uint8_t blockSize) { argumentData[SetupBlockSizeOffset] = blockSize; }
|
||||||
|
|
||||||
|
bool Iso15765TxSetupMessage::getIs29BitEnabled(void) const { return getFlagBit(FlagId29BitEnable); }
|
||||||
|
void Iso15765TxSetupMessage::setIs29BitEnabled(bool enable) { setFlagBit(FlagId29BitEnable, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getIsFc29BitEnabled(void) const { return getFlagBit(FlagFcId29BitEnable); }
|
||||||
|
void Iso15765TxSetupMessage::setIsFc29BitEnabled(bool enable) { setFlagBit(FlagFcId29BitEnable, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getExtAddressEnabled(void) const { return getFlagBit(FlagExtAddressEnable); }
|
||||||
|
void Iso15765TxSetupMessage::setExtAddressEnabled(bool enable) { setFlagBit(FlagExtAddressEnable, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getFcExtAddressEnabled(void) const { return getFlagBit(FlagFcExtAddressEnable); }
|
||||||
|
void Iso15765TxSetupMessage::setFcExtAddressEnabled(bool enable) { setFlagBit(FlagFcExtAddressEnable, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getOverrideStMin(void) const { return getFlagBit(FlagOverrideStMin); }
|
||||||
|
void Iso15765TxSetupMessage::setOverrideStMin(bool enable) { setFlagBit(FlagOverrideStMin, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getOverrideBlockSize(void) const { return getFlagBit(FlagOverrideBlockSize); }
|
||||||
|
void Iso15765TxSetupMessage::setOverrideBlockSize(bool enable) { setFlagBit(FlagOverrideBlockSize, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getPaddingEnabled(void) const { return getFlagBit(FlagPaddingEnable); }
|
||||||
|
void Iso15765TxSetupMessage::setPaddingEnabled(bool enable) { setFlagBit(FlagPaddingEnable, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getIsCanFd(void) const { return getFlagBit(FlagIsCanFd); }
|
||||||
|
void Iso15765TxSetupMessage::setIsCanFd(bool enable) { setFlagBit(FlagIsCanFd, enable); }
|
||||||
|
bool Iso15765TxSetupMessage::getIsBrsEnabled(void) const { return getFlagBit(FlagIsBrsEnabled); }
|
||||||
|
void Iso15765TxSetupMessage::setIsBrsEnabled(bool enable) { setFlagBit(FlagIsBrsEnabled, enable); }
|
||||||
|
|
||||||
|
bool Iso15765TxSetupMessage::getFlagBit(uint32_t mask) const {
|
||||||
|
return (getFlags() & mask) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Iso15765TxSetupMessage::setFlagBit(uint32_t mask, bool enable) {
|
||||||
|
uint32_t f = getFlags();
|
||||||
|
if(enable) f |= mask;
|
||||||
|
else f &= ~mask;
|
||||||
|
setFlags(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t Iso15765TxDataMessage::getIdx(void) const { return read16LE(DataIdxOffset); }
|
||||||
|
void Iso15765TxDataMessage::setIdx(uint16_t idx) { write16LE(DataIdxOffset, idx); }
|
||||||
|
|
||||||
|
uint32_t Iso15765TxDataMessage::getOffset(void) const { return read32LE(DataOffsetOffset); }
|
||||||
|
void Iso15765TxDataMessage::setOffset(uint32_t offset) { write32LE(DataOffsetOffset, offset); }
|
||||||
|
|
||||||
|
uint16_t Iso15765TxDataMessage::getLen(void) const { return read16LE(DataLenOffset); }
|
||||||
|
|
||||||
|
const uint8_t* Iso15765TxDataMessage::getData(void) const { return argumentData.data() + DataPayloadOffset; }
|
||||||
|
|
||||||
|
void Iso15765TxDataMessage::setData(const uint8_t* sourceData, uint16_t len) {
|
||||||
|
len = std::min(len, (uint16_t)MaxDataLength);
|
||||||
|
argumentData.resize(DataPayloadOffset + len);
|
||||||
|
write16LE(DataLenOffset, len);
|
||||||
|
if(len > 0 && sourceData != nullptr)
|
||||||
|
std::copy(sourceData, sourceData + len, argumentData.begin() + DataPayloadOffset);
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#include "icsneo/communication/message/mfgconfigmessage.h"
|
||||||
|
#include "icsneo/communication/icspb.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
static MfgConfigMessage::VersionNumber versionFromProto(const settings::common::v1::VersionNumber& version) {
|
||||||
|
MfgConfigMessage::VersionNumber decoded;
|
||||||
|
decoded.major = version.major();
|
||||||
|
decoded.minor = version.minor();
|
||||||
|
if(version.has_release())
|
||||||
|
decoded.release = version.release();
|
||||||
|
if(version.has_build())
|
||||||
|
decoded.build = version.build();
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<MfgConfigMessage> MfgConfigMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
MfgConfigMessage decoded;
|
||||||
|
settings::manufacturing::v1::MfgConfig msg;
|
||||||
|
|
||||||
|
if(!protoapi::processResponse(bytestream.data(), bytestream.size(), msg)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(msg.has_serial_number()) {
|
||||||
|
decoded.serialNumber = msg.serial_number();
|
||||||
|
}
|
||||||
|
if(msg.has_manufacture_date()) {
|
||||||
|
const auto& date = msg.manufacture_date();
|
||||||
|
decoded.manufactureDate = MfgDate{date.manufacture_day(), date.manufacture_month(), date.manufacture_year()};
|
||||||
|
}
|
||||||
|
if(msg.has_hardware_rev()) {
|
||||||
|
decoded.hardwareRev = versionFromProto(msg.hardware_rev());
|
||||||
|
}
|
||||||
|
if(msg.has_product_id()) {
|
||||||
|
decoded.productId = static_cast<uint8_t>(msg.product_id());
|
||||||
|
}
|
||||||
|
if(msg.has_bootloader_rev()) {
|
||||||
|
decoded.bootloaderRev = versionFromProto(msg.bootloader_rev());
|
||||||
|
}
|
||||||
|
if(msg.has_usb_descriptor()) {
|
||||||
|
decoded.usbDescriptor = msg.usb_descriptor();
|
||||||
|
}
|
||||||
|
for(const auto& mac : msg.mac_addresses()) {
|
||||||
|
const auto& bytes = mac.mac_addr();
|
||||||
|
if(bytes.size() < MACAddressLength)
|
||||||
|
continue;
|
||||||
|
MACAddress address{};
|
||||||
|
std::copy_n(bytes.begin(), MACAddressLength, address.begin());
|
||||||
|
decoded.macAddresses.push_back(address);
|
||||||
|
}
|
||||||
|
if(msg.has_pcb_serial()) {
|
||||||
|
decoded.pcbSerial = msg.pcb_serial().pcb_serial();
|
||||||
|
}
|
||||||
|
if(msg.has_chip_id()) {
|
||||||
|
decoded.chipId = static_cast<ChipID>(msg.chip_id());
|
||||||
|
}
|
||||||
|
if(msg.has_imei()) {
|
||||||
|
decoded.imei = msg.imei();
|
||||||
|
}
|
||||||
|
if(msg.has_parent_product_id()) {
|
||||||
|
decoded.parentProductId = static_cast<uint8_t>(msg.parent_product_id());
|
||||||
|
}
|
||||||
|
if(msg.has_software_version_lock()) {
|
||||||
|
decoded.softwareVersionLock = versionFromProto(msg.software_version_lock());
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_shared<MfgConfigMessage>(decoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> MfgConfigMessage::EncodeArgumentsForGet() {
|
||||||
|
settings::manufacturing::v1::MfgConfig msg;
|
||||||
|
msg.Clear();
|
||||||
|
return protoapi::getPayload(protoapi::Command::GET, msg);
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
|
|||||||
case Network::Type::AutomotiveEthernet: {
|
case Network::Type::AutomotiveEthernet: {
|
||||||
neomessage_eth_t& eth = *(neomessage_eth_t*)&neomsg;
|
neomessage_eth_t& eth = *(neomessage_eth_t*)&neomsg;
|
||||||
auto ethmsg = std::static_pointer_cast<EthernetMessage>(message);
|
auto ethmsg = std::static_pointer_cast<EthernetMessage>(message);
|
||||||
eth.preemptionFlags = ethmsg->preemptionFlags;
|
eth.preemptionFlags = ethmsg->preemptionFlags.value_or(0);
|
||||||
eth.status.incompleteFrame = ethmsg->frameTooShort;
|
eth.status.incompleteFrame = ethmsg->frameTooShort;
|
||||||
// TODO Fill in extra status bits
|
// TODO Fill in extra status bits
|
||||||
//eth.status.xyz = ethmsg->preemptionEnabled;
|
//eth.status.xyz = ethmsg->preemptionEnabled;
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "icsneo/communication/message/spiportkeymessage.h"
|
||||||
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
#include "icsneo/communication/network.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<SPIPortKeyMessage> SPIPortKeyMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
if(bytestream.size() < sizeof(ExtendedResponseMessage::ResponseHeader))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const auto* hdr = reinterpret_cast<const ExtendedResponseMessage::ResponseHeader*>(bytestream.data());
|
||||||
|
|
||||||
|
if(hdr->command != ExtendedCommand::ExecuteSPIPortKeyOperation)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const size_t required = sizeof(ExtendedResponseMessage::ResponseHeader) + sizeof(SPIPortKeyPacket);
|
||||||
|
if(bytestream.size() < required)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto msg = std::make_shared<SPIPortKeyMessage>();
|
||||||
|
|
||||||
|
const auto* packet = reinterpret_cast<const SPIPortKeyPacket*>(bytestream.data() + sizeof(ExtendedResponseMessage::ResponseHeader));
|
||||||
|
msg->isKeyLoaded = packet->isKeyLoaded;
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
@@ -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) {
|
||||||
@@ -104,6 +79,7 @@ static std::vector<uint8_t> EncodeFromMessageCAN(std::shared_ptr<Frame> frame, c
|
|||||||
canpacket->header.BRS = canmsg->baudrateSwitch ? 1 : 0;
|
canpacket->header.BRS = canmsg->baudrateSwitch ? 1 : 0;
|
||||||
canpacket->header.ESI = canmsg->errorStateIndicator ? 1 : 0;
|
canpacket->header.ESI = canmsg->errorStateIndicator ? 1 : 0;
|
||||||
canpacket->dlc.RTR = 0;
|
canpacket->dlc.RTR = 0;
|
||||||
|
canpacket->timestamp.IsExtended = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
canpacket->header.EDL = 0;
|
canpacket->header.EDL = 0;
|
||||||
@@ -126,10 +102,71 @@ static std::vector<uint8_t> EncodeFromMessageCAN(std::shared_ptr<Frame> frame, c
|
|||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<uint8_t> EncodeFromMessageLIN(std::shared_ptr<Frame> /* frame */, const device_eventhandler_t& report) {
|
static std::vector<uint8_t> EncodeFromMessageLIN(std::shared_ptr<Frame> frame, const device_eventhandler_t& report) {
|
||||||
// TODO
|
auto linmsg = std::dynamic_pointer_cast<LINMessage>(frame);
|
||||||
report(APIEvent::Type::UnsupportedTXNetwork, APIEvent::Severity::Error);
|
if(!linmsg) {
|
||||||
return {};
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if(linmsg->linMsgType == LINMessage::Type::NOT_SET) {
|
||||||
|
report(APIEvent::Type::RequiredParameterNull, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t dataLen = std::min<size_t>(8, linmsg->data.size());
|
||||||
|
std::vector<uint8_t> encoded;
|
||||||
|
encoded.resize(sizeof(TransmitMessage));
|
||||||
|
|
||||||
|
TransmitMessage* const msg = (TransmitMessage*)encoded.data();
|
||||||
|
HardwareLINPacket* const linpacket = (HardwareLINPacket*)(msg->commonHeader);
|
||||||
|
memset(linpacket, 0, sizeof(HardwareLINPacket));
|
||||||
|
|
||||||
|
// Protected ID and ID
|
||||||
|
linmsg->protectedID = linmsg->calcProtectedID(linmsg->ID);
|
||||||
|
linpacket->CoreMiniBitsLIN.ID = linmsg->protectedID & 0x3F;
|
||||||
|
|
||||||
|
// LIN message type flags
|
||||||
|
switch(linmsg->linMsgType) {
|
||||||
|
case LINMessage::Type::LIN_COMMANDER_MSG:
|
||||||
|
linpacket->CoreMiniBitsLIN.TXCommander = 1;
|
||||||
|
break;
|
||||||
|
case LINMessage::Type::LIN_HEADER_ONLY:
|
||||||
|
linpacket->CoreMiniBitsLIN.TXCommander = 1;
|
||||||
|
break;
|
||||||
|
case LINMessage::Type::LIN_UPDATE_RESPONDER:
|
||||||
|
linpacket->CoreMiniBitsLIN.TXResponder = 1;
|
||||||
|
break;
|
||||||
|
case LINMessage::Type::LIN_BREAK_ONLY:
|
||||||
|
linpacket->CoreMiniBitsLIN.BreakOnly = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enhanced checksum
|
||||||
|
linpacket->CoreMiniBitsLIN.TxChkSumEnhanced = linmsg->isEnhancedChecksum ? 1 : 0;
|
||||||
|
|
||||||
|
// Data and checksum
|
||||||
|
bool hasData = (linmsg->linMsgType == LINMessage::Type::LIN_COMMANDER_MSG ||
|
||||||
|
linmsg->linMsgType == LINMessage::Type::LIN_UPDATE_RESPONDER) && dataLen > 0;
|
||||||
|
|
||||||
|
if(hasData) {
|
||||||
|
// len includes data bytes + 1 checksum byte
|
||||||
|
linpacket->CoreMiniBitsLIN.len = static_cast<uint16_t>(dataLen + 1);
|
||||||
|
std::copy(linmsg->data.begin(), linmsg->data.begin() + dataLen, linpacket->data);
|
||||||
|
// Checksum goes after data: in data[dataLen] if < 8, otherwise in LINByte9
|
||||||
|
if(dataLen < 8)
|
||||||
|
linpacket->data[dataLen] = linmsg->checksum;
|
||||||
|
else
|
||||||
|
linpacket->CoreMiniBitsLIN.LINByte9 = linmsg->checksum;
|
||||||
|
} else {
|
||||||
|
linpacket->CoreMiniBitsLIN.len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Description/stats and network
|
||||||
|
linpacket->stats = linmsg->description;
|
||||||
|
|
||||||
|
return encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> TransmitMessage::EncodeFromMessage(std::shared_ptr<Frame> frame, uint32_t client_id, const device_eventhandler_t& report) {
|
std::vector<uint8_t> TransmitMessage::EncodeFromMessage(std::shared_ptr<Frame> frame, uint32_t client_id, const device_eventhandler_t& report) {
|
||||||
@@ -139,6 +176,7 @@ std::vector<uint8_t> TransmitMessage::EncodeFromMessage(std::shared_ptr<Frame> f
|
|||||||
case Network::Type::AutomotiveEthernet:
|
case Network::Type::AutomotiveEthernet:
|
||||||
result = EncodeFromMessageEthernet(frame, report);
|
result = EncodeFromMessageEthernet(frame, report);
|
||||||
break;
|
break;
|
||||||
|
case Network::Type::Internal:
|
||||||
case Network::Type::CAN:
|
case Network::Type::CAN:
|
||||||
result = EncodeFromMessageCAN(frame, report);
|
result = EncodeFromMessageCAN(frame, report);
|
||||||
break;
|
break;
|
||||||
@@ -150,6 +188,8 @@ std::vector<uint8_t> TransmitMessage::EncodeFromMessage(std::shared_ptr<Frame> f
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// common fields
|
// common fields
|
||||||
|
if(result.empty())
|
||||||
|
return result;
|
||||||
TransmitMessage* const msg = (TransmitMessage*)result.data();
|
TransmitMessage* const msg = (TransmitMessage*)result.data();
|
||||||
msg->options.clientId = client_id;
|
msg->options.clientId = client_id;
|
||||||
msg->options.networkId = static_cast<uint32_t>(frame->network.getNetID());
|
msg->options.networkId = static_cast<uint32_t>(frame->network.getNetID());
|
||||||
|
|||||||
@@ -142,6 +142,8 @@ void MultiChannelCommunication::hidReadTask() {
|
|||||||
dispatchMessage(msg);
|
dispatchMessage(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentQueue == nullptr) {
|
if(currentQueue == nullptr) {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
@@ -120,7 +119,12 @@ std::shared_ptr<Message> HardwareCANPacket::DecodeToMessage(const std::vector<ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg->transmitted = data->eid.TXMSG;
|
msg->transmitted = data->eid.TXMSG;
|
||||||
|
// Set the generic frame error state
|
||||||
msg->error = data->eid.TXAborted || data->eid.TXError || data->eid.TXLostArb;
|
msg->error = data->eid.TXAborted || data->eid.TXError || data->eid.TXLostArb;
|
||||||
|
// Set specific error states for CANError
|
||||||
|
msg->txAborted = data->eid.TXAborted;
|
||||||
|
msg->txLostArb = data->eid.TXLostArb;
|
||||||
|
msg->txError = data->eid.TXError;
|
||||||
msg->description = data->stats;
|
msg->description = data->stats;
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "icsneo/communication/packet/ethernetpacket.h"
|
#include "icsneo/communication/packet/ethernetpacket.h"
|
||||||
#include <algorithm> // for std::copy
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
@@ -10,29 +11,49 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
|
|||||||
// Make sure we have enough to read the packet length first
|
// Make sure we have enough to read the packet length first
|
||||||
if(bytestream.size() < sizeof(HardwareEthernetPacket))
|
if(bytestream.size() < sizeof(HardwareEthernetPacket))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
// packet->Length will also encompass the two uint16_t's at the end of the struct, make sure that at least they are here
|
|
||||||
if(packet->Length < 4)
|
|
||||||
return nullptr;
|
|
||||||
const size_t fcsSize = packet->header.FCS_AVAIL ? 4 : 0;
|
const size_t fcsSize = packet->header.FCS_AVAIL ? 4 : 0;
|
||||||
|
// Ensure Length is sufficient for FCS extraction to avoid invalid iterator arithmetic
|
||||||
|
if(packet->Length < fcsSize)
|
||||||
|
return nullptr;
|
||||||
const size_t bytestreamExpectedSize = sizeof(HardwareEthernetPacket) + packet->Length;
|
const size_t bytestreamExpectedSize = sizeof(HardwareEthernetPacket) + packet->Length;
|
||||||
const size_t bytestreamActualSize = bytestream.size();
|
const size_t bytestreamActualSize = bytestream.size();
|
||||||
if(bytestreamActualSize < bytestreamExpectedSize)
|
if(bytestreamActualSize < bytestreamExpectedSize)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto messagePtr = std::make_shared<EthernetMessage>();
|
auto messagePtr = std::make_shared<EthernetMessage>();
|
||||||
EthernetMessage& message = *messagePtr;
|
EthernetMessage& message = *messagePtr;
|
||||||
|
// Standard Ethernet fields
|
||||||
message.transmitted = packet->eid.TXMSG;
|
message.transmitted = packet->eid.TXMSG;
|
||||||
if(message.transmitted)
|
if(message.transmitted)
|
||||||
message.description = packet->stats;
|
message.description = packet->stats;
|
||||||
message.preemptionEnabled = packet->header.PREEMPTION_ENABLED;
|
|
||||||
if(message.preemptionEnabled)
|
|
||||||
message.preemptionFlags = (uint8_t)((rawWords[0] & 0x03F8) >> 4);
|
|
||||||
message.frameTooShort = packet->header.RUNT_FRAME;
|
message.frameTooShort = packet->header.RUNT_FRAME;
|
||||||
|
message.noPadding = !packet->header.ENABLE_PADDING;
|
||||||
|
message.fcsVerified = packet->header.FCS_VERIFIED;
|
||||||
|
message.txAborted = packet->eid.TXAborted;
|
||||||
|
message.crcError = packet->header.CRC_ERROR;
|
||||||
|
|
||||||
if(message.frameTooShort)
|
if(message.frameTooShort)
|
||||||
message.error = true;
|
message.error = true;
|
||||||
// This timestamp is raw off the device (in timestampResolution increments)
|
// This timestamp is raw off the device (in timestampResolution increments)
|
||||||
// Decoder will fix as it has information about the timestampResolution increments
|
// Decoder will fix as it has information about the timestampResolution increments
|
||||||
message.timestamp = packet->timestamp.TS;
|
message.timestamp = packet->timestamp.TS;
|
||||||
|
|
||||||
|
// Ethernet Frame Preemption for TSN
|
||||||
|
if(packet->header.PREEMPTION_ENABLED) {
|
||||||
|
message.preemptionFlags = static_cast<uint8_t>((rawWords[0] & 0x03F8) >> 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this is a T1S packet and populate T1S-specific fields
|
||||||
|
if(packet->header.T1S_ETHERNET) {
|
||||||
|
auto& t1s = message.t1s.emplace();
|
||||||
|
|
||||||
|
t1s.isSymbol = packet->eid.T1S_SYMBOL;
|
||||||
|
t1s.isBurst = packet->eid.T1S_BURST;
|
||||||
|
t1s.txCollision = packet->t1s_status.TXCollision;
|
||||||
|
t1s.isWake = packet->t1s_status.T1SWake;
|
||||||
|
t1s.nodeId = packet->t1s_node.T1S_NODE_ID;
|
||||||
|
t1s.burstCount = packet->t1s_node.T1S_BURST_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<uint8_t>::const_iterator databegin = bytestream.begin() + sizeof(HardwareEthernetPacket);
|
const std::vector<uint8_t>::const_iterator databegin = bytestream.begin() + sizeof(HardwareEthernetPacket);
|
||||||
const std::vector<uint8_t>::const_iterator dataend = databegin + packet->Length - fcsSize;
|
const std::vector<uint8_t>::const_iterator dataend = databegin + packet->Length - fcsSize;
|
||||||
message.data.insert(message.data.begin(), databegin, dataend);
|
message.data.insert(message.data.begin(), databegin, dataend);
|
||||||
@@ -55,7 +76,7 @@ bool HardwareEthernetPacket::EncodeFromMessage(const EthernetMessage& message, s
|
|||||||
if(description & 0x8000)
|
if(description & 0x8000)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const bool preempt = message.preemptionEnabled;
|
const bool preempt = message.preemptionFlags.has_value();
|
||||||
// full header including parent
|
// full header including parent
|
||||||
const size_t headerByteCount = preempt ? 15 : 14;
|
const size_t headerByteCount = preempt ? 15 : 14;
|
||||||
// local header for netID, description, and flags
|
// local header for netID, description, and flags
|
||||||
@@ -104,12 +125,15 @@ bool HardwareEthernetPacket::EncodeFromMessage(const EthernetMessage& message, s
|
|||||||
uint8_t flags = 0x00;
|
uint8_t flags = 0x00;
|
||||||
if(!message.noPadding) flags |= FLAG_PADDING;
|
if(!message.noPadding) flags |= FLAG_PADDING;
|
||||||
if(message.fcs) flags |= FLAG_FCS;
|
if(message.fcs) flags |= FLAG_FCS;
|
||||||
if(message.preemptionEnabled) flags |= FLAG_PREEMPTION;
|
if(message.preemptionFlags.has_value()) {
|
||||||
|
flags |= FLAG_PREEMPTION;
|
||||||
|
}
|
||||||
|
|
||||||
bytestream.push_back(flags);
|
bytestream.push_back(flags);
|
||||||
|
|
||||||
if(preempt)
|
if(preempt) {
|
||||||
bytestream.push_back(static_cast<uint8_t>(message.preemptionFlags));
|
bytestream.push_back(message.preemptionFlags.value());
|
||||||
|
}
|
||||||
|
|
||||||
bytestream.insert(bytestream.end(), message.data.begin(), message.data.end());
|
bytestream.insert(bytestream.end(), message.data.begin(), message.data.end());
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ bool Packetizer::input(RingBuffer& bytes) {
|
|||||||
* end of the payload. The short packet length, for reference, only encompasses the length of the actual
|
* end of the payload. The short packet length, for reference, only encompasses the length of the actual
|
||||||
* payload, and not the header or checksum.
|
* payload, and not the header or checksum.
|
||||||
*/
|
*/
|
||||||
if(packetLength < 6 || packetLength > 4000) {
|
if(packetLength < 6 || packetLength > std::numeric_limits<uint16_t>::max()) {
|
||||||
bytes.pop_front();
|
bytes.pop_front();
|
||||||
EventManager::GetInstance().add(APIEvent::Type::FailedToRead, APIEvent::Severity::Error);
|
EventManager::GetInstance().add(APIEvent::Type::FailedToRead, APIEvent::Severity::Error);
|
||||||
state = ReadState::SearchForHeader;
|
state = ReadState::SearchForHeader;
|
||||||
|
|||||||
+66
-10
@@ -144,7 +144,7 @@ typedef union _MACSecSa
|
|||||||
{
|
{
|
||||||
uint8_t index; /*!< SA index */
|
uint8_t index; /*!< SA index */
|
||||||
uint8_t
|
uint8_t
|
||||||
sak[32]; /*!< 256b SAK: Define the encryption key to be used to encrypte this packet. The lower 128 bits are used for 128-bit ciphers. */
|
sak[32]; /*!< SAK: All 32 bytes are written to the firmware. For AES-128 the firmware requires bytes [0..15] == bytes [16..31] (mirrored); serialize() handles this automatically. */
|
||||||
uint8_t hashKey[16]; /*!< 128b Hash Key: Key used for authentication. */
|
uint8_t hashKey[16]; /*!< 128b Hash Key: Key used for authentication. */
|
||||||
uint8_t salt[12]; /*!< 96b Salt value: Salt value used in XPN ciphers. */
|
uint8_t salt[12]; /*!< 96b Salt value: Salt value used in XPN ciphers. */
|
||||||
uint32_t ssci; /*!< 32b SSCI value: Short Secure Channel Identifier, used in XPN ciphers. */
|
uint32_t ssci; /*!< 32b SSCI value: Short Secure Channel Identifier, used in XPN ciphers. */
|
||||||
@@ -230,6 +230,7 @@ MACsecConfig::MACsecConfig(const DeviceType& deviceType) : type(deviceType) {
|
|||||||
case icsneo::DeviceType::Enum::RADMoon2:
|
case icsneo::DeviceType::Enum::RADMoon2:
|
||||||
case icsneo::DeviceType::Enum::RADMoon3:
|
case icsneo::DeviceType::Enum::RADMoon3:
|
||||||
case icsneo::DeviceType::Enum::RADEpsilon:
|
case icsneo::DeviceType::Enum::RADEpsilon:
|
||||||
|
case icsneo::DeviceType::Enum::RADGigastar2:
|
||||||
maxSecY = 2;
|
maxSecY = 2;
|
||||||
maxRule = 2;
|
maxRule = 2;
|
||||||
maxSa = 4;
|
maxSa = 4;
|
||||||
@@ -285,14 +286,29 @@ int MACsecConfig::addTxSecY(const MACsecTxSecY& secY, uint8_t saIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MACsecConfig::addRxSa(const MACsecRxSa& sa) {
|
int MACsecConfig::addRxSa(const MACsecRxSa& sa) {
|
||||||
|
// Validate AN is in valid range
|
||||||
|
if(sa.an > 3) {
|
||||||
|
ReportEvent(APIEvent::Type::MACsecSaLimit, APIEvent::Severity::Error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we've exceeded the maximum SA count
|
||||||
if(rxSa.size() >= maxSa) {
|
if(rxSa.size() >= maxSa) {
|
||||||
ReportEvent(APIEvent::Type::MACsecSaLimit, APIEvent::Severity::Error);
|
ReportEvent(APIEvent::Type::MACsecSaLimit, APIEvent::Severity::Error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = static_cast<int>(rxSa.size());
|
// Ensure vector is large enough to hold index sa.an (sparse array)
|
||||||
rxSa.emplace_back(sa);
|
// This allows SA index to match the AN value from the MACsec SecTAG
|
||||||
return ret;
|
if(rxSa.size() <= sa.an) {
|
||||||
|
rxSa.resize(sa.an + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark it enabled; padding slots created by resize() above default to enabled=false.
|
||||||
|
rxSa[sa.an] = sa;
|
||||||
|
rxSa[sa.an].enabled = true;
|
||||||
|
|
||||||
|
return sa.an;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MACsecConfig::addTxSa(const MACsecTxSa& sa) {
|
int MACsecConfig::addTxSa(const MACsecTxSa& sa) {
|
||||||
@@ -603,13 +619,23 @@ static void SetHardwareRxSecY(
|
|||||||
hwSc->enable = 0x1u;
|
hwSc->enable = 0x1u;
|
||||||
hwSc->secYIndex = index;
|
hwSc->secYIndex = index;
|
||||||
hwSc->enable_auto_rekey = rekeyEnabled ? 0x1u : 0x0u;
|
hwSc->enable_auto_rekey = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
hwSc->sa_index0 = saIndices.first;
|
|
||||||
hwSc->sa_index1 = saIndices.second;
|
|
||||||
hwSc->sa_index0_in_use = 0x1u;
|
|
||||||
hwSc->sa_index1_in_use = rekeyEnabled ? 0x1u : 0x0u;
|
|
||||||
hwSc->isActiveSA1 = rekeyEnabled ? 0x1u : 0x0u;
|
|
||||||
hwSc->sci = secY.sci;
|
hwSc->sci = secY.sci;
|
||||||
|
|
||||||
|
|
||||||
|
if(saIndices.first & 0x1u) {
|
||||||
|
hwSc->sa_index0 = rekeyEnabled ? saIndices.second : saIndices.first;
|
||||||
|
hwSc->sa_index1 = saIndices.first;
|
||||||
|
hwSc->sa_index0_in_use = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
|
hwSc->sa_index1_in_use = 0x1u;
|
||||||
|
hwSc->isActiveSA1 = rekeyEnabled ? 0x0u : 0x1u;
|
||||||
|
} else {
|
||||||
|
hwSc->sa_index0 = saIndices.first;
|
||||||
|
hwSc->sa_index1 = saIndices.second;
|
||||||
|
hwSc->sa_index0_in_use = 0x1u;
|
||||||
|
hwSc->sa_index1_in_use = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
|
hwSc->isActiveSA1 = rekeyEnabled ? 0x1u : 0x0u;
|
||||||
|
}
|
||||||
|
|
||||||
hwMap->index = index;
|
hwMap->index = index;
|
||||||
hwMap->enable = 0x1u;
|
hwMap->enable = 0x1u;
|
||||||
hwMap->secYIndex = index;
|
hwMap->secYIndex = index;
|
||||||
@@ -638,7 +664,9 @@ static void SetHardwareRxSa(MACSEC_SETTINGS_W_HDR* hwSettings, const MACsecRxSa&
|
|||||||
MACSecSa_t* hwSa = &hwSettings->macsec.rx.sa[index];
|
MACSecSa_t* hwSa = &hwSettings->macsec.rx.sa[index];
|
||||||
|
|
||||||
hwSa->index = index;
|
hwSa->index = index;
|
||||||
hwSa->enable = 0x1u;
|
hwSa->enable = sa.enabled ? 0x1u : 0x0u;
|
||||||
|
if(!sa.enabled)
|
||||||
|
return;
|
||||||
memcpy(hwSa->sak, sa.sak.data(), 32);
|
memcpy(hwSa->sak, sa.sak.data(), 32);
|
||||||
memcpy(hwSa->hashKey, sa.hashKey.data(), 16);
|
memcpy(hwSa->hashKey, sa.hashKey.data(), 16);
|
||||||
memcpy(hwSa->salt, sa.salt.data(), 12);
|
memcpy(hwSa->salt, sa.salt.data(), 12);
|
||||||
@@ -740,6 +768,34 @@ std::vector<uint8_t> MACsecConfig::serialize() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AES-128 SAK normalization: the firmware expects the 16-byte SAK mirrored
|
||||||
|
// into both halves of the 32-byte hardware SAK field. Callers only populate
|
||||||
|
// bytes [0..15]; copy them into [16..31] here, transparent to all callers.
|
||||||
|
for(uint8_t i = 0; i < static_cast<uint8_t>(rxSecY.size()); i++) {
|
||||||
|
if(rxSecY[i].cipher == MACsecCipherSuite::GcmAes128 || rxSecY[i].cipher == MACsecCipherSuite::GcmAes128Xpn) {
|
||||||
|
uint8_t primaryIdx = rxSecYSaIndices[i].first;
|
||||||
|
if(primaryIdx < maxSa)
|
||||||
|
memcpy(hwSettings->macsec.rx.sa[primaryIdx].sak + 16, hwSettings->macsec.rx.sa[primaryIdx].sak, 16);
|
||||||
|
if(rxSecYRekey[i]) {
|
||||||
|
uint8_t rekeyIdx = rxSecYSaIndices[i].second;
|
||||||
|
if(rekeyIdx < maxSa)
|
||||||
|
memcpy(hwSettings->macsec.rx.sa[rekeyIdx].sak + 16, hwSettings->macsec.rx.sa[rekeyIdx].sak, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(uint8_t i = 0; i < static_cast<uint8_t>(txSecY.size()); i++) {
|
||||||
|
if(txSecY[i].cipher == MACsecCipherSuite::GcmAes128 || txSecY[i].cipher == MACsecCipherSuite::GcmAes128Xpn) {
|
||||||
|
uint8_t primaryIdx = txSecYSaIndices[i].first;
|
||||||
|
if(primaryIdx < maxSa)
|
||||||
|
memcpy(hwSettings->macsec.tx.sa[primaryIdx].sak + 16, hwSettings->macsec.tx.sa[primaryIdx].sak, 16);
|
||||||
|
if(txSecYRekey[i]) {
|
||||||
|
uint8_t rekeyIdx = txSecYSaIndices[i].second;
|
||||||
|
if(rekeyIdx < maxSa)
|
||||||
|
memcpy(hwSettings->macsec.tx.sa[rekeyIdx].sak + 16, hwSettings->macsec.tx.sa[rekeyIdx].sak, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(rxRule.size() == 0) {
|
if(rxRule.size() == 0) {
|
||||||
MACsecRxRule defaultRule;
|
MACsecRxRule defaultRule;
|
||||||
MACSecRule_t* hwRxRule = &hwSettings->macsec.rx.rule[0];
|
MACSecRule_t* hwRxRule = &hwSettings->macsec.rx.rule[0];
|
||||||
|
|||||||
+452
-169
@@ -1,4 +1,5 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
#include "icsneo/api/eventmanager.h"
|
#include "icsneo/api/eventmanager.h"
|
||||||
#include "icsneo/communication/message/filter/main51messagefilter.h"
|
#include "icsneo/communication/message/filter/main51messagefilter.h"
|
||||||
#include "icsneo/communication/message/extendedresponsemessage.h"
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
@@ -7,6 +8,7 @@
|
|||||||
#include "icsneo/disk/fat.h"
|
#include "icsneo/disk/fat.h"
|
||||||
#include "icsneo/communication/message/filter/extendedresponsefilter.h"
|
#include "icsneo/communication/message/filter/extendedresponsefilter.h"
|
||||||
#include "icsneo/communication/message/networkmutexmessage.h"
|
#include "icsneo/communication/message/networkmutexmessage.h"
|
||||||
|
#include "icsneo/communication/message/mfgconfigmessage.h"
|
||||||
#include "icsneo/communication/message/transmitmessage.h"
|
#include "icsneo/communication/message/transmitmessage.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -91,10 +93,6 @@ Device::~Device() {
|
|||||||
disableMessagePolling();
|
disableMessagePolling();
|
||||||
if(isOpen())
|
if(isOpen())
|
||||||
close();
|
close();
|
||||||
if(heartbeatThread.joinable()) {
|
|
||||||
stopHeartbeatThread = true;
|
|
||||||
heartbeatThread.join();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Device::getTimestampResolution() const {
|
uint16_t Device::getTimestampResolution() const {
|
||||||
@@ -181,12 +179,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);
|
||||||
|
|
||||||
@@ -242,12 +239,12 @@ std::vector<VersionReport> Device::getChipVersions(bool refreshComponents) {
|
|||||||
auto& version = chipVersions.back();
|
auto& version = chipVersions.back();
|
||||||
|
|
||||||
auto disectedVersion = disectVersion(component.dotVersion);
|
auto disectedVersion = disectVersion(component.dotVersion);
|
||||||
version.id = chipInfo.id;
|
version.id = chipInfo.id;
|
||||||
version.name = chipInfo.name;
|
version.name = chipInfo.name;
|
||||||
version.major = disectedVersion[0];
|
version.major = disectedVersion[0];
|
||||||
version.minor = disectedVersion[1];
|
version.minor = disectedVersion[1];
|
||||||
version.maintenance = disectedVersion[2];
|
version.maintenance = disectedVersion[2];
|
||||||
version.build = disectedVersion[3];
|
version.build = disectedVersion[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,12 +264,12 @@ std::vector<VersionReport> Device::getChipVersions(bool refreshComponents) {
|
|||||||
chipVersions.emplace_back();
|
chipVersions.emplace_back();
|
||||||
auto& version = chipVersions.back();
|
auto& version = chipVersions.back();
|
||||||
|
|
||||||
version.id = chipInfo.id;
|
version.id = chipInfo.id;
|
||||||
version.name = chipInfo.name;
|
version.name = chipInfo.name;
|
||||||
version.major = appVer->major;
|
version.major = appVer->major;
|
||||||
version.minor = appVer->minor;
|
version.minor = appVer->minor;
|
||||||
version.maintenance = 0;
|
version.maintenance = 0;
|
||||||
version.build = 0;
|
version.build = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chipVersions;
|
return chipVersions;
|
||||||
@@ -288,6 +285,8 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startHeartbeat();
|
||||||
|
|
||||||
APIEvent::Type attemptErr = attemptToBeginCommunication();
|
APIEvent::Type attemptErr = attemptToBeginCommunication();
|
||||||
if(attemptErr != APIEvent::Type::NoErrorFound) {
|
if(attemptErr != APIEvent::Type::NoErrorFound) {
|
||||||
// We could not communicate with the device, let's see if an extension can
|
// We could not communicate with the device, let's see if an extension can
|
||||||
@@ -334,79 +333,6 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
|||||||
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
EventManager::GetInstance().cancelErrorDowngradingOnCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageFilter filter;
|
|
||||||
filter.includeInternalInAny = true;
|
|
||||||
internalHandlerCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>(filter, [this](std::shared_ptr<Message> message) {
|
|
||||||
handleInternalMessage(message);
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Clear the previous heartbeat thread, in case open() was called on this instance more than once
|
|
||||||
if(heartbeatThread.joinable())
|
|
||||||
heartbeatThread.join();
|
|
||||||
|
|
||||||
stopHeartbeatThread = false;
|
|
||||||
|
|
||||||
heartbeatThread = std::thread([this]() {
|
|
||||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
|
||||||
|
|
||||||
MessageFilter filter;
|
|
||||||
filter.includeInternalInAny = true;
|
|
||||||
|
|
||||||
std::condition_variable heartbeatCV;
|
|
||||||
std::mutex receivedMessageMutex;
|
|
||||||
bool receivedMessage = false;
|
|
||||||
auto messageReceivedCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>(filter, [&](std::shared_ptr<Message>) {
|
|
||||||
{
|
|
||||||
std::scoped_lock<std::mutex> lk(receivedMessageMutex);
|
|
||||||
receivedMessage = true;
|
|
||||||
}
|
|
||||||
heartbeatCV.notify_all();
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Give the device time to get situated
|
|
||||||
auto i = 150;
|
|
||||||
while(!stopHeartbeatThread && i != 0) {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!stopHeartbeatThread) {
|
|
||||||
std::unique_lock<std::mutex> recvLk(receivedMessageMutex);
|
|
||||||
// Wait for 110ms for a possible heartbeat
|
|
||||||
if(heartbeatCV.wait_for(recvLk, std::chrono::milliseconds(110), [&]() { return receivedMessage; })) {
|
|
||||||
receivedMessage = false;
|
|
||||||
} else if(!stopHeartbeatThread) { // Add this condition here in case the thread was stopped while waiting for the last message
|
|
||||||
|
|
||||||
// Some communication, such as the bootloader and extractor interfaces, must
|
|
||||||
// redirect the input stream from the device as it will no longer be in the
|
|
||||||
// packet format we expect here. As a result, status updates will not reach
|
|
||||||
// us here and suppressDisconnects() must be used. We don't want to request
|
|
||||||
// a status and then redirect the stream, as we'll then be polluting an
|
|
||||||
// otherwise quiet stream. This lock makes sure suppressDisconnects() will
|
|
||||||
// block until we've either gotten our status update or disconnected from
|
|
||||||
// the device.
|
|
||||||
std::unique_lock<std::mutex> lk(heartbeatMutex);
|
|
||||||
if(heartbeatSuppressed()) continue;
|
|
||||||
|
|
||||||
// No heartbeat received, request a status
|
|
||||||
com->sendCommand(Command::RequestStatusUpdate);
|
|
||||||
|
|
||||||
// Check if we got a message, and if not, if settings are being applied
|
|
||||||
if(heartbeatCV.wait_for(recvLk, std::chrono::milliseconds(3500), [&](){ return receivedMessage; })) {
|
|
||||||
receivedMessage = false;
|
|
||||||
} else {
|
|
||||||
if(!stopHeartbeatThread && !isDisconnected()) {
|
|
||||||
close();
|
|
||||||
report(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
com->removeMessageCallback(messageReceivedCallbackID);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(supportsLiveData())
|
if(supportsLiveData())
|
||||||
clearAllLiveData();
|
clearAllLiveData();
|
||||||
|
|
||||||
@@ -503,7 +429,7 @@ bool Device::close() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopHeartbeatThread = true;
|
stopHeartbeat();
|
||||||
|
|
||||||
if (isMessagePollingEnabled()) {
|
if (isMessagePollingEnabled()) {
|
||||||
disableMessagePolling();
|
disableMessagePolling();
|
||||||
@@ -534,82 +460,79 @@ bool Device::goOnline() {
|
|||||||
if(!enableNetworkCommunication(true, onlineTimeoutMs))
|
if(!enableNetworkCommunication(true, onlineTimeoutMs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto startTime = std::chrono::system_clock::now();
|
|
||||||
|
|
||||||
ledState = LEDState::Online;
|
ledState = LEDState::Online;
|
||||||
|
|
||||||
updateLEDState();
|
updateLEDState();
|
||||||
|
|
||||||
std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>(Network::NetID::Reset_Status);
|
|
||||||
filter->includeInternalInAny = true;
|
|
||||||
|
|
||||||
// Wait until communication is enabled or 5 seconds, whichever comes first
|
|
||||||
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds(5)) {
|
|
||||||
if(latestResetStatus && latestResetStatus->comEnabled)
|
|
||||||
break;
|
|
||||||
|
|
||||||
bool failOut = false;
|
|
||||||
com->waitForMessageSync([this, &failOut]() {
|
|
||||||
if(!com->sendCommand(Command::RequestStatusUpdate)) {
|
|
||||||
failOut = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, filter, std::chrono::milliseconds(100));
|
|
||||||
if(failOut)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(supportsNetworkMutex()) {
|
|
||||||
assignedClientId = com->getClientIDSync();
|
|
||||||
if(assignedClientId) {
|
|
||||||
// firmware supports clientid/mutex
|
|
||||||
networkMutexCallbackHandle = lockAllNetworks(std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), NetworkMutexType::Shared, [this](std::shared_ptr<Message> message) {
|
|
||||||
auto netMutexMsg = std::static_pointer_cast<NetworkMutexMessage>(message);
|
|
||||||
if(netMutexMsg->networks.size() && netMutexMsg->event.has_value()) {
|
|
||||||
switch(*netMutexMsg->event) {
|
|
||||||
case NetworkMutexEvent::Acquired:
|
|
||||||
lockedNetworks.emplace(*netMutexMsg->networks.begin());
|
|
||||||
break;
|
|
||||||
case NetworkMutexEvent::Released: {
|
|
||||||
auto it = lockedNetworks.find(*netMutexMsg->networks.begin());
|
|
||||||
if (it != lockedNetworks.end())
|
|
||||||
lockedNetworks.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// (re)start the keeponline
|
// (re)start the keeponline
|
||||||
keeponline = std::make_unique<Periodic>([this] {
|
keeponline = std::make_unique<Periodic>([this] {
|
||||||
static std::vector<uint8_t> timeoutBytes = std::vector<uint8_t>((uint8_t*)&onlineTimeoutMs, (uint8_t*)&onlineTimeoutMs + sizeof(onlineTimeoutMs));
|
static std::vector<uint8_t> timeoutBytes = std::vector<uint8_t>((uint8_t*)&onlineTimeoutMs, (uint8_t*)&onlineTimeoutMs + sizeof(onlineTimeoutMs));
|
||||||
return com->sendCommand(Command::KeepAlive, timeoutBytes);
|
return com->sendCommand(Command::KeepAlive, timeoutBytes);
|
||||||
}, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
}, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
||||||
|
|
||||||
|
if(supportsNetworkMutex) {
|
||||||
|
assignedClientId = com->getClientIDSync();
|
||||||
|
if(assignedClientId) {
|
||||||
|
std::set<Network::NetID> nets;
|
||||||
|
for(auto&& net : getSupportedTXNetworks()) {
|
||||||
|
nets.insert(net.getNetID());
|
||||||
|
}
|
||||||
|
// firmware supports clientid/mutex
|
||||||
|
networkMutexCallbackHandle = lockNetworks(nets, std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), NetworkMutexType::Shared, [this](std::shared_ptr<Message> message) {
|
||||||
|
auto netMutexMsg = std::static_pointer_cast<NetworkMutexMessage>(message);
|
||||||
|
if(netMutexMsg->networks.size() && netMutexMsg->event.has_value()) {
|
||||||
|
switch(*netMutexMsg->event) {
|
||||||
|
case NetworkMutexEvent::Acquired:
|
||||||
|
lockedNetworks.emplace(*netMutexMsg->networks.begin());
|
||||||
|
break;
|
||||||
|
case NetworkMutexEvent::Expired:
|
||||||
|
case NetworkMutexEvent::Preempted:
|
||||||
|
case NetworkMutexEvent::Released: {
|
||||||
|
auto it = lockedNetworks.find(*netMutexMsg->networks.begin());
|
||||||
|
if (it != lockedNetworks.end())
|
||||||
|
lockedNetworks.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NetworkMutexEvent::Queued:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
online = true;
|
online = true;
|
||||||
|
|
||||||
|
// restart the heartbeat in online mode
|
||||||
|
restartHeartbeat();
|
||||||
|
|
||||||
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOnline(); return true; });
|
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOnline(); return true; });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::goOffline() {
|
bool Device::goOffline() {
|
||||||
|
online = false;
|
||||||
|
|
||||||
keeponline.reset();
|
keeponline.reset();
|
||||||
|
|
||||||
|
// restart the heartbeat in offline mode
|
||||||
|
restartHeartbeat();
|
||||||
|
|
||||||
if(networkMutexCallbackHandle)
|
if(networkMutexCallbackHandle)
|
||||||
removeMessageCallback(*networkMutexCallbackHandle);
|
removeMessageCallback(*networkMutexCallbackHandle);
|
||||||
|
|
||||||
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOffline(); return true; });
|
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOffline(); return true; });
|
||||||
|
|
||||||
if(isDisconnected()) {
|
if(isDisconnected()) {
|
||||||
online = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(assignedClientId.has_value()) {
|
||||||
|
unlockAllNetworks();
|
||||||
|
assignedClientId.reset();
|
||||||
|
}
|
||||||
|
|
||||||
if(!enableNetworkCommunication(false))
|
if(!enableNetworkCommunication(false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -617,8 +540,6 @@ bool Device::goOffline() {
|
|||||||
|
|
||||||
updateLEDState();
|
updateLEDState();
|
||||||
|
|
||||||
online = false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,15 +650,17 @@ bool Device::uploadCoremini(std::istream& stream, Disk::MemoryType memType) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto connected = isLogicalDiskConnected();
|
if (memType == Disk::MemoryType::SD) {
|
||||||
|
auto connected = isLogicalDiskConnected();
|
||||||
if(!connected) {
|
|
||||||
return false; // Already added an API error
|
if(!connected) {
|
||||||
}
|
return false; // Already added an API error
|
||||||
|
}
|
||||||
if(!(*connected)) {
|
|
||||||
report(APIEvent::Type::DiskNotConnected, APIEvent::Severity::Error);
|
if(!(*connected)) {
|
||||||
return false;
|
report(APIEvent::Type::DiskNotConnected, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!stopScript()) {
|
if(!stopScript()) {
|
||||||
@@ -748,7 +671,6 @@ bool Device::uploadCoremini(std::istream& stream, Disk::MemoryType memType) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!eraseScriptMemory(memType, static_cast<uint64_t>(bin.size()))) {
|
if(!eraseScriptMemory(memType, static_cast<uint64_t>(bin.size()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -838,10 +760,12 @@ std::optional<CoreminiHeader> Device::readCoreminiHeader(Disk::MemoryType memTyp
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto connected = isLogicalDiskConnected();
|
if (memType == Disk::MemoryType::SD) {
|
||||||
|
auto connected = isLogicalDiskConnected();
|
||||||
if(!connected) {
|
|
||||||
return std::nullopt; // Already added an API error
|
if(!connected) {
|
||||||
|
return std::nullopt; // Already added an API error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma pack(push, 2)
|
#pragma pack(push, 2)
|
||||||
@@ -1000,6 +924,36 @@ std::shared_ptr<HardwareInfo> Device::getHardwareInfo(std::chrono::milliseconds
|
|||||||
return hardwareInfo;
|
return hardwareInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<MfgConfigMessage> Device::getMfgConfig() {
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = MfgConfigMessage::EncodeArgumentsForGet();
|
||||||
|
|
||||||
|
auto response = com->waitForMessageSync(
|
||||||
|
[this, payload]() {
|
||||||
|
return com->sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::MfgConfig),
|
||||||
|
std::chrono::milliseconds(250)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::Timeout, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mfgConfig = std::dynamic_pointer_cast<MfgConfigMessage>(response);
|
||||||
|
if(!mfgConfig) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mfgConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<uint64_t> Device::readLogicalDisk(uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, Disk::MemoryType memType) {
|
std::optional<uint64_t> Device::readLogicalDisk(uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, Disk::MemoryType memType) {
|
||||||
if(!into || timeout <= std::chrono::milliseconds(0)) {
|
if(!into || timeout <= std::chrono::milliseconds(0)) {
|
||||||
@@ -1977,11 +1931,9 @@ void Device::stopScriptStatusThreadIfNecessary(std::unique_lock<std::mutex> lk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lifetime Device::suppressDisconnects() {
|
Lifetime Device::suppressDisconnects() {
|
||||||
std::lock_guard<std::mutex> lk(heartbeatMutex);
|
stopHeartbeat();
|
||||||
heartbeatSuppressedByUser++;
|
|
||||||
return Lifetime([this] {
|
return Lifetime([this] {
|
||||||
std::lock_guard<std::mutex> lk2(heartbeatMutex);
|
startHeartbeat();
|
||||||
heartbeatSuppressedByUser--;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2117,6 +2069,18 @@ std::optional<EthPhyMessage> Device::sendEthPhyMsg(const EthPhyMessage& message,
|
|||||||
return std::make_optional<EthPhyMessage>(*retMsg);
|
return std::make_optional<EthPhyMessage>(*retMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::sendSPIPortKeyOperation(uint8_t portIndex, SPIPortKeyMessage::Operation op, std::array<uint8_t, 16> key) {
|
||||||
|
std::vector<uint8_t> args(sizeof(SPIPortKeyMessage::SPIPortKeyPacket));
|
||||||
|
auto& params = *reinterpret_cast<SPIPortKeyMessage::SPIPortKeyPacket*>(args.data());
|
||||||
|
params.op = op;
|
||||||
|
params.portIndex = portIndex;
|
||||||
|
std::copy(key.begin(), key.end(), params.key);
|
||||||
|
if(!com->sendCommand(ExtendedCommand::ExecuteSPIPortKeyOperation, args)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<bool> Device::SetRootDirectoryEntryFlags(uint8_t mask, uint8_t values, uint32_t collectionEntryByteAddress)
|
std::optional<bool> Device::SetRootDirectoryEntryFlags(uint8_t mask, uint8_t values, uint32_t collectionEntryByteAddress)
|
||||||
{
|
{
|
||||||
if(!supportsWiVI())
|
if(!supportsWiVI())
|
||||||
@@ -2246,6 +2210,45 @@ bool Device::setRTC(const std::chrono::time_point<std::chrono::system_clock>& ti
|
|||||||
return m51msg->data.front();
|
return m51msg->data.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::vector<uint8_t>> Device::getPCBSerial() {
|
||||||
|
auto serialMsg = com->getSerialNumberSync();
|
||||||
|
if(!serialMsg || !serialMsg->hasPCBSerial) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::vector<uint8_t>(serialMsg->pcbSerial, serialMsg->pcbSerial + sizeof(serialMsg->pcbSerial));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unordered_map<Network::NetID, MACAddress> Device::getMACAddresses() {
|
||||||
|
if(supportsGetAllMACAddresses()) {
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
auto msg = com->waitForMessageSync(
|
||||||
|
[this](){ return com->sendCommand(ExtendedCommand::GetAllMACAddresses, {}); },
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::AllMACAddresses),
|
||||||
|
std::chrono::milliseconds(100)
|
||||||
|
);
|
||||||
|
if(msg) {
|
||||||
|
const auto typed = std::dynamic_pointer_cast<AllMACAddressesMessage>(msg);
|
||||||
|
if(typed)
|
||||||
|
return typed->addresses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto serialMsg = com->getSerialNumberSync();
|
||||||
|
if(!serialMsg || !serialMsg->hasMacAddress)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
std::unordered_map<Network::NetID, MACAddress> addresses;
|
||||||
|
auto addr = serialMsg->macAddress;
|
||||||
|
MACAddress arrAddr;
|
||||||
|
std::copy(addr, addr + MACAddressLength, arrAddr.begin());
|
||||||
|
addresses.emplace(std::make_pair(Network::NetID::ETHERNET_01, arrAddr));
|
||||||
|
return addresses;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<std::set<SupportedFeature>> Device::getSupportedFeatures() {
|
std::optional<std::set<SupportedFeature>> Device::getSupportedFeatures() {
|
||||||
auto timeout = std::chrono::milliseconds(100);
|
auto timeout = std::chrono::milliseconds(100);
|
||||||
std::shared_ptr<Message> msg = com->waitForMessageSync(
|
std::shared_ptr<Message> msg = com->waitForMessageSync(
|
||||||
@@ -3247,11 +3250,12 @@ bool Device::findVSAOffsetFromTimepoint(ICSClock::time_point point, uint64_t& vs
|
|||||||
std::shared_ptr<VSA> midRecord;
|
std::shared_ptr<VSA> midRecord;
|
||||||
auto midRecordStatus = parser.getRecordFromBytes(buffer.data(), Disk::SectorSize, midRecord);
|
auto midRecordStatus = parser.getRecordFromBytes(buffer.data(), Disk::SectorSize, midRecord);
|
||||||
switch(midRecordStatus) {
|
switch(midRecordStatus) {
|
||||||
case VSAParser::RecordParseStatus::NotARecordStart:
|
case VSAParser::RecordParseStatus::NotARecordStart: {
|
||||||
// This part of the buffer does not contain records
|
// This part of the buffer does not contain records
|
||||||
rightIndex = midIndex - 1;
|
rightIndex = midIndex - 1;
|
||||||
continue;
|
continue;
|
||||||
case VSAParser::RecordParseStatus::ConsecutiveExtended:
|
}
|
||||||
|
case VSAParser::RecordParseStatus::ConsecutiveExtended: {
|
||||||
// We dropped in the middle of an extended message record
|
// We dropped in the middle of an extended message record
|
||||||
auto extendedRecord = std::dynamic_pointer_cast<VSAExtendedMessage>(midRecord);
|
auto extendedRecord = std::dynamic_pointer_cast<VSAExtendedMessage>(midRecord);
|
||||||
uint64_t pos = readPos;
|
uint64_t pos = readPos;
|
||||||
@@ -3266,6 +3270,9 @@ bool Device::findVSAOffsetFromTimepoint(ICSClock::time_point point, uint64_t& vs
|
|||||||
midIndex = (pos - firstOffset) / Disk::SectorSize;
|
midIndex = (pos - firstOffset) / Disk::SectorSize;
|
||||||
midRecord = extendedRecord;
|
midRecord = extendedRecord;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(midIndex <= leftIndex) {
|
if(midIndex <= leftIndex) {
|
||||||
// Extended records cause problems with binary search
|
// Extended records cause problems with binary search
|
||||||
@@ -3688,6 +3695,15 @@ bool Device::requestTC10Sleep(Network::NetID network) {
|
|||||||
return typed->response == ExtendedResponse::OK;
|
return typed->response == ExtendedResponse::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::reboot(bool safe) {
|
||||||
|
if(!supportsReboot()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// The device reboots in response to this command, so no reply is expected.
|
||||||
|
return com->sendCommand(ExtendedCommand::Reboot, { uint8_t(safe ? 1 : 0) });
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<TC10StatusMessage> Device::getTC10Status(Network::NetID network) {
|
std::optional<TC10StatusMessage> Device::getTC10Status(Network::NetID network) {
|
||||||
if(!supportsTC10()) {
|
if(!supportsTC10()) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
@@ -3809,7 +3825,7 @@ bool Device::formatDisk(const DiskDetails& config, const DiskFormatProgress& han
|
|||||||
return com->sendCommand(ExtendedCommand::DiskFormatProgress, {});
|
return com->sendCommand(ExtendedCommand::DiskFormatProgress, {});
|
||||||
},
|
},
|
||||||
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::DiskFormatProgress),
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::DiskFormatProgress),
|
||||||
std::chrono::milliseconds(200)
|
std::chrono::milliseconds(5000)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!response) {
|
if(!response) {
|
||||||
@@ -3901,7 +3917,7 @@ std::shared_ptr<DiskDetails> Device::getDiskDetails(std::chrono::milliseconds ti
|
|||||||
|
|
||||||
[[nodiscard]] std::optional<int> Device::lockNetworks(const std::set<Network::NetID>& networks, uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
[[nodiscard]] std::optional<int> Device::lockNetworks(const std::set<Network::NetID>& networks, uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -3951,7 +3967,7 @@ std::shared_ptr<DiskDetails> Device::getDiskDetails(std::chrono::milliseconds ti
|
|||||||
|
|
||||||
bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3991,7 +4007,7 @@ bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
|||||||
|
|
||||||
std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetID network)
|
std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetID network)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -4013,7 +4029,7 @@ std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetI
|
|||||||
|
|
||||||
[[nodiscard]] std::optional<int> Device::lockAllNetworks(uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
[[nodiscard]] std::optional<int> Device::lockAllNetworks(uint32_t priority, uint32_t ttlMs, NetworkMutexType type, std::function<void(std::shared_ptr<Message>)>&& on_event)
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -4060,7 +4076,7 @@ std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetI
|
|||||||
|
|
||||||
bool Device::unlockAllNetworks()
|
bool Device::unlockAllNetworks()
|
||||||
{
|
{
|
||||||
if(!supportsNetworkMutex()) {
|
if(!supportsNetworkMutex) {
|
||||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4097,3 +4113,270 @@ bool Device::unlockAllNetworks()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::startHeartbeat() {
|
||||||
|
if(!heartbeat)
|
||||||
|
heartbeat = std::make_unique<Heartbeat>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::stopHeartbeat() {
|
||||||
|
heartbeat.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::restartHeartbeat() {
|
||||||
|
stopHeartbeat();
|
||||||
|
startHeartbeat();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::iso15765Enable(const Network& network) {
|
||||||
|
return J2534_EnableIso15765(network, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::iso15765DisableAll(void) {
|
||||||
|
bool ok = true;
|
||||||
|
for(const auto& slot : iso15765FirmwareEnabled)
|
||||||
|
{
|
||||||
|
if (slot.second)
|
||||||
|
{
|
||||||
|
if (!J2534_EnableIso15765(slot.first, false))
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::iso15765TransmitMessage(const Network& network, const Iso15765MessageArgs& msg, const std::chrono::milliseconds& timeout) {
|
||||||
|
if (!isOnline())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(iso15765FirmwareEnabled.find(network) == iso15765FirmwareEnabled.end() || !iso15765FirmwareEnabled[network])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool result;
|
||||||
|
Iso15765TxSetupMessage setupMsg;
|
||||||
|
|
||||||
|
//Set the network ID to use
|
||||||
|
if(const auto& coreMiniId = network.getCoreMini())
|
||||||
|
setupMsg.setCoreMiniId((uint16_t)*coreMiniId);
|
||||||
|
|
||||||
|
const uint8_t txIndex = msg.getTxIndex();
|
||||||
|
setupMsg.setIdx(txIndex);
|
||||||
|
|
||||||
|
setupMsg.setId(msg.getArbId().Id);
|
||||||
|
setupMsg.setFcId(msg.getFlowControlArbId().Id);
|
||||||
|
setupMsg.setFcIdMask(msg.getFlowControlArbIdMask());
|
||||||
|
|
||||||
|
setupMsg.setFsTimeout(msg.getFsTimeout());
|
||||||
|
setupMsg.setFsWait(msg.getFsWaitTimeout());
|
||||||
|
|
||||||
|
const uint32_t messageLength = (uint32_t)msg.getData().size();
|
||||||
|
setupMsg.setMessageLength(messageLength);
|
||||||
|
setupMsg.setIs29BitEnabled(msg.getArbId().Is29Bit);
|
||||||
|
setupMsg.setIsFc29BitEnabled(msg.getFlowControlArbId().Is29Bit);
|
||||||
|
if(const auto& extAddress = msg.getExtendedAddress())
|
||||||
|
{
|
||||||
|
setupMsg.setExtAddressEnabled(true);
|
||||||
|
setupMsg.setExtendedAddress(*extAddress);
|
||||||
|
}
|
||||||
|
if(const auto& extFcAddress = msg.getFlowControlExtendedAddress())
|
||||||
|
{
|
||||||
|
setupMsg.setFcExtAddressEnabled(true);
|
||||||
|
setupMsg.setFlowControlExtendedAddress(*extFcAddress);
|
||||||
|
}
|
||||||
|
if(const auto& stMin = msg.getStMin())
|
||||||
|
{
|
||||||
|
setupMsg.setOverrideStMin(true);
|
||||||
|
setupMsg.setStMin(*stMin);
|
||||||
|
}
|
||||||
|
if(const auto& blockSize = msg.getBlockSize())
|
||||||
|
{
|
||||||
|
setupMsg.setOverrideBlockSize(true);
|
||||||
|
setupMsg.setBlockSize(*blockSize);
|
||||||
|
}
|
||||||
|
if(const auto& padding = msg.getPaddingValue())
|
||||||
|
{
|
||||||
|
setupMsg.setPaddingEnabled(true);
|
||||||
|
setupMsg.setPadding(*padding);
|
||||||
|
}
|
||||||
|
setupMsg.setIsBrsEnabled(msg.getIsBrsEnabled());
|
||||||
|
setupMsg.setIsCanFd(msg.getIsCanFd());
|
||||||
|
setupMsg.setTxDl(msg.getTxDl());
|
||||||
|
|
||||||
|
{
|
||||||
|
uint32_t octetsToSend = messageLength;
|
||||||
|
const uint8_t* payload = msg.getData().data();
|
||||||
|
uint32_t offset = 0;
|
||||||
|
|
||||||
|
result = J2534_Transaction(network, std::move(setupMsg), timeout);
|
||||||
|
while(result && octetsToSend)
|
||||||
|
{
|
||||||
|
const uint16_t chunkSize = (uint16_t)std::min((uint32_t)Iso15765TxDataMessage::MaxDataLength, octetsToSend);
|
||||||
|
|
||||||
|
Iso15765TxDataMessage dataMsg;
|
||||||
|
dataMsg.setIdx(txIndex);
|
||||||
|
dataMsg.setOffset(offset);
|
||||||
|
dataMsg.setData(&payload[offset], chunkSize);
|
||||||
|
|
||||||
|
result = J2534_Transaction(network, std::move(dataMsg), timeout);
|
||||||
|
|
||||||
|
offset += chunkSize;
|
||||||
|
octetsToSend -= chunkSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::iso15765SetupRxFlowControl(const Network& network, const Iso15765MessageArgs& msg) {
|
||||||
|
if (!isOnline())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(iso15765FirmwareEnabled.find(network) == iso15765FirmwareEnabled.end() || !iso15765FirmwareEnabled[network])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
J2534SetupIso15765FlowControlMessage rxFlowControl;
|
||||||
|
|
||||||
|
rxFlowControl.setIsBrsEnabled(msg.getIsBrsEnabled());
|
||||||
|
rxFlowControl.setIsCanFd(msg.getIsCanFd());
|
||||||
|
rxFlowControl.setIdx(msg.getTxIndex());
|
||||||
|
if(const auto& coreMiniId = network.getCoreMini())
|
||||||
|
rxFlowControl.setCoreMiniId((uint16_t)*coreMiniId);
|
||||||
|
rxFlowControl.setEnable(true);
|
||||||
|
if(const auto& blockSize = msg.getBlockSize())
|
||||||
|
{
|
||||||
|
rxFlowControl.setBlockSize(*blockSize);
|
||||||
|
}
|
||||||
|
rxFlowControl.setCfTimeout(msg.getCfTimeout());
|
||||||
|
rxFlowControl.setFlowControlTransmissionEnabled(msg.getIsFlowControlEnabled());
|
||||||
|
if(const auto& extAddress = msg.getExtendedAddress())
|
||||||
|
{
|
||||||
|
rxFlowControl.setExtendedAddress(*extAddress);
|
||||||
|
rxFlowControl.setExtAddressEnabled(true);
|
||||||
|
}
|
||||||
|
if(const auto& fcExtAddress = msg.getFlowControlExtendedAddress())
|
||||||
|
{
|
||||||
|
rxFlowControl.setFlowControlExtendedAddress(*fcExtAddress);
|
||||||
|
rxFlowControl.setFcExtAddressEnabled(true);
|
||||||
|
}
|
||||||
|
rxFlowControl.setFcId(msg.getFlowControlArbId().Id);
|
||||||
|
rxFlowControl.setIsFc29BitEnabled(msg.getFlowControlArbId().Is29Bit);
|
||||||
|
rxFlowControl.setIs29BitEnabled(msg.getArbId().Is29Bit);
|
||||||
|
rxFlowControl.setId(msg.getArbId().Id);
|
||||||
|
rxFlowControl.setIdMask(msg.getFlowControlArbIdMask());
|
||||||
|
if(const auto& padding = msg.getPaddingValue())
|
||||||
|
{
|
||||||
|
rxFlowControl.setPadding(*padding);
|
||||||
|
rxFlowControl.setPaddingEnabled(true);
|
||||||
|
}
|
||||||
|
if(const auto& stMin = msg.getStMin())
|
||||||
|
{
|
||||||
|
rxFlowControl.setStMin(*stMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
return J2534_Transaction(network, std::move(rxFlowControl), std::chrono::milliseconds(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::J2534_Transaction(const Network& network, J2534CommandMessage&& msg, const std::chrono::milliseconds& timeout) {
|
||||||
|
msg.network = network;
|
||||||
|
if (timeout.count())
|
||||||
|
{
|
||||||
|
static std::shared_ptr<MessageFilter> filter = std::make_shared<Main51MessageFilter>(Command::J2534Command);
|
||||||
|
const auto& response = com->waitForMessageSync([&](void)
|
||||||
|
{
|
||||||
|
return com->sendCommand(msg.command, msg.getArgumentData());
|
||||||
|
}, filter, timeout);
|
||||||
|
|
||||||
|
if (!response)
|
||||||
|
{
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto responseMsg = std::dynamic_pointer_cast<Main51Message>(response);
|
||||||
|
if (!responseMsg || responseMsg->command != Command::J2534Command)
|
||||||
|
{
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return com->sendCommand(msg.command, msg.getArgumentData());
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: responseMsg->data.front()
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Device::J2534_ClearRxFilters(const Network& network)
|
||||||
|
{
|
||||||
|
return J2534_Transaction(network, J2534CommandMessage(J2534CommandMessage::J2534Command::SetupClearCanRxFilters, { (uint8_t)0 /* is this necessary? */}), std::chrono::milliseconds(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::J2534_SetupCanRxFilter(const Network& network, const J2534_RxCanFilter& rxCanFilter)
|
||||||
|
{
|
||||||
|
return J2534_Transaction(network, J2534SetupCanRxFilteringMessage(rxCanFilter), std::chrono::milliseconds(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::J2534_EnableFiltering(const Network& network, const bool enable)
|
||||||
|
{
|
||||||
|
return J2534_Transaction(network, J2534EnableFilteringMessage(enable), std::chrono::milliseconds(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool Device::J2534_EnableIso15765(const Network& network, const bool enable)
|
||||||
|
{
|
||||||
|
if (iso15765FirmwareEnabled[network] == enable)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!J2534_Transaction(network, J2534EnableMessage(enable), std::chrono::milliseconds(0)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
iso15765FirmwareEnabled[network] = enable;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
// Turn OFF filtering of CAN messages in the firmware
|
||||||
|
return J2534_EnableFirmwareUsbPassFilters(network, false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::J2534_ClearRxFilter(const Network& network, unsigned int iIndex)
|
||||||
|
{
|
||||||
|
if (const auto& slot = iso15765FirmwareEnabled.find(network); slot != iso15765FirmwareEnabled.end() && slot->second)
|
||||||
|
{
|
||||||
|
J2534_RxCanFilter rxFilter;
|
||||||
|
memset(&rxFilter, 0, sizeof(rxFilter));
|
||||||
|
rxFilter.idx = (uint16_t)iIndex;
|
||||||
|
return J2534_SetupCanRxFilter(network, rxFilter);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::J2534_EnableFirmwareUsbPassFilters(const Network& network, const bool enable)
|
||||||
|
{
|
||||||
|
const auto& slot = iso15765FirmwareEnabled.find(network);
|
||||||
|
if (slot == iso15765FirmwareEnabled.end())
|
||||||
|
return false;
|
||||||
|
//check for disconnect here!
|
||||||
|
if (!slot->second)
|
||||||
|
{
|
||||||
|
// Tried to shut-off Rx table message filtering but FW ISO15765 was not enabled
|
||||||
|
return true; //just ignore it, no filtering can occur anyway
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable) //turning ON filtering in the Firmware based on the rx table
|
||||||
|
{
|
||||||
|
//Rx table message filtering is on by default in the firmware when m_bISO15765_FW_Enabled is true
|
||||||
|
//need to check here to see if we set index 0 to a PASS all filter (i.e. turned off USB filtering)
|
||||||
|
if (!J2534_ClearRxFilters(network))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// New "filtering enable" mechanism - old firmware ignores this frame
|
||||||
|
return J2534_EnableFiltering(network, enable);
|
||||||
|
}
|
||||||
|
|||||||
+10
-6
@@ -165,10 +165,6 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
makeIfSerialMatches<RADA2B>(dev, newFoundDevices);
|
makeIfSerialMatches<RADA2B>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __RADCOMET_H_
|
|
||||||
makeIfSerialRangeMatches<RADComet>(dev, newFoundDevices);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __RADCOMET2_H_
|
#ifdef __RADCOMET2_H_
|
||||||
makeIfSerialRangeMatches<RADComet2>(dev, newFoundDevices);
|
makeIfSerialRangeMatches<RADComet2>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
@@ -245,6 +241,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
makeIfSerialMatches<RADSupermoon>(dev, newFoundDevices);
|
makeIfSerialMatches<RADSupermoon>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __RADWBMS_H_
|
||||||
|
makeIfSerialMatches<RADwBMS>(dev, newFoundDevices);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN3_H_
|
#ifdef __VALUECAN3_H_
|
||||||
makeIfSerialRangeMatches<ValueCAN3>(dev, newFoundDevices);
|
makeIfSerialRangeMatches<ValueCAN3>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
@@ -340,8 +340,8 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
|||||||
RADA2B::DEVICE_TYPE,
|
RADA2B::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __RADCOMET_H_
|
#ifdef __RADCOMET2_H_
|
||||||
RADComet::DEVICE_TYPE,
|
RADComet2::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __RADCOMET3_H_
|
#ifdef __RADCOMET3_H_
|
||||||
@@ -408,6 +408,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
|||||||
RADSupermoon::DEVICE_TYPE,
|
RADSupermoon::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __RADWBMS_H_
|
||||||
|
RADwBMS::DEVICE_TYPE,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN3_H_
|
#ifdef __VALUECAN3_H_
|
||||||
ValueCAN3::DEVICE_TYPE,
|
ValueCAN3::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+189
-22
@@ -1,9 +1,16 @@
|
|||||||
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/idevicesettings.h"
|
#include "icsneo/device/idevicesettings.h"
|
||||||
#include "icsneo/communication/message/filter/main51messagefilter.h"
|
#include "icsneo/communication/message/filter/main51messagefilter.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
|
IDeviceSettings::IDeviceSettings(Device* device, size_t size)
|
||||||
|
: device(device), report(device->report), structSize(size) {}
|
||||||
|
|
||||||
|
IDeviceSettings::IDeviceSettings(warn_t createInoperableSettings, Device* device)
|
||||||
|
: disabled(true), readonly(true), report(device->report), structSize(0) { (void)createInoperableSettings; }
|
||||||
|
|
||||||
std::optional<uint16_t> IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settings) {
|
std::optional<uint16_t> IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settings) {
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(settings.data());
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(settings.data());
|
||||||
size_t words = settings.size();
|
size_t words = settings.size();
|
||||||
@@ -166,7 +173,7 @@ bool IDeviceSettings::refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> rxSettings;
|
std::vector<uint8_t> rxSettings;
|
||||||
bool ret = com->getSettingsSync(rxSettings);
|
bool ret = device->com->getSettingsSync(rxSettings);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
@@ -231,11 +238,11 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
||||||
|
|
||||||
// Pause I/O with the device while the settings are applied
|
// Pause I/O with the device while the settings are applied
|
||||||
applyingSettings = true;
|
device->stopHeartbeat();
|
||||||
|
|
||||||
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return device->com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
||||||
|
|
||||||
if(!msg || msg->data[0] != 1) { // We did not receive a response
|
if(!msg || msg->data[0] != 1) { // We did not receive a response
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
@@ -259,9 +266,9 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
||||||
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
||||||
|
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return device->com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
||||||
if(!msg || msg->data[0] != 1) {
|
if(!msg || msg->data[0] != 1) {
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
if(refresh()) {
|
if(refresh()) {
|
||||||
@@ -272,12 +279,12 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!temporary) {
|
if(!temporary) {
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::SaveSettings);
|
return device->com->sendCommand(Command::SaveSettings);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyingSettings = false;
|
device->startHeartbeat();
|
||||||
|
|
||||||
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
||||||
|
|
||||||
@@ -299,11 +306,11 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyingSettings = true;
|
device->stopHeartbeat();
|
||||||
|
|
||||||
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
|
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::SetDefaultSettings);
|
return device->com->sendCommand(Command::SetDefaultSettings);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetDefaultSettings), std::chrono::milliseconds(1000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetDefaultSettings), std::chrono::milliseconds(5000)));
|
||||||
if(!msg || msg->data[0] != 1) {
|
if(!msg || msg->data[0] != 1) {
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
if(refresh()) {
|
if(refresh()) {
|
||||||
@@ -336,9 +343,9 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
bytestream[6] = (uint8_t)(*gsChecksum >> 8);
|
||||||
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
memcpy(bytestream.data() + 7, getMutableRawStructurePointer(), settings.size());
|
||||||
|
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return device->com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(5000)));
|
||||||
if(!msg || msg->data[0] != 1) {
|
if(!msg || msg->data[0] != 1) {
|
||||||
// Attempt to get the settings from the device so we're up to date if possible
|
// Attempt to get the settings from the device so we're up to date if possible
|
||||||
if(refresh()) {
|
if(refresh()) {
|
||||||
@@ -349,12 +356,12 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!temporary) {
|
if(!temporary) {
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(device->com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::SaveSettings);
|
return device->com->sendCommand(Command::SaveSettings);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SaveSettings), std::chrono::milliseconds(5000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyingSettings = false;
|
device->startHeartbeat();
|
||||||
|
|
||||||
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
refresh(); // Refresh our buffer with what the device has, whether we were successful or not
|
||||||
|
|
||||||
@@ -945,4 +952,164 @@ template<typename T> bool IDeviceSettings::applyStructure(const T& newStructure)
|
|||||||
|
|
||||||
memcpy(settings.data(), &newStructure, structSize);
|
memcpy(settings.data(), &newStructure, structSize);
|
||||||
return apply();
|
return apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setMiscIOAnalogOutputEnabled(uint8_t pin, bool enabled) {
|
||||||
|
(void)pin;
|
||||||
|
(void)enabled;
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setMiscIOAnalogOutput(uint8_t pin, MiscIOAnalogVoltage voltage) {
|
||||||
|
(void)pin;
|
||||||
|
(void)voltage;
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::optional<RADGPTPProfile> IDeviceSettings::getGPTPProfile() const {
|
||||||
|
const auto* gptp = getGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return static_cast<RADGPTPProfile>(gptp->profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setGPTPProfile(RADGPTPProfile profile) {
|
||||||
|
auto* gptp = getMutableGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
gptp->profile = static_cast<uint8_t>(profile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<RADGPTPRole> IDeviceSettings::getGPTPRole() const {
|
||||||
|
const auto* gptp = getGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return static_cast<RADGPTPRole>(gptp->gptpPortRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setGPTPRole(RADGPTPRole role) {
|
||||||
|
auto* gptp = getMutableGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
gptp->gptpPortRole = static_cast<uint8_t>(role);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<uint8_t> IDeviceSettings::getGPTPEnabledPort() const {
|
||||||
|
const auto* gptp = getGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return gptp->gptpEnabledPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setGPTPEnabledPort(uint8_t port) {
|
||||||
|
auto* gptp = getMutableGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
gptp->gptpEnabledPort = port;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<bool> IDeviceSettings::isGPTPClockSyntonizationEnabled() const {
|
||||||
|
const auto* gptp = getGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return gptp->enableClockSyntonization != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setGPTPClockSyntonizationEnabled(bool enable) {
|
||||||
|
auto* gptp = getMutableGPTPSettings();
|
||||||
|
if(!gptp) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
gptp->enableClockSyntonization = enable ? 1 : 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<bool> IDeviceSettings::getLinuxBootEnabled() {
|
||||||
|
const auto* os = getLinuxSettings();
|
||||||
|
if(os == nullptr) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return os->allowBoot != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setLinuxBootEnabled(bool enabled) {
|
||||||
|
auto os = getMutableLinuxSettings();
|
||||||
|
if(!os) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
(*os)->allowBoot = enabled ? 1 : 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<bool> IDeviceSettings::getExternalWifiAntennaEnabled() {
|
||||||
|
const auto* os = getLinuxSettings();
|
||||||
|
if(os == nullptr) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return os->useExternalWifiAntenna != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setExternalWifiAntennaEnabled(bool enabled) {
|
||||||
|
auto os = getMutableLinuxSettings();
|
||||||
|
if(!os) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
(*os)->useExternalWifiAntenna = enabled ? 1 : 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<LinuxConfigurationPort> IDeviceSettings::getLinuxConfigurationPort() {
|
||||||
|
const auto* os = getLinuxSettings();
|
||||||
|
if(os == nullptr) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::EventWarning);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
switch(static_cast<LinuxConfigurationPort>(os->ethConfigurationPort)) {
|
||||||
|
case LinuxConfigurationPort::ETH01:
|
||||||
|
return LinuxConfigurationPort::ETH01;
|
||||||
|
case LinuxConfigurationPort::USB:
|
||||||
|
default: // Any other value means the configuration interface is over USB
|
||||||
|
return LinuxConfigurationPort::USB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setLinuxConfigurationPort(LinuxConfigurationPort port) {
|
||||||
|
switch(port) {
|
||||||
|
case LinuxConfigurationPort::USB:
|
||||||
|
case LinuxConfigurationPort::ETH01:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto os = getMutableLinuxSettings();
|
||||||
|
if(!os) {
|
||||||
|
report(APIEvent::Type::SettingNotAvaiableDevice, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
(*os)->ethConfigurationPort = static_cast<uint8_t>(port);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
+3
-1
@@ -7,12 +7,13 @@ 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
|
||||||
|
|
||||||
project = 'libicsneo'
|
project = 'libicsneo'
|
||||||
copyright = '2024-2025, Intrepid Control Systems, Inc.'
|
copyright = '2024-2026, Intrepid Control Systems, Inc.'
|
||||||
author = 'Intrepid Control Systems, Inc.'
|
author = 'Intrepid Control Systems, Inc.'
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
@@ -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'
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
doxygen
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
icsneoc
|
icsneoc (deprecated, use icsneoc2)
|
||||||
=======
|
============================
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
doxygen
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
=================
|
||||||
|
icsneoc2 Examples
|
||||||
|
=================
|
||||||
|
|
||||||
|
Simple
|
||||||
|
======
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/simple/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/simple/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
Supported Devices
|
||||||
|
=================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/supported_devices/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/supported_devices/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
|
||||||
|
|
||||||
|
Device Info
|
||||||
|
===========
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/device_info/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/device_info/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
LIN
|
||||||
|
===
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/lin/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/lin/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
LIN Transmit
|
||||||
|
============
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/lin_transmit/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/lin_transmit/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
Ethernet Transmit
|
||||||
|
=================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/ethernet_transmit/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/ethernet_transmit/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
Ethernet Receive
|
||||||
|
================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/ethernet_receive/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/ethernet_receive/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
Ethernet Status
|
||||||
|
===============
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/ethernet_status/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/ethernet_status/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
T1S Loopback
|
||||||
|
============
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/t1s_loopback/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/t1s_loopback/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
TC10
|
||||||
|
====
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/tc10/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/tc10/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
gPTP
|
||||||
|
====
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/gptp/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/gptp/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
PerfTest
|
||||||
|
========
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/perf_test/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/perf_test/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
|
Termination Groups
|
||||||
|
==================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/c2/termination/src/main.c>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/c2/termination/src/main.c
|
||||||
|
:language: c
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
icsneoc2
|
||||||
|
========
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
installation
|
||||||
|
examples
|
||||||
|
api
|
||||||
@@ -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.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
doxygen
|
||||||
@@ -6,7 +6,7 @@ Prerequisites
|
|||||||
=============
|
=============
|
||||||
|
|
||||||
- Python 3.8 or higher
|
- Python 3.8 or higher
|
||||||
- icsneopy library installed
|
- icsneopy installed (see :doc:`installation`)
|
||||||
- CAN hardware device connected
|
- CAN hardware device connected
|
||||||
|
|
||||||
:download:`Download complete example <../../examples/python/can/can_complete_example.py>`
|
:download:`Download complete example <../../examples/python/can/can_complete_example.py>`
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Prerequisites
|
|||||||
=============
|
=============
|
||||||
|
|
||||||
- Python 3.8 or higher
|
- Python 3.8 or higher
|
||||||
- icsneopy library installed
|
- icsneopy installed (see :doc:`installation`)
|
||||||
- Intrepid Control Systems Device
|
- Intrepid Control Systems Device
|
||||||
|
|
||||||
:download:`Download complete example <../../examples/python/ethernet/ethernet_complete_example.py>`
|
:download:`Download complete example <../../examples/python/ethernet/ethernet_complete_example.py>`
|
||||||
|
|||||||
@@ -27,6 +27,15 @@ Complete CAN Example
|
|||||||
:language: python
|
:language: python
|
||||||
|
|
||||||
|
|
||||||
|
LiveData Subscription and Monitoring
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/python/livedata/livedata_example.py>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/livedata/livedata_example.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
|
|
||||||
Transmit Ethernet frames on Ethernet 01
|
Transmit Ethernet frames on Ethernet 01
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
@@ -74,3 +83,27 @@ Device Firmware/Chip Versions
|
|||||||
|
|
||||||
.. literalinclude:: ../../examples/python/device/chip_versions.py
|
.. literalinclude:: ../../examples/python/device/chip_versions.py
|
||||||
:language: python
|
:language: python
|
||||||
|
|
||||||
|
SPI Example for 10BASE-T1S
|
||||||
|
=============================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/python/spi/spi_example.py>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/spi/spi_example.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
|
10BASE-T1S Settings Configuration
|
||||||
|
=================================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/python/t1s/t1s_settings.py>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/t1s/t1s_settings.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
|
Analog Output Control
|
||||||
|
=====================
|
||||||
|
|
||||||
|
:download:`Download example <../../examples/python/analog_out/analog_out_basic.py>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/analog_out/analog_out_basic.py
|
||||||
|
:language: python
|
||||||
|
|||||||
@@ -0,0 +1,191 @@
|
|||||||
|
=======================
|
||||||
|
FlexRay Getting Started
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Prerequisites
|
||||||
|
=============
|
||||||
|
|
||||||
|
- icsneopy installed (see :doc:`installation`)
|
||||||
|
- FlexRay hardware device connected (e.g., Fire3 Flexray)
|
||||||
|
- Proper FlexRay bus termination (100Ω on each channel end)
|
||||||
|
|
||||||
|
Physical Hardware Setup for Two-Node Testing
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
For testing the basic transmit and receive examples with a single device:
|
||||||
|
|
||||||
|
- Hardware: Device with dual FlexRay controllers (e.g., neoVI FIRE 3 Flexray)
|
||||||
|
- Connection: FLEXRAY_01 Channel A looped to FLEXRAY_02 Channel A
|
||||||
|
- Termination: 100Ω termination resistors on both ends of the loopback
|
||||||
|
- Cable: Use proper FlexRay twisted pair cable (impedance matched)
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The basic transmit/receive examples are configured for this loopback setup
|
||||||
|
where both controllers act as coldstart nodes. For use on an existing
|
||||||
|
FlexRay network, see the passive monitoring configuration notes in the
|
||||||
|
receive example.
|
||||||
|
|
||||||
|
FlexRay Coldstart
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
FlexRay networks require at least one "coldstart node" to initialize the network timing.
|
||||||
|
The coldstart node is responsible for starting the FlexRay communication cycle.
|
||||||
|
|
||||||
|
For a complete standalone coldstart example, see the Additional Examples section below.
|
||||||
|
|
||||||
|
Basic Setup
|
||||||
|
===========
|
||||||
|
|
||||||
|
1. Import the library and find FlexRay device:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import icsneopy
|
||||||
|
|
||||||
|
devices = icsneopy.find_all_devices()
|
||||||
|
|
||||||
|
# Find a device with FlexRay support
|
||||||
|
device = None
|
||||||
|
for dev in devices:
|
||||||
|
if dev.get_extension("FlexRay"):
|
||||||
|
device = dev
|
||||||
|
break
|
||||||
|
|
||||||
|
if not device:
|
||||||
|
raise RuntimeError("No FlexRay-capable device found")
|
||||||
|
|
||||||
|
2. Configure FlexRay controller:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/flexray/flexray_transmit_basic.py
|
||||||
|
:language: python
|
||||||
|
:lines: 12-111
|
||||||
|
|
||||||
|
3. Open device and go online:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
if not device.open():
|
||||||
|
raise RuntimeError("Failed to open device")
|
||||||
|
|
||||||
|
if not device.go_online():
|
||||||
|
raise RuntimeError("Failed to go online")
|
||||||
|
|
||||||
|
Transmitting FlexRay Frames
|
||||||
|
============================
|
||||||
|
|
||||||
|
This example demonstrates a coldstart node that initiates a FlexRay network
|
||||||
|
and transmits simulated sensor data continuously in slot 1.
|
||||||
|
|
||||||
|
**Hardware Setup**: FLEXRAY_01 looped to FLEXRAY_02
|
||||||
|
|
||||||
|
**Usage**:
|
||||||
|
1. Start the receive example first
|
||||||
|
2. Start this transmit example second
|
||||||
|
3. Network will initialize and frames will be transmitted
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/flexray/flexray_transmit_basic.py
|
||||||
|
:language: python
|
||||||
|
:lines: 113-170
|
||||||
|
|
||||||
|
Key Configuration Parameters:
|
||||||
|
|
||||||
|
- **slotid**: The FlexRay slot ID for transmission (1-2047 for static segment)
|
||||||
|
- **cycle**: The FlexRay cycle number (0-63)
|
||||||
|
- **cycle_repetition**: How often the frame repeats (1 = every cycle, 2 = every other cycle)
|
||||||
|
- **channel**: Transmission channel (A, B, or AB for both)
|
||||||
|
- **key_slot_id**: Must be unique per node on the network
|
||||||
|
- **key_slot_used_for_startup**: True for coldstart nodes
|
||||||
|
- **key_slot_used_for_sync**: True to provide synchronization frames
|
||||||
|
|
||||||
|
Receiving FlexRay Frames
|
||||||
|
=========================
|
||||||
|
|
||||||
|
This example demonstrates receiving FlexRay frames on FLEXRAY_02 Channel A.
|
||||||
|
|
||||||
|
**Hardware Setup**: FLEXRAY_01 looped to FLEXRAY_02
|
||||||
|
|
||||||
|
**Configuration Note**: This example is configured with coldstart capability
|
||||||
|
for two-node loopback testing. For passive monitoring on an existing FlexRay
|
||||||
|
network:
|
||||||
|
|
||||||
|
1. Set ``key_slot_used_for_startup = False`` in the controller configuration
|
||||||
|
2. Remove the ``controller.set_allow_coldstart(True)`` call
|
||||||
|
3. Ensure all cluster parameters match the existing network
|
||||||
|
4. The node will sync and receive without transmitting
|
||||||
|
|
||||||
|
**Usage**:
|
||||||
|
1. Start this receive example first
|
||||||
|
2. Start the transmit example second
|
||||||
|
3. Frames from slot 1 will be displayed with hex and decimal payload views
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/flexray/flexray_receive_basic.py
|
||||||
|
:language: python
|
||||||
|
:lines: 103-170
|
||||||
|
|
||||||
|
FlexRay Coldstart Configuration
|
||||||
|
================================
|
||||||
|
|
||||||
|
To use the Coldstart example, ensure the following:
|
||||||
|
|
||||||
|
Set the Flexray network in ICS Device Manager to Coldstart.
|
||||||
|
|
||||||
|
No other nodes should be present on the network during testing.
|
||||||
|
|
||||||
|
Nothing connected to Fire3 FlexRay bus.
|
||||||
|
|
||||||
|
Critical Coldstart Settings
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/flexray/flexray_coldstart.py
|
||||||
|
:language: python
|
||||||
|
:lines: 40-48
|
||||||
|
|
||||||
|
Configuration Example:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/flexray/flexray_coldstart.py
|
||||||
|
:language: python
|
||||||
|
:lines: 20-64
|
||||||
|
|
||||||
|
Setting Coldstart on Controller:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
controller.set_allow_coldstart(True)
|
||||||
|
controller.set_start_when_going_online(True)
|
||||||
|
|
||||||
|
Cleanup and Resource Management
|
||||||
|
================================
|
||||||
|
|
||||||
|
Always close the device when finished:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Your FlexRay operations here
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
device.close()
|
||||||
|
|
||||||
|
See the basic transmit and receive examples for complete implementations.
|
||||||
|
|
||||||
|
Additional Examples
|
||||||
|
===================
|
||||||
|
|
||||||
|
Transmit Basic
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Complete working example with coldstart node transmitting simulated sensor data.
|
||||||
|
|
||||||
|
All example files are available for download:
|
||||||
|
|
||||||
|
**Transmit Basic** - Coldstart node transmitting simulated sensor data
|
||||||
|
|
||||||
|
:download:`flexray_transmit_basic.py <../../examples/python/flexray/flexray_transmit_basic.py>`
|
||||||
|
|
||||||
|
**Receive Basic** - Receiving and displaying FlexRay frames with formatted output
|
||||||
|
|
||||||
|
:download:`flexray_receive_basic.py <../../examples/python/flexray/flexray_receive_basic.py>`
|
||||||
|
|
||||||
|
**Coldstart** - Standalone coldstart example demonstrating network initialization
|
||||||
|
|
||||||
|
:download:`flexray_coldstart.py <../../examples/python/flexray/flexray_coldstart.py>`
|
||||||
@@ -5,8 +5,10 @@ icsneopy
|
|||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
installation
|
||||||
can_getting_started
|
can_getting_started
|
||||||
ethernet_getting_started
|
ethernet_getting_started
|
||||||
|
flexray_getting_started
|
||||||
examples
|
examples
|
||||||
api
|
api
|
||||||
radepsilon
|
radepsilon
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
============
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
icsneopy is available on PyPI at https://pypi.org/project/icsneopy/ and can be installed with pip:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip install icsneopy
|
||||||
|
|
||||||
|
Pre-release
|
||||||
|
===========
|
||||||
|
|
||||||
|
For the latest features, install with the ``--pre`` flag to include pre-release versions:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip install --pre icsneopy
|
||||||
|
|
||||||
|
Upgrading
|
||||||
|
=========
|
||||||
|
|
||||||
|
To upgrade an existing installation:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip install --pre --upgrade icsneopy
|
||||||
|
|
||||||
|
Linux udev Rules
|
||||||
|
================
|
||||||
|
|
||||||
|
Linux users may want to install the included udev rules to run icsneopy-based
|
||||||
|
applications without root. The rules file can be found in the libicsneo source
|
||||||
|
repository at https://github.com/intrepidcs/libicsneo/.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo cp 99-intrepidcs.rules /etc/udev/rules.d/
|
||||||
@@ -13,3 +13,19 @@ 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
|
||||||
|
|
||||||
|
Linux Installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Applications that use raw Ethernet device discovery, such as PCAP-backed
|
||||||
|
discovery, need permission to open raw network sockets. Instead of running your
|
||||||
|
application with ``sudo``, grant the installed executable the required Linux
|
||||||
|
capabilities:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/your-app
|
||||||
|
|
||||||
|
Replace ``/usr/bin/your-app`` with the full path to the application executable.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,25 @@
|
|||||||
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_SUPPORTED_DEVICES_EXAMPLE "Build the C2 supported devices 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_C2_RECONNECT_EXAMPLE "Build the C2 reconnect example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_DEVICE_INFO_EXAMPLE "Build the C2 device info example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_CHIP_VERSIONS_EXAMPLE "Build the C2 chip versions example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_TERMINATION_EXAMPLE "Build the C2 termination groups example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_LIN_EXAMPLE "Build the C2 LIN example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_LIN_TRANSMIT_EXAMPLE "Build the C2 LIN transmit example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_ETHERNET_TRANSMIT_EXAMPLE "Build the C2 ethernet transmit example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_ETHERNET_RECEIVE_EXAMPLE "Build the C2 ethernet receive example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_ETHERNET_STATUS_EXAMPLE "Build the C2 ethernet status example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_T1S_LOOPBACK_EXAMPLE "Build the C2 RAD-Comet3 T1S loopback example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_TC10_EXAMPLE "Build the C2 TC10 example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_GPTP_EXAMPLE "Build the C2 gPTP settings example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_C2_PERF_TEST_EXAMPLE "Build the C2 PerfTest setting 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_DEVICE_INFO_EXAMPLE "Build the C++ device info 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)
|
||||||
option(LIBICSNEO_BUILD_CPP_LIN_EXAMPLE "Build the LIN example." ON)
|
option(LIBICSNEO_BUILD_CPP_LIN_EXAMPLE "Build the LIN example." ON)
|
||||||
@@ -14,6 +32,11 @@ option(LIBICSNEO_BUILD_CPP_APP_ERROR_EXAMPLE "Build the macsec example" ON)
|
|||||||
option(LIBICSNEO_BUILD_CPP_FLEXRAY_EXAMPLE "Build the FlexRay example." ON)
|
option(LIBICSNEO_BUILD_CPP_FLEXRAY_EXAMPLE "Build the FlexRay example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_SPI_EXAMPLE "Build the SPI example." ON)
|
option(LIBICSNEO_BUILD_CPP_SPI_EXAMPLE "Build the SPI example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_MUTEX_EXAMPLE "Build the NetworkMutex example." ON)
|
option(LIBICSNEO_BUILD_CPP_MUTEX_EXAMPLE "Build the NetworkMutex example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_CPP_ANALOG_OUT_EXAMPLE "Build the analog output example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_CPP_DISKFORMAT_EXAMPLE "Build the disk format example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_CPP_T1S_EXAMPLE "Build the T1S example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_CPP_GPTP_EXAMPLE "Build the C++ gPTP settings example." ON)
|
||||||
|
option(LIBICSNEO_BUILD_CPP_ISO15765_LOOPBACK_EXAMPLE "Build the C++ ISO15765 two-device CAN1 loopback example." ON)
|
||||||
|
|
||||||
add_compile_options(${LIBICSNEO_COMPILER_WARNINGS})
|
add_compile_options(${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
|
|
||||||
@@ -29,10 +52,82 @@ 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_SUPPORTED_DEVICES_EXAMPLE)
|
||||||
|
add_subdirectory(c2/supported_devices)
|
||||||
|
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_C2_RECONNECT_EXAMPLE)
|
||||||
|
add_subdirectory(c2/reconnect)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_DEVICE_INFO_EXAMPLE)
|
||||||
|
add_subdirectory(c2/device_info)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_CHIP_VERSIONS_EXAMPLE)
|
||||||
|
add_subdirectory(c2/chip_versions)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_TERMINATION_EXAMPLE)
|
||||||
|
add_subdirectory(c2/termination)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_LIN_EXAMPLE)
|
||||||
|
add_subdirectory(c2/lin)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_LIN_TRANSMIT_EXAMPLE)
|
||||||
|
add_subdirectory(c2/lin_transmit)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_ETHERNET_TRANSMIT_EXAMPLE)
|
||||||
|
add_subdirectory(c2/ethernet_transmit)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_ETHERNET_RECEIVE_EXAMPLE)
|
||||||
|
add_subdirectory(c2/ethernet_receive)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_ETHERNET_STATUS_EXAMPLE)
|
||||||
|
add_subdirectory(c2/ethernet_status)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_T1S_LOOPBACK_EXAMPLE)
|
||||||
|
add_subdirectory(c2/t1s_loopback)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_TC10_EXAMPLE)
|
||||||
|
add_subdirectory(c2/tc10)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_GPTP_EXAMPLE)
|
||||||
|
add_subdirectory(c2/gptp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_C2_PERF_TEST_EXAMPLE)
|
||||||
|
add_subdirectory(c2/perf_test)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE)
|
if(LIBICSNEO_BUILD_CPP_SIMPLE_EXAMPLE)
|
||||||
add_subdirectory(cpp/simple)
|
add_subdirectory(cpp/simple)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_DEVICE_INFO_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/device_info)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_CPP_INTERACTIVE_EXAMPLE)
|
if(LIBICSNEO_BUILD_CPP_INTERACTIVE_EXAMPLE)
|
||||||
add_subdirectory(cpp/interactive)
|
add_subdirectory(cpp/interactive)
|
||||||
endif()
|
endif()
|
||||||
@@ -80,3 +175,23 @@ endif()
|
|||||||
if(LIBICSNEO_BUILD_CPP_MUTEX_EXAMPLE)
|
if(LIBICSNEO_BUILD_CPP_MUTEX_EXAMPLE)
|
||||||
add_subdirectory(cpp/mutex)
|
add_subdirectory(cpp/mutex)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_ANALOG_OUT_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/analog_out)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_DISKFORMAT_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/diskformat)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_T1S_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/t1s)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_GPTP_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/gptp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_ISO15765_LOOPBACK_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/iso15765_loopback)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ int main() {
|
|||||||
msg1.Protocol = SPY_PROTOCOL_LIN;
|
msg1.Protocol = SPY_PROTOCOL_LIN;
|
||||||
msg1.StatusBitField = 0;
|
msg1.StatusBitField = 0;
|
||||||
msg1.StatusBitField2 = 0;
|
msg1.StatusBitField2 = 0;
|
||||||
lNetworkID = NETID_LIN_02;
|
lNetworkID = NETID_LIN2;
|
||||||
msg1.Header[0] = 0x11; //protected ID
|
msg1.Header[0] = 0x11; //protected ID
|
||||||
msg1.Header[1] = 0xaa;
|
msg1.Header[1] = 0xaa;
|
||||||
msg1.Header[2] = 0xbb;
|
msg1.Header[2] = 0xbb;
|
||||||
@@ -80,7 +80,7 @@ int main() {
|
|||||||
icsSpyMessageJ1850 msg2 = {0};
|
icsSpyMessageJ1850 msg2 = {0};
|
||||||
msg2.Protocol = SPY_PROTOCOL_LIN;
|
msg2.Protocol = SPY_PROTOCOL_LIN;
|
||||||
msg2.StatusBitField = SPY_STATUS_INIT_MESSAGE;
|
msg2.StatusBitField = SPY_STATUS_INIT_MESSAGE;
|
||||||
lNetworkID = NETID_LIN_01;
|
lNetworkID = NETID_LIN;
|
||||||
msg2.Header[0] = 0x11; //protected ID
|
msg2.Header[0] = 0x11; //protected ID
|
||||||
msg2.NumberBytesData = 0;
|
msg2.NumberBytesData = 0;
|
||||||
msg2.NumberBytesHeader = 1;
|
msg2.NumberBytesHeader = 1;
|
||||||
@@ -96,7 +96,7 @@ int main() {
|
|||||||
msg3.Protocol = SPY_PROTOCOL_LIN;
|
msg3.Protocol = SPY_PROTOCOL_LIN;
|
||||||
msg3.StatusBitField = SPY_STATUS_INIT_MESSAGE;
|
msg3.StatusBitField = SPY_STATUS_INIT_MESSAGE;
|
||||||
msg3.StatusBitField2 = 0;
|
msg3.StatusBitField2 = 0;
|
||||||
lNetworkID = NETID_LIN_01;
|
lNetworkID = NETID_LIN;
|
||||||
msg3.Header[0] = 0xe2; //protected ID
|
msg3.Header[0] = 0xe2; //protected ID
|
||||||
msg3.Header[1] = 0x44;
|
msg3.Header[1] = 0x44;
|
||||||
msg3.Header[2] = 0x33;
|
msg3.Header[2] = 0x33;
|
||||||
@@ -131,10 +131,10 @@ int main() {
|
|||||||
const icsSpyMessageJ1850* linMsg = (icsSpyMessageJ1850*)&rxMsg[idx];
|
const icsSpyMessageJ1850* linMsg = (icsSpyMessageJ1850*)&rxMsg[idx];
|
||||||
size_t frameLen = (linMsg->NumberBytesHeader + linMsg->NumberBytesData);
|
size_t frameLen = (linMsg->NumberBytesHeader + linMsg->NumberBytesData);
|
||||||
size_t dataLen = (frameLen > 2) ? (frameLen - 2) : 0;
|
size_t dataLen = (frameLen > 2) ? (frameLen - 2) : 0;
|
||||||
if(linMsg->NetworkID == NETID_LIN_01) {
|
if(linMsg->NetworkID == NETID_LIN) {
|
||||||
printf("LIN 1 | ID: 0x%02x [%zu] ", linMsg->Header[0], dataLen);
|
printf("LIN 1 | ID: 0x%02x [%zu] ", linMsg->Header[0], dataLen);
|
||||||
}
|
}
|
||||||
else if (linMsg->NetworkID == NETID_LIN_02) {
|
else if (linMsg->NetworkID == NETID_LIN2) {
|
||||||
printf("LIN 2 | ID: 0x%02x [%zu] ", linMsg->Header[0], dataLen);
|
printf("LIN 2 | ID: 0x%02x [%zu] ", linMsg->Header[0], dataLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
add_executable(libicsneoc2-chip-versions-example src/main.c)
|
||||||
|
target_link_libraries(libicsneoc2-chip-versions-example icsneoc2-static)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(libicsneoc2-chip-versions-example PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#include <icsneo/icsneoc2.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
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 %u with error code %u\n", message, error, res);
|
||||||
|
return (int)res;
|
||||||
|
}
|
||||||
|
printf("%s: \"%s\" (%u)\n", message, error_str, error);
|
||||||
|
return (int)error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
icsneoc2_error_t res;
|
||||||
|
|
||||||
|
icsneoc2_device_t* device = NULL;
|
||||||
|
res = icsneoc2_device_open_first(0, icsneoc2_open_options_default, &device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
return print_error_code("Failed to open first device", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
char description[128] = {0};
|
||||||
|
size_t description_length = sizeof(description);
|
||||||
|
icsneoc2_device_description_get(device, description, &description_length);
|
||||||
|
printf("Opened device: %s\n\n", description);
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
icsneoc2_chip_versions_t* chip_versions = NULL;
|
||||||
|
res = icsneoc2_device_chip_versions_enumerate(device, &chip_versions, true, &count);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
print_error_code("Failed to enumerate chip versions", res);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Found %zu chip version(s):\n", count);
|
||||||
|
for(icsneoc2_chip_versions_t* cur = chip_versions; cur; cur = icsneoc2_chip_versions_next(cur)) {
|
||||||
|
char name[64] = {0};
|
||||||
|
size_t name_length = sizeof(name);
|
||||||
|
uint8_t major = 0, minor = 0, maintenance = 0, build = 0;
|
||||||
|
res = icsneoc2_chip_versions_props_get(cur, name, &name_length, &major, &minor, &maintenance, &build);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
print_error_code("Failed to get chip version properties", res);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
printf(" %s: %u.%u.%u.%u\n", name, major, minor, maintenance, build);
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_chip_versions_free(chip_versions);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
add_executable(libicsneoc2-device-info-example src/main.c)
|
||||||
|
target_link_libraries(libicsneoc2-device-info-example icsneoc2-static)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(libicsneoc2-device-info-example PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
#include <icsneo/icsneoc2.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
icsneoc2_error_t res;
|
||||||
|
|
||||||
|
/* ===== Device Selection ===== */
|
||||||
|
printf("Searching for devices...\n");
|
||||||
|
icsneoc2_device_info_t* found_devices = NULL;
|
||||||
|
res = icsneoc2_device_enumerate(0, &found_devices);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
return print_error_code("Failed to enumerate devices", res);
|
||||||
|
}
|
||||||
|
if(!found_devices) {
|
||||||
|
printf("No devices found.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Count and display devices */
|
||||||
|
int device_count = 0;
|
||||||
|
for(icsneoc2_device_info_t* cur = found_devices; cur; cur = icsneoc2_device_info_next(cur)) {
|
||||||
|
char desc[128] = {0};
|
||||||
|
size_t desc_len = sizeof(desc);
|
||||||
|
icsneoc2_device_info_description_get(cur, desc, &desc_len);
|
||||||
|
|
||||||
|
char serial[32] = {0};
|
||||||
|
size_t serial_len = sizeof(serial);
|
||||||
|
icsneoc2_device_info_serial_get(cur, serial, &serial_len);
|
||||||
|
|
||||||
|
printf(" [%d] %s (Serial: %s)\n", device_count + 1, desc, serial);
|
||||||
|
device_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int device_choice;
|
||||||
|
printf("Select device (1-%d): ", device_count);
|
||||||
|
if(scanf("%d", &device_choice) != 1 || device_choice < 1 || device_choice > device_count) {
|
||||||
|
printf("Invalid selection.\n");
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the selected device_info node */
|
||||||
|
icsneoc2_device_info_t* selected_info = found_devices;
|
||||||
|
for(int i = 1; i < device_choice; i++) {
|
||||||
|
selected_info = icsneoc2_device_info_next(selected_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the selected device */
|
||||||
|
icsneoc2_device_t* device = NULL;
|
||||||
|
res = icsneoc2_device_create(selected_info, &device);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
return print_error_code("Failed to create device from device info", res);
|
||||||
|
}
|
||||||
|
res = icsneoc2_device_open(device, icsneoc2_open_options_default);
|
||||||
|
icsneoc2_enumeration_free(found_devices);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return print_error_code("Failed to open device", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
char description[128] = {0};
|
||||||
|
size_t description_length = sizeof(description);
|
||||||
|
icsneoc2_device_description_get(device, description, &description_length);
|
||||||
|
printf("\nOpened device: %s\n\n", description);
|
||||||
|
|
||||||
|
/* ===== Serial Number ===== */
|
||||||
|
char serial[32] = {0};
|
||||||
|
size_t serial_len = sizeof(serial);
|
||||||
|
res = icsneoc2_device_serial_get(device, serial, &serial_len);
|
||||||
|
if(res == icsneoc2_error_success) {
|
||||||
|
printf("Serial: %s\n", serial);
|
||||||
|
} else {
|
||||||
|
print_error_code("Failed to get serial", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== PCB Serial Number ===== */
|
||||||
|
uint8_t pcbsn[16] = {0};
|
||||||
|
size_t pcbsn_len = sizeof(pcbsn);
|
||||||
|
res = icsneoc2_device_pcb_serial_get(device, pcbsn, &pcbsn_len);
|
||||||
|
if(res == icsneoc2_error_success) {
|
||||||
|
printf("PCB Serial: ");
|
||||||
|
for(size_t i = 0; i < pcbsn_len; i++) {
|
||||||
|
printf("%c", pcbsn[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
} else {
|
||||||
|
print_error_code("Failed to get PCB serial (device may not support it)", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== MAC Addresses ===== */
|
||||||
|
icsneoc2_mac_addr_entry_t* macs = NULL;
|
||||||
|
res = icsneoc2_device_mac_addresses_enumerate(device, &macs);
|
||||||
|
if(res == icsneoc2_error_success) {
|
||||||
|
uint16_t mac_count = 0;
|
||||||
|
for(icsneoc2_mac_addr_entry_t* cur = macs; cur; cur = icsneoc2_mac_addresses_next(cur)) {
|
||||||
|
mac_count++;
|
||||||
|
}
|
||||||
|
printf("MACs: %u entr%s\n", mac_count, mac_count == 1 ? "y" : "ies");
|
||||||
|
for(icsneoc2_mac_addr_entry_t* cur = macs; cur; cur = icsneoc2_mac_addresses_next(cur)) {
|
||||||
|
icsneoc2_netid_t network_id;
|
||||||
|
icsneoc2_mac_network_id_get(cur, &network_id);
|
||||||
|
printf(" Network %-5u ", (unsigned)network_id);
|
||||||
|
uint8_t address[6];
|
||||||
|
size_t address_size = 6;
|
||||||
|
icsneoc2_mac_address_get(cur, address, &address_size);
|
||||||
|
for(int j = 0; j < 6; j++) {
|
||||||
|
if(j > 0) printf(":");
|
||||||
|
printf("%02X", (unsigned)address[j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
icsneoc2_mac_addresses_free(macs);
|
||||||
|
} else {
|
||||||
|
print_error_code("Failed to get MAC addresses (device may not support it)", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cleanup */
|
||||||
|
printf("\nClosing device... ");
|
||||||
|
res = icsneoc2_device_close(device);
|
||||||
|
printf("%s\n", res == icsneoc2_error_success ? "OK" : "FAIL");
|
||||||
|
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -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()
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
#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) {
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
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);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!supported) {
|
||||||
|
printf("\terror: %s does not support disk formatting\n", description);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(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);
|
||||||
|
icsneoc2_device_free(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, §ors, &bps);
|
||||||
|
printf("\t Size : %" PRIu64 " MB (%" PRIu64 " sectors x %" PRIu64 " bytes)\n",
|
||||||
|
(sectors * bps) / (1024 * 1024), sectors, bps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Choose operation */
|
||||||
|
printf("\n\tChoose operation:\n");
|
||||||
|
printf("\t [f] Format the disk(s)\n");
|
||||||
|
printf("\t [u] Update the disk configuration without formatting\n");
|
||||||
|
printf("\t [q] Quit\n");
|
||||||
|
printf("\tSelection [f/u/q]: ");
|
||||||
|
char choice[8] = {0};
|
||||||
|
if(scanf("%7s", choice) != 1) {
|
||||||
|
choice[0] = 'q';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(choice[0] == 'u' || choice[0] == 'U') {
|
||||||
|
/* Force a disk config update (e.g. changing the disk layout) without formatting.
|
||||||
|
* Unlike a format, this preserves the existing data on the disk(s). */
|
||||||
|
printf("\n\tChoose disk layout:\n");
|
||||||
|
printf("\t [s] Spanned\n");
|
||||||
|
printf("\t [r] RAID0\n");
|
||||||
|
printf("\tSelection [s/r] (current: %s): ", layout == icsneoc2_disk_layout_raid0 ? "RAID0" : "Spanned");
|
||||||
|
char layout_choice[8] = {0};
|
||||||
|
if(scanf("%7s", layout_choice) != 1) {
|
||||||
|
layout_choice[0] = '\0';
|
||||||
|
}
|
||||||
|
if(layout_choice[0] == 'r' || layout_choice[0] == 'R') {
|
||||||
|
icsneoc2_disk_details_layout_set(details, icsneoc2_disk_layout_raid0);
|
||||||
|
} else if(layout_choice[0] == 's' || layout_choice[0] == 'S') {
|
||||||
|
icsneoc2_disk_details_layout_set(details, icsneoc2_disk_layout_spanned);
|
||||||
|
} else {
|
||||||
|
printf("\tKeeping current layout.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enable/disable individual disks in the configuration. A disk's enabled
|
||||||
|
* state is carried by the FORMATTED flag; only present disks can be enabled. */
|
||||||
|
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)) {
|
||||||
|
continue; /* Can't enable a disk that isn't present */
|
||||||
|
}
|
||||||
|
printf("\tEnable disk [%zu]? [y/N] (currently %s): ", i,
|
||||||
|
(flags & ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED) ? "enabled" : "disabled");
|
||||||
|
char disk_choice[8] = {0};
|
||||||
|
if(scanf("%7s", disk_choice) != 1) {
|
||||||
|
disk_choice[0] = '\0';
|
||||||
|
}
|
||||||
|
if(disk_choice[0] == 'y' || disk_choice[0] == 'Y') {
|
||||||
|
flags |= ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED;
|
||||||
|
} else {
|
||||||
|
flags &= ~(icsneoc2_disk_format_flags_t)ICSNEOC2_DISK_FORMAT_FLAGS_FORMATTED;
|
||||||
|
}
|
||||||
|
icsneoc2_disk_details_flags_set(details, i, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
icsneoc2_disk_layout_t new_layout = 0;
|
||||||
|
icsneoc2_disk_details_layout_get(details, &new_layout);
|
||||||
|
printf("\n\tForcing disk config update on %s to %s layout (no data will be erased)...\n",
|
||||||
|
description, new_layout == icsneoc2_disk_layout_raid0 ? "RAID0" : "Spanned");
|
||||||
|
res = icsneoc2_device_force_disk_config_update(device, details);
|
||||||
|
if(res != icsneoc2_error_success) {
|
||||||
|
print_error_code("\tForce disk config update failed", res);
|
||||||
|
icsneoc2_disk_details_free(details);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("\tDisk config update complete!\n");
|
||||||
|
icsneoc2_disk_details_free(details);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(choice[0] != 'f' && choice[0] != 'F') {
|
||||||
|
printf("\tAborted.\n");
|
||||||
|
icsneoc2_disk_details_free(details);
|
||||||
|
icsneoc2_device_close(device);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
icsneoc2_device_free(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);
|
||||||
|
icsneoc2_device_free(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);
|
||||||
|
icsneoc2_device_free(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);
|
||||||
|
icsneoc2_device_free(device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user