mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-09-21 16:38:39 +02:00
Compare commits
57
Commits
1.0.0
...
563c444def
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
563c444def | ||
|
|
3f3300d677 | ||
|
|
b9e3542bcf | ||
|
|
7f192a0cea | ||
|
|
3b60bfc986 | ||
|
|
d51f88d023 | ||
|
|
f3cb41d60b | ||
|
|
1b00c6a05b | ||
|
|
ebf9409c18 | ||
|
|
83ab65b062 | ||
|
|
7f1668a55b | ||
|
|
10ffd756a1 | ||
|
|
c2f1022858 | ||
|
|
bf311ebe30 | ||
|
|
5cdaeb1edc | ||
|
|
deabc2cff4 | ||
|
|
b48160286b | ||
|
|
5d672d48d4 | ||
|
|
495632ddb7 | ||
|
|
3668b86f37 | ||
|
|
0bd733bc5d | ||
|
|
99a2ca4f0d | ||
|
|
ec350b522a | ||
|
|
895cd0792c | ||
|
|
a5ec9a2d20 | ||
|
|
b9d3dde8d5 | ||
|
|
11643e2281 | ||
|
|
f22d666f94 | ||
|
|
58b22da09b | ||
|
|
88d32128c9 | ||
|
|
6d82289864 | ||
|
|
674e905340 | ||
|
|
8b7e2556a0 | ||
|
|
fbdab1e998 | ||
|
|
f53bc2e920 | ||
|
|
a9e1f24f67 | ||
|
|
b10e29b8f5 | ||
|
|
3c0c0dd44c | ||
|
|
cf2cf3e28b | ||
|
|
6926ca8199 | ||
|
|
29dc7b345f | ||
|
|
17285389e3 | ||
|
|
328563b7e6 | ||
|
|
6b60804174 | ||
|
|
c5bce795c6 | ||
|
|
1e5e714f5b | ||
|
|
d70defbf8a | ||
|
|
10efacf91e | ||
|
|
6d985ca873 | ||
|
|
19df557b4a | ||
|
|
7afa41bf2a | ||
|
|
c056e8dc2e | ||
|
|
d5ae1cdb03 | ||
|
|
5795791eac | ||
|
|
c91db6355c | ||
|
|
f37b88d616 | ||
|
|
33dea748f7 |
@@ -15,3 +15,4 @@ third-party/concurrentqueue/tests
|
|||||||
examples/csharp/bin
|
examples/csharp/bin
|
||||||
examples/csharp/obj
|
examples/csharp/obj
|
||||||
test/system
|
test/system
|
||||||
|
.env
|
||||||
|
|||||||
+75
-99
@@ -1,5 +1,6 @@
|
|||||||
variables:
|
variables:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
|
LIBICSNEO_ICSPB_REPO: https://gitlab-ci-token:${CI_JOB_TOKEN}@${LIBICSNEO_ICSPB_GIT}
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
@@ -13,7 +14,7 @@ stages:
|
|||||||
build windows/x64:
|
build windows/x64:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- CMD.EXE /C ci\build-windows64.bat
|
- cmd /C ci\build-windows64.bat
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
@@ -37,7 +38,7 @@ unit_test windows/x64:
|
|||||||
build windows/x86:
|
build windows/x86:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- CMD.EXE /C ci\build-windows32.bat
|
- cmd /C ci\build-windows32.bat
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
@@ -67,7 +68,9 @@ unit_test windows/x86:
|
|||||||
script:
|
script:
|
||||||
- apt update -y
|
- apt update -y
|
||||||
- apt upgrade -y
|
- apt upgrade -y
|
||||||
- apt install -y g++ ninja-build cmake libusb-1.0-0-dev libpcap-dev git
|
- apt install -y g++ ninja-build cmake libpcap-dev git ca-certificates
|
||||||
|
- echo "$ICS_IPA_CA_CRT" >/usr/local/share/ca-certificates/ica-ipa-ca.crt
|
||||||
|
- update-ca-certificates --fresh
|
||||||
- sh ci/build-posix.sh
|
- sh ci/build-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
@@ -82,7 +85,7 @@ unit_test windows/x86:
|
|||||||
script:
|
script:
|
||||||
- apt update -y
|
- apt update -y
|
||||||
- apt upgrade -y
|
- apt upgrade -y
|
||||||
- apt install -y libusb-1.0-0-dev libpcap-dev
|
- apt install -y libpcap-dev
|
||||||
- build/libicsneo-unit-tests
|
- build/libicsneo-unit-tests
|
||||||
tags:
|
tags:
|
||||||
- linux-build
|
- linux-build
|
||||||
@@ -93,7 +96,9 @@ unit_test windows/x86:
|
|||||||
script:
|
script:
|
||||||
- apt update -y
|
- apt update -y
|
||||||
- apt upgrade -y
|
- apt upgrade -y
|
||||||
- apt install -y clang lld ninja-build cmake libusb-1.0-0-dev libpcap-dev git
|
- apt install -y clang lld ninja-build cmake libpcap-dev git ca-certificates
|
||||||
|
- echo "$ICS_IPA_CA_CRT" >/usr/local/share/ca-certificates/ica-ipa-ca.crt
|
||||||
|
- update-ca-certificates --fresh
|
||||||
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
|
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
@@ -108,36 +113,12 @@ unit_test windows/x86:
|
|||||||
script:
|
script:
|
||||||
- apt update -y
|
- apt update -y
|
||||||
- apt upgrade -y
|
- apt upgrade -y
|
||||||
- apt install -y libusb-1.0-0-dev libpcap-dev
|
- apt install -y libpcap-dev
|
||||||
- build/libicsneo-unit-tests
|
- build/libicsneo-unit-tests
|
||||||
tags:
|
tags:
|
||||||
- linux-build
|
- linux-build
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
build linux/ubuntu/2004/amd64/gcc:
|
|
||||||
<<: *build_linux_ubuntu_gcc
|
|
||||||
image: ubuntu:20.04
|
|
||||||
|
|
||||||
unit_test linux/ubuntu/2004/amd64/gcc:
|
|
||||||
<<: *test_linux_ubuntu_gcc
|
|
||||||
image: ubuntu:20.04
|
|
||||||
dependencies:
|
|
||||||
- build linux/ubuntu/2004/amd64/gcc
|
|
||||||
needs:
|
|
||||||
- build linux/ubuntu/2004/amd64/gcc
|
|
||||||
|
|
||||||
build linux/ubuntu/2004/amd64/clang:
|
|
||||||
<<: *build_linux_ubuntu_clang
|
|
||||||
image: ubuntu:20.04
|
|
||||||
|
|
||||||
unit_test linux/ubuntu/2004/amd64/clang:
|
|
||||||
<<: *test_linux_ubuntu_clang
|
|
||||||
image: ubuntu:20.04
|
|
||||||
dependencies:
|
|
||||||
- build linux/ubuntu/2004/amd64/clang
|
|
||||||
needs:
|
|
||||||
- build linux/ubuntu/2004/amd64/clang
|
|
||||||
|
|
||||||
build linux/ubuntu/2204/amd64/gcc:
|
build linux/ubuntu/2204/amd64/gcc:
|
||||||
<<: *build_linux_ubuntu_gcc
|
<<: *build_linux_ubuntu_gcc
|
||||||
image: ubuntu:22.04
|
image: ubuntu:22.04
|
||||||
@@ -162,6 +143,30 @@ unit_test linux/ubuntu/2204/amd64/clang:
|
|||||||
needs:
|
needs:
|
||||||
- build linux/ubuntu/2204/amd64/clang
|
- build linux/ubuntu/2204/amd64/clang
|
||||||
|
|
||||||
|
build linux/ubuntu/2404/amd64/gcc:
|
||||||
|
<<: *build_linux_ubuntu_gcc
|
||||||
|
image: ubuntu:24.04
|
||||||
|
|
||||||
|
unit_test linux/ubuntu/2404/amd64/gcc:
|
||||||
|
<<: *test_linux_ubuntu_gcc
|
||||||
|
image: ubuntu:24.04
|
||||||
|
dependencies:
|
||||||
|
- build linux/ubuntu/2404/amd64/gcc
|
||||||
|
needs:
|
||||||
|
- build linux/ubuntu/2404/amd64/gcc
|
||||||
|
|
||||||
|
build linux/ubuntu/2404/amd64/clang:
|
||||||
|
<<: *build_linux_ubuntu_clang
|
||||||
|
image: ubuntu:24.04
|
||||||
|
|
||||||
|
unit_test linux/ubuntu/2404/amd64/clang:
|
||||||
|
<<: *test_linux_ubuntu_clang
|
||||||
|
image: ubuntu:24.04
|
||||||
|
dependencies:
|
||||||
|
- build linux/ubuntu/2404/amd64/clang
|
||||||
|
needs:
|
||||||
|
- build linux/ubuntu/2404/amd64/clang
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Fedora
|
# Fedora
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -175,7 +180,9 @@ unit_test linux/ubuntu/2204/amd64/clang:
|
|||||||
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
||||||
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
||||||
- dnf upgrade -y
|
- dnf upgrade -y
|
||||||
- dnf install -y g++ libpcap-devel cmake ninja-build libusb1-devel git
|
- dnf install -y g++ libpcap-devel cmake ninja-build git ca-certificates
|
||||||
|
- echo "$ICS_IPA_CA_CRT" >/etc/pki/ca-trust/source/anchors/ica-ipa-ca.crt
|
||||||
|
- update-ca-trust
|
||||||
- sh ci/build-posix.sh
|
- sh ci/build-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
@@ -194,7 +201,7 @@ unit_test linux/ubuntu/2204/amd64/clang:
|
|||||||
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
||||||
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
||||||
- dnf upgrade -y
|
- dnf upgrade -y
|
||||||
- dnf install -y libpcap-devel libusb1-devel
|
- dnf install -y libpcap-devel
|
||||||
- build/libicsneo-unit-tests
|
- build/libicsneo-unit-tests
|
||||||
tags:
|
tags:
|
||||||
- linux-build
|
- linux-build
|
||||||
@@ -209,7 +216,9 @@ unit_test linux/ubuntu/2204/amd64/clang:
|
|||||||
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
||||||
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
||||||
- dnf upgrade -y
|
- dnf upgrade -y
|
||||||
- dnf install -y clang lld libpcap-devel cmake ninja-build libusb1-devel git
|
- dnf install -y clang lld libpcap-devel cmake ninja-build git ca-certificates
|
||||||
|
- echo "$ICS_IPA_CA_CRT" >/etc/pki/ca-trust/source/anchors/ica-ipa-ca.crt
|
||||||
|
- update-ca-trust
|
||||||
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
|
- CC=clang CXX=clang++ LDFLAGS=-fuse-ld=lld sh ci/build-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
@@ -228,83 +237,59 @@ unit_test linux/ubuntu/2204/amd64/clang:
|
|||||||
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
- echo max_parallel_downloads=10 >>/etc/dnf/dnf.conf
|
||||||
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
- echo fastestmirror=True >>/etc/dnf/dnf.conf
|
||||||
- dnf upgrade -y
|
- dnf upgrade -y
|
||||||
- dnf install -y libpcap-devel libusb1-devel
|
- dnf install -y libpcap-devel
|
||||||
- build/libicsneo-unit-tests
|
- build/libicsneo-unit-tests
|
||||||
tags:
|
tags:
|
||||||
- linux-build
|
- linux-build
|
||||||
timeout: 5m
|
timeout: 5m
|
||||||
|
|
||||||
build linux/fedora/39/amd64/gcc:
|
build linux/fedora/42/amd64/gcc:
|
||||||
<<: *build_linux_fedora_gcc
|
<<: *build_linux_fedora_gcc
|
||||||
image: fedora:39
|
image: fedora:42
|
||||||
|
|
||||||
unit_test linux/fedora/39/amd64/gcc:
|
unit_test linux/fedora/42/amd64/gcc:
|
||||||
<<: *test_linux_fedora_gcc
|
<<: *test_linux_fedora_gcc
|
||||||
image: fedora:39
|
image: fedora:42
|
||||||
dependencies:
|
dependencies:
|
||||||
- build linux/fedora/39/amd64/gcc
|
- build linux/fedora/42/amd64/gcc
|
||||||
needs:
|
needs:
|
||||||
- build linux/fedora/39/amd64/gcc
|
- build linux/fedora/42/amd64/gcc
|
||||||
|
|
||||||
build linux/fedora/39/amd64/clang:
|
build linux/fedora/42/amd64/clang:
|
||||||
<<: *build_linux_fedora_clang
|
<<: *build_linux_fedora_clang
|
||||||
image: fedora:39
|
image: fedora:42
|
||||||
|
|
||||||
unit_test linux/fedora/39/amd64/clang:
|
unit_test linux/fedora/42/amd64/clang:
|
||||||
<<: *test_linux_fedora_clang
|
<<: *test_linux_fedora_clang
|
||||||
image: fedora:39
|
image: fedora:42
|
||||||
dependencies:
|
dependencies:
|
||||||
- build linux/fedora/39/amd64/clang
|
- build linux/fedora/42/amd64/clang
|
||||||
needs:
|
needs:
|
||||||
- build linux/fedora/39/amd64/clang
|
- build linux/fedora/42/amd64/clang
|
||||||
|
|
||||||
build linux/fedora/40/amd64/gcc:
|
build linux/fedora/43/amd64/gcc:
|
||||||
<<: *build_linux_fedora_gcc
|
<<: *build_linux_fedora_gcc
|
||||||
image: fedora:40
|
image: fedora:43
|
||||||
|
|
||||||
unit_test linux/fedora/40/amd64/gcc:
|
unit_test linux/fedora/43/amd64/gcc:
|
||||||
<<: *test_linux_fedora_gcc
|
<<: *test_linux_fedora_gcc
|
||||||
image: fedora:40
|
image: fedora:43
|
||||||
dependencies:
|
dependencies:
|
||||||
- build linux/fedora/40/amd64/gcc
|
- build linux/fedora/43/amd64/gcc
|
||||||
needs:
|
needs:
|
||||||
- build linux/fedora/40/amd64/gcc
|
- build linux/fedora/43/amd64/gcc
|
||||||
|
|
||||||
build linux/fedora/40/amd64/clang:
|
build linux/fedora/43/amd64/clang:
|
||||||
<<: *build_linux_fedora_clang
|
<<: *build_linux_fedora_clang
|
||||||
image: fedora:40
|
image: fedora:43
|
||||||
|
|
||||||
unit_test linux/fedora/40/amd64/clang:
|
unit_test linux/fedora/43/amd64/clang:
|
||||||
<<: *test_linux_fedora_clang
|
<<: *test_linux_fedora_clang
|
||||||
image: fedora:40
|
image: fedora:43
|
||||||
dependencies:
|
dependencies:
|
||||||
- build linux/fedora/40/amd64/clang
|
- build linux/fedora/43/amd64/clang
|
||||||
needs:
|
needs:
|
||||||
- build linux/fedora/40/amd64/clang
|
- build linux/fedora/43/amd64/clang
|
||||||
|
|
||||||
build linux/fedora/41/amd64/gcc:
|
|
||||||
<<: *build_linux_fedora_gcc
|
|
||||||
image: fedora:41
|
|
||||||
|
|
||||||
unit_test linux/fedora/41/amd64/gcc:
|
|
||||||
<<: *test_linux_fedora_gcc
|
|
||||||
image: fedora:41
|
|
||||||
dependencies:
|
|
||||||
- build linux/fedora/41/amd64/gcc
|
|
||||||
needs:
|
|
||||||
- build linux/fedora/41/amd64/gcc
|
|
||||||
|
|
||||||
build linux/fedora/41/amd64/clang:
|
|
||||||
<<: *build_linux_fedora_clang
|
|
||||||
image: fedora:41
|
|
||||||
|
|
||||||
unit_test linux/fedora/41/amd64/clang:
|
|
||||||
<<: *test_linux_fedora_clang
|
|
||||||
image: fedora:41
|
|
||||||
dependencies:
|
|
||||||
- build linux/fedora/41/amd64/clang
|
|
||||||
needs:
|
|
||||||
- build linux/fedora/41/amd64/clang
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Python Module
|
# Python Module
|
||||||
@@ -313,22 +298,13 @@ unit_test linux/fedora/41/amd64/clang:
|
|||||||
build python/linux/amd64:
|
build python/linux/amd64:
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- linux-build
|
- linux-native-amd64
|
||||||
image: python:3.12
|
|
||||||
services:
|
|
||||||
- name: docker:dind
|
|
||||||
entrypoint: ["env", "-u", "DOCKER_HOST"]
|
|
||||||
command: ["dockerd-entrypoint.sh"]
|
|
||||||
variables:
|
variables:
|
||||||
CIBW_BEFORE_ALL: yum install -y flex && sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.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
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install
|
||||||
DOCKER_DRIVER: overlay2
|
|
||||||
DOCKER_TLS_CERTDIR: ""
|
|
||||||
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install:/project/libusb/install
|
|
||||||
script:
|
script:
|
||||||
- curl -sSL https://get.docker.com/ | sh
|
|
||||||
- sh ci/build-wheel-posix.sh
|
- sh ci/build-wheel-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
@@ -339,10 +315,10 @@ build python/linux/arm64:
|
|||||||
tags:
|
tags:
|
||||||
- arm64-linux-build
|
- arm64-linux-build
|
||||||
variables:
|
variables:
|
||||||
CIBW_BEFORE_ALL: yum install -y flex && sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.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:/project/libusb/install
|
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install
|
||||||
script:
|
script:
|
||||||
- sh ci/build-wheel-posix.sh
|
- sh ci/build-wheel-posix.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -354,9 +330,9 @@ build python/macos:
|
|||||||
tags:
|
tags:
|
||||||
- macos-arm64
|
- macos-arm64
|
||||||
variables:
|
variables:
|
||||||
CIBW_BEFORE_ALL: sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.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:$CI_PROJECT_DIR/libusb/install
|
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=$CI_PROJECT_DIR/libpcap/install
|
||||||
MACOSX_DEPLOYMENT_TARGET: 10.14
|
MACOSX_DEPLOYMENT_TARGET: 10.14
|
||||||
script:
|
script:
|
||||||
- sh ci/build-wheel-posix.sh
|
- sh ci/build-wheel-posix.sh
|
||||||
@@ -384,7 +360,7 @@ deploy python/pypi:
|
|||||||
TWINE_PASSWORD: $PYPI_TOKEN
|
TWINE_PASSWORD: $PYPI_TOKEN
|
||||||
tags:
|
tags:
|
||||||
- linux-build
|
- linux-build
|
||||||
image: python:3.12
|
image: python:3.13
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
script:
|
script:
|
||||||
|
|||||||
+2
-21
@@ -3,24 +3,5 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="093c", GROUP="users", MODE="0666"
|
|||||||
KERNEL=="ttyUSB?", ATTRS{idVendor}=="093c", GROUP="users", MODE="0666"
|
KERNEL=="ttyUSB?", ATTRS{idVendor}=="093c", GROUP="users", MODE="0666"
|
||||||
KERNEL=="ttyACM?", ATTRS{idVendor}=="093c", GROUP="users", MODE="0666"
|
KERNEL=="ttyACM?", ATTRS{idVendor}=="093c", GROUP="users", MODE="0666"
|
||||||
|
|
||||||
# neoVI ION/PLASMA PIDs are not in the latest ftdi_sio driver so lets make a
|
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="093c", KERNEL=="ttyUSB*", \
|
||||||
# rule to add it when we see a new unclaimed device.
|
RUN+="/bin/sh -c 'echo $id:1.0>/sys/bus/usb/drivers/ftdi_sio/unbind'"
|
||||||
# PLASMA = 0x0801, ION = 0x0901
|
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", \
|
|
||||||
ATTRS{idVendor}=="093c", ATTRS{idProduct}=="0801", \
|
|
||||||
DRIVER=="", \
|
|
||||||
RUN+="/sbin/modprobe -b ftdi_sio"
|
|
||||||
ACTION=="add", SUBSYSTEM=="drivers", \
|
|
||||||
ENV{DEVPATH}=="/bus/usb-serial/drivers/ftdi_sio", \
|
|
||||||
ATTR{new_id}="093c 0801"
|
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", \
|
|
||||||
ATTRS{idVendor}=="093c", ATTRS{idProduct}=="0901", \
|
|
||||||
DRIVER=="", \
|
|
||||||
RUN+="/sbin/modprobe -b ftdi_sio"
|
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", \
|
|
||||||
ATTRS{idVendor}=="093c", ATTRS{idProduct}=="1000", \
|
|
||||||
DRIVER=="", \
|
|
||||||
RUN+="/sbin/modprobe -b ftdi_sio"
|
|
||||||
ACTION=="add", SUBSYSTEM=="drivers", \
|
|
||||||
ENV{DEVPATH}=="/bus/usb-serial/drivers/ftdi_sio", \
|
|
||||||
ATTR{new_id}="093c 0901"
|
|
||||||
|
|||||||
+63
-102
@@ -22,15 +22,13 @@ set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to
|
|||||||
option(LIBICSNEO_ENABLE_FIRMIO "Enable communication between Linux and CoreMini within the same device" OFF)
|
option(LIBICSNEO_ENABLE_FIRMIO "Enable communication between Linux and CoreMini within the same device" OFF)
|
||||||
option(LIBICSNEO_ENABLE_RAW_ETHERNET "Enable devices which communicate over raw ethernet" ON)
|
option(LIBICSNEO_ENABLE_RAW_ETHERNET "Enable devices which communicate over raw ethernet" ON)
|
||||||
option(LIBICSNEO_ENABLE_CDCACM "Enable devices which communicate over USB CDC ACM" ON)
|
option(LIBICSNEO_ENABLE_CDCACM "Enable devices which communicate over USB CDC ACM" ON)
|
||||||
option(LIBICSNEO_ENABLE_FTDI "Enable devices which communicate over USB FTDI2XX" ON)
|
|
||||||
option(LIBICSNEO_ENABLE_TCP "Enable devices which communicate over TCP" OFF)
|
option(LIBICSNEO_ENABLE_TCP "Enable devices which communicate over TCP" OFF)
|
||||||
option(LIBICSNEO_ENABLE_FTD3XX "Enable devices which communicate over USB FTD3XX" ON)
|
option(LIBICSNEO_ENABLE_DXX "Enable devices which communicate over D2XX/D3XX via libredxx" ON)
|
||||||
|
|
||||||
option(LIBICSNEO_ENABLE_BINDINGS_PYTHON "Enable Python library" OFF)
|
option(LIBICSNEO_ENABLE_BINDINGS_PYTHON "Enable Python library" OFF)
|
||||||
|
|
||||||
if(NOT CMAKE_CXX_STANDARD)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||||
endif()
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
@@ -38,17 +36,13 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|||||||
|
|
||||||
# Enable Warnings
|
# Enable Warnings
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Force to always compile with W4
|
set(LIBICSNEO_COMPILER_WARNINGS /W4)
|
||||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
||||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
||||||
else()
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
|
||||||
endif()
|
|
||||||
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0618r0.html
|
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0618r0.html
|
||||||
# Still supported until a suitable replacement is standardized
|
# Still supported until a suitable replacement is standardized
|
||||||
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)
|
||||||
else() #if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
else() #if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-switch -Wno-unknown-pragmas")
|
set(LIBICSNEO_COMPILER_WARNINGS -Wall -Wno-switch -Wno-unknown-pragmas)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
@@ -109,7 +103,6 @@ if(LIBICSNEO_BUILD_DOCS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
set(PLATFORM_SRC
|
set(PLATFORM_SRC
|
||||||
platform/windows/strings.cpp
|
platform/windows/strings.cpp
|
||||||
platform/windows/registry.cpp
|
platform/windows/registry.cpp
|
||||||
@@ -122,9 +115,9 @@ if(WIN32)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_ENABLE_CDCACM OR LIBICSNEO_ENABLE_FTDI)
|
if(LIBICSNEO_ENABLE_CDCACM)
|
||||||
list(APPEND PLATFORM_SRC
|
list(APPEND PLATFORM_SRC
|
||||||
platform/windows/vcp.cpp
|
platform/windows/cdcacm.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
else() # Darwin or Linux
|
else() # Darwin or Linux
|
||||||
@@ -142,12 +135,6 @@ else() # Darwin or Linux
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_ENABLE_FTDI)
|
|
||||||
list(APPEND PLATFORM_SRC
|
|
||||||
platform/posix/ftdi.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(LIBICSNEO_ENABLE_CDCACM)
|
if(LIBICSNEO_ENABLE_CDCACM)
|
||||||
list(APPEND PLATFORM_SRC
|
list(APPEND PLATFORM_SRC
|
||||||
platform/posix/cdcacm.cpp
|
platform/posix/cdcacm.cpp
|
||||||
@@ -171,51 +158,9 @@ else() # Darwin or Linux
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_ENABLE_FTD3XX)
|
if(LIBICSNEO_ENABLE_DXX)
|
||||||
if(NOT FTD3XX_ROOT) # allow system override
|
|
||||||
include(FetchContent)
|
|
||||||
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(LIBICSNEO_FTD3XX_URL "https://github.com/intrepidcs/libftd3xx-repack/releases/download/24.34.0/libftd3xx-1.3.0.10-win-x64.zip")
|
|
||||||
set(LIBICSNEO_FTD3XX_URL_HASH "SHA256=459e635496ab47d6069c9d3515fdd6d82cba3d95e7ae34f794d66ffdf336e9d1")
|
|
||||||
elseif(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
||||||
set(LIBICSNEO_FTD3XX_URL "https://github.com/intrepidcs/libftd3xx-repack/releases/download/24.34.0/libftd3xx-1.3.0.10-win-i686.zip")
|
|
||||||
set(LIBICSNEO_FTD3XX_URL_HASH "SHA256=ce4259ae11772d6ede7d217172156fa392f329b29d9455131f4126a2fb89dad1")
|
|
||||||
elseif(APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(LIBICSNEO_FTD3XX_URL "https://github.com/intrepidcs/libftd3xx-repack/releases/download/24.34.0/libftd3xx-1.0.16-macos-universal2.zip")
|
|
||||||
set(LIBICSNEO_FTD3XX_URL_HASH "SHA256=0904ac5eda8e1dc4b5aac3714383bcc7792b42dfeb585dce6cbfb8b67b8c0c51")
|
|
||||||
elseif(UNIX)
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(LIBICSNEO_FTD3XX_URL "https://github.com/intrepidcs/libftd3xx-repack/releases/download/24.34.0/libftd3xx-1.0.16-linux-x64.zip")
|
|
||||||
set(LIBICSNEO_FTD3XX_URL_HASH "SHA256=cf66bf299fc722f050cdd3c36998a670f1df69f7c0df18afa73707277067114b")
|
|
||||||
endif()
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*|aarch64")
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(LIBICSNEO_FTD3XX_URL "https://github.com/intrepidcs/libftd3xx-repack/releases/download/24.34.0/libftd3xx-1.0.16-linux-aarch64.zip")
|
|
||||||
set(LIBICSNEO_FTD3XX_URL_HASH "SHA256=66341b5112b9841e959e81400b51711be96fec91894477c5cbfc29b10a0c00a6")
|
|
||||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
||||||
set(LIBICSNEO_FTD3XX_URL "https://github.com/intrepidcs/libftd3xx-repack/releases/download/24.34.0/libftd3xx-1.0.16-linux-armhf.zip")
|
|
||||||
set(LIBICSNEO_FTD3XX_URL_HASH "SHA256=cec1f959b48a11eb6b829ed43c81b6ba1c0bcf3e797bafcc84a6376e5ffc3c47")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
if(NOT LIBICSNEO_FTD3XX_URL)
|
|
||||||
message(FATAL_ERROR "Unsupported platform for FTD3XX driver")
|
|
||||||
endif()
|
|
||||||
FetchContent_Declare(
|
|
||||||
ftdi3xx
|
|
||||||
URL ${LIBICSNEO_FTD3XX_URL}
|
|
||||||
URL_HASH ${LIBICSNEO_FTD3XX_URL_HASH}
|
|
||||||
)
|
|
||||||
FetchContent_GetProperties(ftdi3xx)
|
|
||||||
if(NOT ftdi3xx_POPULATED)
|
|
||||||
FetchContent_Populate(ftdi3xx)
|
|
||||||
endif()
|
|
||||||
set(FTD3XX_ROOT "${ftdi3xx_SOURCE_DIR}")
|
|
||||||
endif()
|
|
||||||
find_package(FTD3XX REQUIRED)
|
|
||||||
list(APPEND PLATFORM_SRC
|
list(APPEND PLATFORM_SRC
|
||||||
platform/ftd3xx.cpp
|
platform/dxx.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -251,9 +196,13 @@ set(SRC_FILES
|
|||||||
communication/message/gptpstatusmessage.cpp
|
communication/message/gptpstatusmessage.cpp
|
||||||
communication/message/ethernetstatusmessage.cpp
|
communication/message/ethernetstatusmessage.cpp
|
||||||
communication/message/macsecmessage.cpp
|
communication/message/macsecmessage.cpp
|
||||||
|
communication/message/networkmutexmessage.cpp
|
||||||
|
communication/message/clientidmessage.cpp
|
||||||
|
communication/message/transmitmessage.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
|
||||||
|
communication/packet/spipacket.cpp
|
||||||
communication/packet/ethernetpacket.cpp
|
communication/packet/ethernetpacket.cpp
|
||||||
communication/packet/versionpacket.cpp
|
communication/packet/versionpacket.cpp
|
||||||
communication/packet/iso9141packet.cpp
|
communication/packet/iso9141packet.cpp
|
||||||
@@ -292,6 +241,7 @@ set(SRC_FILES
|
|||||||
disk/plasiondiskreaddriver.cpp
|
disk/plasiondiskreaddriver.cpp
|
||||||
disk/extextractordiskreaddriver.cpp
|
disk/extextractordiskreaddriver.cpp
|
||||||
disk/fat.cpp
|
disk/fat.cpp
|
||||||
|
disk/diskdetails.cpp
|
||||||
disk/vsa/vsa.cpp
|
disk/vsa/vsa.cpp
|
||||||
disk/vsa/vsa02.cpp
|
disk/vsa/vsa02.cpp
|
||||||
disk/vsa/vsa03.cpp
|
disk/vsa/vsa03.cpp
|
||||||
@@ -372,6 +322,7 @@ target_include_directories(icsneocpp
|
|||||||
target_link_libraries(icsneocpp PUBLIC Threads::Threads $<$<BOOL:${WIN32}>:ws2_32 iphlpapi>)
|
target_link_libraries(icsneocpp PUBLIC Threads::Threads $<$<BOOL:${WIN32}>:ws2_32 iphlpapi>)
|
||||||
set_property(TARGET icsneocpp PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET icsneocpp PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
target_compile_features(icsneocpp PUBLIC cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums)
|
target_compile_features(icsneocpp PUBLIC cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums)
|
||||||
|
target_compile_options(icsneocpp PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
message("Loaded extensions: " ${LIBICSNEO_EXTENSION_TARGETS})
|
message("Loaded extensions: " ${LIBICSNEO_EXTENSION_TARGETS})
|
||||||
target_link_libraries(icsneocpp PUBLIC ${LIBICSNEO_EXTENSION_TARGETS})
|
target_link_libraries(icsneocpp PUBLIC ${LIBICSNEO_EXTENSION_TARGETS})
|
||||||
if(LIBICSNEO_ENABLE_FIRMIO)
|
if(LIBICSNEO_ENABLE_FIRMIO)
|
||||||
@@ -382,13 +333,15 @@ if(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
|||||||
endif()
|
endif()
|
||||||
if(LIBICSNEO_ENABLE_CDCACM)
|
if(LIBICSNEO_ENABLE_CDCACM)
|
||||||
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_CDCACM)
|
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_CDCACM)
|
||||||
|
if(APPLE)
|
||||||
|
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
|
||||||
|
find_library(IO_KIT_FRAMEWORK IOKit REQUIRED)
|
||||||
|
target_link_libraries(icsneocpp PRIVATE ${CORE_FOUNDATION_FRAMEWORK} ${IO_KIT_FRAMEWORK})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(LIBICSNEO_ENABLE_FTDI)
|
if(LIBICSNEO_ENABLE_DXX)
|
||||||
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_FTDI)
|
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_DXX)
|
||||||
endif()
|
target_link_libraries(icsneocpp PRIVATE libredxx::libredxx)
|
||||||
if(LIBICSNEO_ENABLE_FTD3XX)
|
|
||||||
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_FTD3XX)
|
|
||||||
target_link_libraries(icsneocpp PRIVATE FTD3XX::FTD3XX)
|
|
||||||
endif()
|
endif()
|
||||||
if(LIBICSNEO_ENABLE_TCP)
|
if(LIBICSNEO_ENABLE_TCP)
|
||||||
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_TCP)
|
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_TCP)
|
||||||
@@ -402,25 +355,16 @@ add_subdirectory(third-party/fatfs)
|
|||||||
set_property(TARGET fatfs PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET fatfs PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
target_link_libraries(icsneocpp PRIVATE fatfs)
|
target_link_libraries(icsneocpp PRIVATE fatfs)
|
||||||
|
|
||||||
# libftdi
|
# dxx
|
||||||
if(LIBICSNEO_ENABLE_FTDI)
|
if(LIBICSNEO_ENABLE_DXX)
|
||||||
if(NOT WIN32)
|
include(FetchContent)
|
||||||
target_include_directories(icsneocpp PUBLIC third-party/libftdi/src)
|
FetchContent_Declare(libredxx
|
||||||
set(LIBFTDI_DOCUMENTATION OFF CACHE INTERNAL "")
|
GIT_REPOSITORY https://github.com/Zeranoe/libredxx.git
|
||||||
set(LIBFTDI_BUILD_TESTS OFF CACHE INTERNAL "")
|
GIT_TAG e1fe2bd6ba6079b17037379d78f3f18024b389d7
|
||||||
set(LIBFTDI_INSTALL OFF CACHE INTERNAL "")
|
)
|
||||||
set(LIBFTDI_PYTHON_BINDINGS OFF CACHE INTERNAL "")
|
set(LIBREDXX_DISABLE_INSTALL ON)
|
||||||
set(LIBFTDI_LINK_PYTHON_LIBRARY OFF CACHE INTERNAL "")
|
FetchContent_MakeAvailable(libredxx)
|
||||||
set(FTDIPP OFF CACHE INTERNAL "")
|
endif()
|
||||||
set(FTDI_EEPROM OFF CACHE INTERNAL "")
|
|
||||||
add_subdirectory(third-party/libftdi)
|
|
||||||
target_include_directories(icsneocpp PRIVATE ${LIBUSB_INCLUDE_DIR})
|
|
||||||
|
|
||||||
set_property(TARGET ftdi1-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
||||||
target_link_libraries(icsneocpp PUBLIC ftdi1-static)
|
|
||||||
target_link_libraries(icsneocpp PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
endif(NOT WIN32)
|
|
||||||
endif(LIBICSNEO_ENABLE_FTDI)
|
|
||||||
|
|
||||||
# pcap
|
# pcap
|
||||||
if(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
if(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
||||||
@@ -438,6 +382,21 @@ if(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
|||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
endif(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
endif(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
||||||
|
|
||||||
|
# protobuf
|
||||||
|
if(DEFINED ENV{LIBICSNEO_ICSPB_REPO})
|
||||||
|
set(LIBICSNEO_ICSPB_REPO "$ENV{LIBICSNEO_ICSPB_REPO}")
|
||||||
|
endif()
|
||||||
|
if(NOT LIBICSNEO_ICSPB_REPO)
|
||||||
|
set(LIBICSNEO_ICSPB_REPO https://github.com/intrepidcs/icspb.git)
|
||||||
|
endif()
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(icspb
|
||||||
|
GIT_REPOSITORY ${LIBICSNEO_ICSPB_REPO}
|
||||||
|
GIT_TAG 2881dc4239319214dbf72fd3aa0427a4aefddd42
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(icspb)
|
||||||
|
target_link_libraries(icsneocpp PRIVATE icspb::icspb)
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_ICSNEOC)
|
if(LIBICSNEO_BUILD_ICSNEOC)
|
||||||
add_library(icsneoc SHARED api/icsneoc/icsneoc.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated/icsneoc/version.rc)
|
add_library(icsneoc SHARED api/icsneoc/icsneoc.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated/icsneoc/version.rc)
|
||||||
target_include_directories(icsneoc
|
target_include_directories(icsneoc
|
||||||
@@ -449,6 +408,7 @@ if(LIBICSNEO_BUILD_ICSNEOC)
|
|||||||
)
|
)
|
||||||
target_link_libraries(icsneoc PRIVATE icsneocpp)
|
target_link_libraries(icsneoc PRIVATE icsneocpp)
|
||||||
target_compile_features(icsneoc PRIVATE cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums)
|
target_compile_features(icsneoc 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(icsneoc PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_ICSNEOC_STATIC)
|
if(LIBICSNEO_BUILD_ICSNEOC_STATIC)
|
||||||
@@ -463,6 +423,7 @@ if(LIBICSNEO_BUILD_ICSNEOC_STATIC)
|
|||||||
target_link_libraries(icsneoc-static PUBLIC icsneocpp)
|
target_link_libraries(icsneoc-static PUBLIC icsneocpp)
|
||||||
target_compile_features(icsneoc-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_features(icsneoc-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(icsneoc-static PUBLIC ICSNEOC_BUILD_STATIC)
|
target_compile_definitions(icsneoc-static PUBLIC ICSNEOC_BUILD_STATIC)
|
||||||
|
target_compile_options(icsneoc-static PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_ICSNEOLEGACY)
|
if(LIBICSNEO_BUILD_ICSNEOLEGACY)
|
||||||
@@ -481,6 +442,7 @@ if(LIBICSNEO_BUILD_ICSNEOLEGACY)
|
|||||||
)
|
)
|
||||||
target_link_libraries(icsneolegacy PRIVATE icsneocpp)
|
target_link_libraries(icsneolegacy PRIVATE icsneocpp)
|
||||||
target_compile_features(icsneolegacy PRIVATE cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums)
|
target_compile_features(icsneolegacy 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(icsneolegacy PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC)
|
if(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC)
|
||||||
@@ -500,23 +462,19 @@ if(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC)
|
|||||||
target_link_libraries(icsneolegacy-static PUBLIC icsneocpp)
|
target_link_libraries(icsneolegacy-static PUBLIC icsneocpp)
|
||||||
target_compile_features(icsneolegacy-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_features(icsneolegacy-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(icsneolegacy-static PUBLIC ICSNEOC_BUILD_STATIC)
|
target_compile_definitions(icsneolegacy-static PUBLIC ICSNEOC_BUILD_STATIC)
|
||||||
|
target_compile_options(icsneolegacy-static PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(bindings)
|
add_subdirectory(bindings)
|
||||||
|
|
||||||
# googletest
|
# googletest
|
||||||
if(LIBICSNEO_BUILD_UNIT_TESTS)
|
if(LIBICSNEO_BUILD_UNIT_TESTS)
|
||||||
if(WIN32)
|
include(FetchContent)
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
FetchContent_Declare(googletest
|
||||||
endif()
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||||
|
GIT_TAG 6986c2b575f77135401a4e1c65a7a42f20e18fef
|
||||||
if (NOT TARGET gtest)
|
)
|
||||||
add_subdirectory(third-party/googletest-master)
|
FetchContent_MakeAvailable(googletest)
|
||||||
endif()
|
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
|
||||||
include_directories("${gtest_SOURCE_DIR}/include")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(libicsneo-unit-tests
|
add_executable(libicsneo-unit-tests
|
||||||
test/unit/main.cpp
|
test/unit/main.cpp
|
||||||
@@ -532,8 +490,11 @@ if(LIBICSNEO_BUILD_UNIT_TESTS)
|
|||||||
test/unit/ringbuffertest.cpp
|
test/unit/ringbuffertest.cpp
|
||||||
test/unit/apperrordecodertest.cpp
|
test/unit/apperrordecodertest.cpp
|
||||||
test/unit/windowsstrings.cpp
|
test/unit/windowsstrings.cpp
|
||||||
|
test/unit/periodictest.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_compile_options(libicsneo-unit-tests PRIVATE ${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
@@ -546,4 +507,4 @@ endif()
|
|||||||
|
|
||||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ each of the respective APIs.
|
|||||||
- RAD-EpsilonXL
|
- RAD-EpsilonXL
|
||||||
- RAD-Galaxy
|
- RAD-Galaxy
|
||||||
- RAD-Galaxy 2
|
- RAD-Galaxy 2
|
||||||
|
- RAD-Gemini
|
||||||
- RAD-Gigastar
|
- RAD-Gigastar
|
||||||
- RAD-Gigastar 2
|
- RAD-Gigastar 2
|
||||||
- RAD-Moon 2
|
- RAD-Moon 2
|
||||||
|
|||||||
@@ -757,3 +757,33 @@ bool icsneo_isOnlineSupported(const neodevice_t* device) {
|
|||||||
|
|
||||||
return device->device->isOnlineSupported();
|
return device->device->isOnlineSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool icsneo_requestTC10Wake(const neodevice_t* device, neonetid_t netid) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return device->device->requestTC10Wake((Network::NetID)netid);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool icsneo_requestTC10Sleep(const neodevice_t* device, neonetid_t netid) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return device->device->requestTC10Sleep((Network::NetID)netid);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool icsneo_getTC10Status(const neodevice_t* device, neonetid_t netid, neotc10status_t* status) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto statusMsg = device->device->getTC10Status((Network::NetID)netid);
|
||||||
|
|
||||||
|
if(!statusMsg)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
status->wakeStatus = (neotc10wakestatus_t)statusMsg->wakeStatus;
|
||||||
|
status->sleepStatus = (neotc10sleepstatus_t)statusMsg->sleepStatus;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-106
@@ -28,7 +28,7 @@ std::string APIEvent::describe() const noexcept {
|
|||||||
ss << *device; // Makes use of device.describe()
|
ss << *device; // Makes use of device.describe()
|
||||||
else
|
else
|
||||||
ss << "API";
|
ss << "API";
|
||||||
|
|
||||||
Severity severity = getSeverity();
|
Severity severity = getSeverity();
|
||||||
if(severity == Severity::EventInfo) {
|
if(severity == Severity::EventInfo) {
|
||||||
ss << " Info: ";
|
ss << " Info: ";
|
||||||
@@ -74,6 +74,9 @@ static constexpr const char* TIMEOUT = "The timeout was reached.";
|
|||||||
static constexpr const char* WIVI_NOT_SUPPORTED = "Wireless neoVI functions are not supported on this device.";
|
static constexpr const char* WIVI_NOT_SUPPORTED = "Wireless neoVI functions are not supported on this device.";
|
||||||
static constexpr const char* RESTRICTED_ENTRY_FLAG = "Attempted to set a restricted flag in a Root Directory entry.";
|
static constexpr const char* RESTRICTED_ENTRY_FLAG = "Attempted to set a restricted flag in a Root Directory entry.";
|
||||||
static constexpr const char* NOT_SUPPORTED = "The requested feature is not supported.";
|
static constexpr const char* NOT_SUPPORTED = "The requested feature is not supported.";
|
||||||
|
static constexpr const char* FIXED_POINT_OVERFLOW = "Value is too large to convert to fixed point.";
|
||||||
|
static constexpr const char* FIXED_POINT_PRECISION = "Value is too small for fixed point precision.";
|
||||||
|
static constexpr const char* SYSCALL_ERROR = "Error returned from syscall, check errno/GetLastError().";
|
||||||
|
|
||||||
// Device Errors
|
// Device Errors
|
||||||
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
||||||
@@ -114,7 +117,7 @@ static constexpr const char* ATOMIC_OPERATION_RETRIED = "An operation failed to
|
|||||||
static constexpr const char* ATOMIC_OPERATION_COMPLETED_NONATOMICALLY = "An ideally-atomic operation was completed nonatomically.";
|
static constexpr const char* ATOMIC_OPERATION_COMPLETED_NONATOMICALLY = "An ideally-atomic operation was completed nonatomically.";
|
||||||
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* 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.";
|
||||||
@@ -122,6 +125,10 @@ static constexpr const char* LIN_SETTINGS_NOT_AVAILABLE = "LIN settings are not
|
|||||||
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* 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_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.";
|
||||||
@@ -140,41 +147,6 @@ static constexpr const char* ERROR_SETTING_SOCKET_OPTION = "A call to setsockopt
|
|||||||
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.";
|
||||||
|
|
||||||
// FTD3XX
|
|
||||||
static constexpr const char* FT_OK = "FTD3XX success.";
|
|
||||||
static constexpr const char* FT_INVALID_HANDLE = "Invalid FTD3XX handle.";
|
|
||||||
static constexpr const char* FT_DEVICE_NOT_FOUND = "FTD3XX device not found.";
|
|
||||||
static constexpr const char* FT_DEVICE_NOT_OPENED = "FTD3XX device not opened.";
|
|
||||||
static constexpr const char* FT_IO_ERROR = "FTD3XX IO error.";
|
|
||||||
static constexpr const char* FT_INSUFFICIENT_RESOURCES = "Insufficient resources for FTD3XX.";
|
|
||||||
static constexpr const char* FT_INVALID_PARAMETER = "Invalid FTD3XX parameter.";
|
|
||||||
static constexpr const char* FT_INVALID_BAUD_RATE = "Invalid FTD3XX baud rate.";
|
|
||||||
static constexpr const char* FT_DEVICE_NOT_OPENED_FOR_ERASE = "FTD3XX device not opened for erase.";
|
|
||||||
static constexpr const char* FT_DEVICE_NOT_OPENED_FOR_WRITE = "FTD3XX not opened for write.";
|
|
||||||
static constexpr const char* FT_FAILED_TO_WRITE_DEVICE = "FTD3XX failed to write device.";
|
|
||||||
static constexpr const char* FT_EEPROM_READ_FAILED = "FTD3XX EEPROM read failed.";
|
|
||||||
static constexpr const char* FT_EEPROM_WRITE_FAILED = "FTD3XX EEPROM write failed.";
|
|
||||||
static constexpr const char* FT_EEPROM_ERASE_FAILED = "FTD3XX EEPROM erase failed.";
|
|
||||||
static constexpr const char* FT_EEPROM_NOT_PRESENT = "FTD3XX EEPROM not present.";
|
|
||||||
static constexpr const char* FT_EEPROM_NOT_PROGRAMMED = "FTD3XX EEPROM not programmed.";
|
|
||||||
static constexpr const char* FT_INVALID_ARGS = "Invalid FTD3XX arguments.";
|
|
||||||
static constexpr const char* FT_NOT_SUPPORTED = "FTD3XX not supported.";
|
|
||||||
static constexpr const char* FT_NO_MORE_ITEMS = "No more FTD3XX items.";
|
|
||||||
static constexpr const char* FT_TIMEOUT = "FTD3XX timeout.";
|
|
||||||
static constexpr const char* FT_OPERATION_ABORTED = "FTD3XX operation aborted.";
|
|
||||||
static constexpr const char* FT_RESERVED_PIPE = "Reserved FTD3XX pipe.";
|
|
||||||
static constexpr const char* FT_INVALID_CONTROL_REQUEST_DIRECTION = "Invalid FTD3XX control request direction.";
|
|
||||||
static constexpr const char* FT_INVALID_CONTROL_REQUEST_TYPE = "Invalid FTD3XX control request type.";
|
|
||||||
static constexpr const char* FT_IO_PENDING = "FTD3XX IO pending.";
|
|
||||||
static constexpr const char* FT_IO_INCOMPLETE = "FTD3XX IO incomplete.";
|
|
||||||
static constexpr const char* FT_HANDLE_EOF = "Handle FTD3XX EOF.";
|
|
||||||
static constexpr const char* FT_BUSY = "FTD3XX busy.";
|
|
||||||
static constexpr const char* FT_NO_SYSTEM_RESOURCES = "No FTD3XX system resources.";
|
|
||||||
static constexpr const char* FT_DEVICE_LIST_NOT_READY = "FTD3XX device list not ready.";
|
|
||||||
static constexpr const char* FT_DEVICE_NOT_CONNECTED = "FTD3XX device not connected.";
|
|
||||||
static constexpr const char* FT_INCORRECT_DEVICE_PATH = "Incorrect FTD3XX device path.";
|
|
||||||
static constexpr const char* FT_OTHER_ERROR = "Other FTD3XX error.";
|
|
||||||
|
|
||||||
// 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.";
|
||||||
static constexpr const char* VSA_TIMESTAMP_NOT_FOUND = "Unable to find a VSA record with a valid timestamp.";
|
static constexpr const char* VSA_TIMESTAMP_NOT_FOUND = "Unable to find a VSA record with a valid timestamp.";
|
||||||
@@ -197,6 +169,13 @@ 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";
|
||||||
|
|
||||||
|
// DXX
|
||||||
|
static constexpr const char* DXX_ERROR_SYS = "System error, check errno/GetLastError()";
|
||||||
|
static constexpr const char* DXX_ERROR_INT = "DXX interrupt called";
|
||||||
|
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_ARG = "Invalid arg passed to DXX";
|
||||||
|
|
||||||
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.";
|
||||||
@@ -240,6 +219,12 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return RESTRICTED_ENTRY_FLAG;
|
return RESTRICTED_ENTRY_FLAG;
|
||||||
case Type::NotSupported:
|
case Type::NotSupported:
|
||||||
return NOT_SUPPORTED;
|
return NOT_SUPPORTED;
|
||||||
|
case Type::FixedPointOverflow:
|
||||||
|
return FIXED_POINT_OVERFLOW;
|
||||||
|
case Type::FixedPointPrecision:
|
||||||
|
return FIXED_POINT_PRECISION;
|
||||||
|
case Type::SyscallError:
|
||||||
|
return SYSCALL_ERROR;
|
||||||
|
|
||||||
// Device Errors
|
// Device Errors
|
||||||
case Type::PollingMessageOverflow:
|
case Type::PollingMessageOverflow:
|
||||||
@@ -365,74 +350,10 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
return SEND_TO_ERROR;
|
return SEND_TO_ERROR;
|
||||||
case Type::GPTPNotSupported:
|
case Type::GPTPNotSupported:
|
||||||
return GPTP_NOT_SUPPORTED;
|
return GPTP_NOT_SUPPORTED;
|
||||||
|
case Type::DiskFormatNotSupported:
|
||||||
// FTD3XX
|
return DISK_FORMAT_NOT_SUPPORTED;
|
||||||
case Type::FTOK:
|
case Type::DiskFormatInvalidCount:
|
||||||
return FT_OK;
|
return DISK_FORMAT_INVALID_COUNT;
|
||||||
case Type::FTInvalidHandle:
|
|
||||||
return FT_INVALID_HANDLE;
|
|
||||||
case Type::FTDeviceNotFound:
|
|
||||||
return FT_DEVICE_NOT_FOUND;
|
|
||||||
case Type::FTDeviceNotOpened:
|
|
||||||
return FT_DEVICE_NOT_OPENED;
|
|
||||||
case Type::FTIOError:
|
|
||||||
return FT_IO_ERROR;
|
|
||||||
case Type::FTInsufficientResources:
|
|
||||||
return FT_INSUFFICIENT_RESOURCES;
|
|
||||||
case Type::FTInvalidParameter:
|
|
||||||
return FT_INVALID_PARAMETER;
|
|
||||||
case Type::FTInvalidBaudRate:
|
|
||||||
return FT_INVALID_BAUD_RATE;
|
|
||||||
case Type::FTDeviceNotOpenedForErase:
|
|
||||||
return FT_DEVICE_NOT_OPENED_FOR_ERASE;
|
|
||||||
case Type::FTDeviceNotOpenedForWrite:
|
|
||||||
return FT_DEVICE_NOT_OPENED_FOR_WRITE;
|
|
||||||
case Type::FTFailedToWriteDevice:
|
|
||||||
return FT_FAILED_TO_WRITE_DEVICE;
|
|
||||||
case Type::FTEEPROMReadFailed:
|
|
||||||
return FT_EEPROM_READ_FAILED;
|
|
||||||
case Type::FTEEPROMWriteFailed:
|
|
||||||
return FT_EEPROM_WRITE_FAILED;
|
|
||||||
case Type::FTEEPROMEraseFailed:
|
|
||||||
return FT_EEPROM_ERASE_FAILED;
|
|
||||||
case Type::FTEEPROMNotPresent:
|
|
||||||
return FT_EEPROM_NOT_PRESENT;
|
|
||||||
case Type::FTEEPROMNotProgrammed:
|
|
||||||
return FT_EEPROM_NOT_PROGRAMMED;
|
|
||||||
case Type::FTInvalidArgs:
|
|
||||||
return FT_INVALID_ARGS;
|
|
||||||
case Type::FTNotSupported:
|
|
||||||
return FT_NOT_SUPPORTED;
|
|
||||||
case Type::FTNoMoreItems:
|
|
||||||
return FT_NO_MORE_ITEMS;
|
|
||||||
case Type::FTTimeout:
|
|
||||||
return FT_TIMEOUT;
|
|
||||||
case Type::FTOperationAborted:
|
|
||||||
return FT_OPERATION_ABORTED;
|
|
||||||
case Type::FTReservedPipe:
|
|
||||||
return FT_RESERVED_PIPE;
|
|
||||||
case Type::FTInvalidControlRequestDirection:
|
|
||||||
return FT_INVALID_CONTROL_REQUEST_DIRECTION;
|
|
||||||
case Type::FTInvalidControlRequestType:
|
|
||||||
return FT_INVALID_CONTROL_REQUEST_TYPE;
|
|
||||||
case Type::FTIOPending:
|
|
||||||
return FT_IO_PENDING;
|
|
||||||
case Type::FTIOIncomplete:
|
|
||||||
return FT_IO_INCOMPLETE;
|
|
||||||
case Type::FTHandleEOF:
|
|
||||||
return FT_HANDLE_EOF;
|
|
||||||
case Type::FTBusy:
|
|
||||||
return FT_BUSY;
|
|
||||||
case Type::FTNoSystemResources:
|
|
||||||
return FT_NO_SYSTEM_RESOURCES;
|
|
||||||
case Type::FTDeviceListNotReady:
|
|
||||||
return FT_DEVICE_LIST_NOT_READY;
|
|
||||||
case Type::FTDeviceNotConnected:
|
|
||||||
return FT_DEVICE_NOT_CONNECTED;
|
|
||||||
case Type::FTIncorrectDevicePath:
|
|
||||||
return FT_INCORRECT_DEVICE_PATH;
|
|
||||||
case Type::FTOtherError:
|
|
||||||
return FT_OTHER_ERROR;
|
|
||||||
|
|
||||||
// VSA
|
// VSA
|
||||||
case Type::VSABufferCorrupted:
|
case Type::VSABufferCorrupted:
|
||||||
@@ -474,6 +395,18 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
case Type::ServdJoinMulticastError:
|
case Type::ServdJoinMulticastError:
|
||||||
return SERVD_JOIN_MULTICAST_ERROR;
|
return SERVD_JOIN_MULTICAST_ERROR;
|
||||||
|
|
||||||
|
// DXX
|
||||||
|
case Type::DXXErrorSys:
|
||||||
|
return DXX_ERROR_SYS;
|
||||||
|
case Type::DXXErrorInt:
|
||||||
|
return DXX_ERROR_INT;
|
||||||
|
case Type::DXXErrorOverflow:
|
||||||
|
return DXX_ERROR_OVERFLOW;
|
||||||
|
case Type::DXXErrorIO:
|
||||||
|
return DXX_ERROR_IO;
|
||||||
|
case Type::DXXErrorArg:
|
||||||
|
return DXX_ERROR_ARG;
|
||||||
|
|
||||||
// Other Errors
|
// Other Errors
|
||||||
case Type::TooManyEvents:
|
case Type::TooManyEvents:
|
||||||
return TOO_MANY_EVENTS;
|
return TOO_MANY_EVENTS;
|
||||||
@@ -487,7 +420,7 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||||||
bool EventFilter::match(const APIEvent& event) const noexcept {
|
bool EventFilter::match(const APIEvent& event) const noexcept {
|
||||||
if(type != APIEvent::Type::Any && type != event.getType())
|
if(type != APIEvent::Type::Any && type != event.getType())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(matchOnDevicePtr && !event.isForDevice(device))
|
if(matchOnDevicePtr && !event.isForDevice(device))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
//FILE: icsneo40DLLAPI.H
|
//FILE: icsneo40DLLAPI.H
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "icsneo/icsnVC40.h"
|
#include "icsneo/icsnVC40.h"
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ static bool NeoMessageToSpyMessage(const neodevice_t* device, const neomessage_t
|
|||||||
copyFrameData();
|
copyFrameData();
|
||||||
break;
|
break;
|
||||||
case Network::Type::Ethernet:
|
case Network::Type::Ethernet:
|
||||||
|
case Network::Type::AutomotiveEthernet:
|
||||||
oldmsg.Protocol = SPY_PROTOCOL_ETHERNET;
|
oldmsg.Protocol = SPY_PROTOCOL_ETHERNET;
|
||||||
oldmsg.NumberBytesData = static_cast<uint8_t>(frame.length & 0xFF);
|
oldmsg.NumberBytesData = static_cast<uint8_t>(frame.length & 0xFF);
|
||||||
oldmsg.NumberBytesHeader = static_cast<uint8_t>(frame.length >> 8);
|
oldmsg.NumberBytesHeader = static_cast<uint8_t>(frame.length >> 8);
|
||||||
@@ -1075,6 +1076,9 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void* hObject, EPlasmaIonVnetCha
|
|||||||
case NEODEVICE_RADMOON3:
|
case NEODEVICE_RADMOON3:
|
||||||
*pDeviceSettingsType = DeviceRADMoon3SettingsType;
|
*pDeviceSettingsType = DeviceRADMoon3SettingsType;
|
||||||
break;
|
break;
|
||||||
|
case NEODEVICE_RADGEMINI:
|
||||||
|
*pDeviceSettingsType = DeviceRADGeminiSettingsType;
|
||||||
|
break;
|
||||||
case NEODEVICE_RED2:
|
case NEODEVICE_RED2:
|
||||||
*pDeviceSettingsType = DeviceRed2SettingsType;
|
*pDeviceSettingsType = DeviceRed2SettingsType;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -31,13 +31,18 @@ pybind11_add_module(icsneopy
|
|||||||
icsneopy/communication/message/mdiomessage.cpp
|
icsneopy/communication/message/mdiomessage.cpp
|
||||||
icsneopy/communication/message/gptpstatusmessage.cpp
|
icsneopy/communication/message/gptpstatusmessage.cpp
|
||||||
icsneopy/communication/message/ethernetstatusmessage.cpp
|
icsneopy/communication/message/ethernetstatusmessage.cpp
|
||||||
|
icsneopy/communication/message/spimessage.cpp
|
||||||
icsneopy/communication/message/macsecmessage.cpp
|
icsneopy/communication/message/macsecmessage.cpp
|
||||||
icsneopy/communication/message/scriptstatusmessage.cpp
|
icsneopy/communication/message/scriptstatusmessage.cpp
|
||||||
|
icsneopy/communication/message/ethphymessage.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/communication/message/flexray/flexraymessage.cpp
|
icsneopy/flexray/flexray.cpp
|
||||||
icsneopy/disk/diskdriver.cpp
|
icsneopy/disk/diskdriver.cpp
|
||||||
|
icsneopy/device/chipid.cpp
|
||||||
|
icsneopy/device/versionreport.cpp
|
||||||
icsneopy/device/device.cpp
|
icsneopy/device/device.cpp
|
||||||
|
icsneopy/device/extensions/deviceextension.cpp
|
||||||
icsneopy/device/idevicesettings.cpp
|
icsneopy/device/idevicesettings.cpp
|
||||||
icsneopy/icsneocpp.cpp
|
icsneopy/icsneocpp.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ void init_event(pybind11::module_& m) {
|
|||||||
.value("WiVINotSupported", APIEvent::Type::WiVINotSupported)
|
.value("WiVINotSupported", APIEvent::Type::WiVINotSupported)
|
||||||
.value("RestrictedEntryFlag", APIEvent::Type::RestrictedEntryFlag)
|
.value("RestrictedEntryFlag", APIEvent::Type::RestrictedEntryFlag)
|
||||||
.value("NotSupported", APIEvent::Type::NotSupported)
|
.value("NotSupported", APIEvent::Type::NotSupported)
|
||||||
|
.value("FixedPointOverflow", APIEvent::Type::FixedPointOverflow)
|
||||||
|
.value("FixedPointPrecision", APIEvent::Type::FixedPointPrecision)
|
||||||
|
.value("SyscallError", APIEvent::Type::SyscallError)
|
||||||
.value("PollingMessageOverflow", APIEvent::Type::PollingMessageOverflow)
|
.value("PollingMessageOverflow", APIEvent::Type::PollingMessageOverflow)
|
||||||
.value("NoSerialNumber", APIEvent::Type::NoSerialNumber)
|
.value("NoSerialNumber", APIEvent::Type::NoSerialNumber)
|
||||||
.value("IncorrectSerialNumber", APIEvent::Type::IncorrectSerialNumber)
|
.value("IncorrectSerialNumber", APIEvent::Type::IncorrectSerialNumber)
|
||||||
@@ -84,6 +87,10 @@ void init_event(pybind11::module_& m) {
|
|||||||
.value("LINSettingsNotAvailable", APIEvent::Type::LINSettingsNotAvailable)
|
.value("LINSettingsNotAvailable", APIEvent::Type::LINSettingsNotAvailable)
|
||||||
.value("ModeNotFound", APIEvent::Type::ModeNotFound)
|
.value("ModeNotFound", APIEvent::Type::ModeNotFound)
|
||||||
.value("AppErrorParsingFailed", APIEvent::Type::AppErrorParsingFailed)
|
.value("AppErrorParsingFailed", APIEvent::Type::AppErrorParsingFailed)
|
||||||
|
.value("GPTPNotSupported", APIEvent::Type::GPTPNotSupported)
|
||||||
|
.value("SettingNotAvaiableDevice", APIEvent::Type::SettingNotAvaiableDevice)
|
||||||
|
.value("DiskFormatNotSupported", APIEvent::Type::DiskFormatNotSupported)
|
||||||
|
.value("DiskFormatInvalidCount", APIEvent::Type::DiskFormatInvalidCount)
|
||||||
.value("FailedToRead", APIEvent::Type::FailedToRead)
|
.value("FailedToRead", APIEvent::Type::FailedToRead)
|
||||||
.value("FailedToWrite", APIEvent::Type::FailedToWrite)
|
.value("FailedToWrite", APIEvent::Type::FailedToWrite)
|
||||||
.value("DriverFailedToOpen", APIEvent::Type::DriverFailedToOpen)
|
.value("DriverFailedToOpen", APIEvent::Type::DriverFailedToOpen)
|
||||||
@@ -100,39 +107,6 @@ void init_event(pybind11::module_& m) {
|
|||||||
.value("GetIfAddrsError", APIEvent::Type::GetIfAddrsError)
|
.value("GetIfAddrsError", APIEvent::Type::GetIfAddrsError)
|
||||||
.value("SendToError", APIEvent::Type::SendToError)
|
.value("SendToError", APIEvent::Type::SendToError)
|
||||||
.value("MDIOMessageExceedsMaxLength", APIEvent::Type::MDIOMessageExceedsMaxLength)
|
.value("MDIOMessageExceedsMaxLength", APIEvent::Type::MDIOMessageExceedsMaxLength)
|
||||||
.value("FTOK", APIEvent::Type::FTOK)
|
|
||||||
.value("FTInvalidHandle", APIEvent::Type::FTInvalidHandle)
|
|
||||||
.value("FTDeviceNotFound", APIEvent::Type::FTDeviceNotFound)
|
|
||||||
.value("FTDeviceNotOpened", APIEvent::Type::FTDeviceNotOpened)
|
|
||||||
.value("FTIOError", APIEvent::Type::FTIOError)
|
|
||||||
.value("FTInsufficientResources", APIEvent::Type::FTInsufficientResources)
|
|
||||||
.value("FTInvalidParameter", APIEvent::Type::FTInvalidParameter)
|
|
||||||
.value("FTInvalidBaudRate", APIEvent::Type::FTInvalidBaudRate)
|
|
||||||
.value("FTDeviceNotOpenedForErase", APIEvent::Type::FTDeviceNotOpenedForErase)
|
|
||||||
.value("FTDeviceNotOpenedForWrite", APIEvent::Type::FTDeviceNotOpenedForWrite)
|
|
||||||
.value("FTFailedToWriteDevice", APIEvent::Type::FTFailedToWriteDevice)
|
|
||||||
.value("FTEEPROMReadFailed", APIEvent::Type::FTEEPROMReadFailed)
|
|
||||||
.value("FTEEPROMWriteFailed", APIEvent::Type::FTEEPROMWriteFailed)
|
|
||||||
.value("FTEEPROMEraseFailed", APIEvent::Type::FTEEPROMEraseFailed)
|
|
||||||
.value("FTEEPROMNotPresent", APIEvent::Type::FTEEPROMNotPresent)
|
|
||||||
.value("FTEEPROMNotProgrammed", APIEvent::Type::FTEEPROMNotProgrammed)
|
|
||||||
.value("FTInvalidArgs", APIEvent::Type::FTInvalidArgs)
|
|
||||||
.value("FTNotSupported", APIEvent::Type::FTNotSupported)
|
|
||||||
.value("FTNoMoreItems", APIEvent::Type::FTNoMoreItems)
|
|
||||||
.value("FTTimeout", APIEvent::Type::FTTimeout)
|
|
||||||
.value("FTOperationAborted", APIEvent::Type::FTOperationAborted)
|
|
||||||
.value("FTReservedPipe", APIEvent::Type::FTReservedPipe)
|
|
||||||
.value("FTInvalidControlRequestDirection", APIEvent::Type::FTInvalidControlRequestDirection)
|
|
||||||
.value("FTInvalidControlRequestType", APIEvent::Type::FTInvalidControlRequestType)
|
|
||||||
.value("FTIOPending", APIEvent::Type::FTIOPending)
|
|
||||||
.value("FTIOIncomplete", APIEvent::Type::FTIOIncomplete)
|
|
||||||
.value("FTHandleEOF", APIEvent::Type::FTHandleEOF)
|
|
||||||
.value("FTBusy", APIEvent::Type::FTBusy)
|
|
||||||
.value("FTNoSystemResources", APIEvent::Type::FTNoSystemResources)
|
|
||||||
.value("FTDeviceListNotReady", APIEvent::Type::FTDeviceListNotReady)
|
|
||||||
.value("FTDeviceNotConnected", APIEvent::Type::FTDeviceNotConnected)
|
|
||||||
.value("FTIncorrectDevicePath", APIEvent::Type::FTIncorrectDevicePath)
|
|
||||||
.value("FTOtherError", APIEvent::Type::FTOtherError)
|
|
||||||
.value("VSABufferCorrupted", APIEvent::Type::VSABufferCorrupted)
|
.value("VSABufferCorrupted", APIEvent::Type::VSABufferCorrupted)
|
||||||
.value("VSATimestampNotFound", APIEvent::Type::VSATimestampNotFound)
|
.value("VSATimestampNotFound", APIEvent::Type::VSATimestampNotFound)
|
||||||
.value("VSABufferFormatError", APIEvent::Type::VSABufferFormatError)
|
.value("VSABufferFormatError", APIEvent::Type::VSABufferFormatError)
|
||||||
@@ -140,16 +114,32 @@ void init_event(pybind11::module_& m) {
|
|||||||
.value("VSAByteParseFailure", APIEvent::Type::VSAByteParseFailure)
|
.value("VSAByteParseFailure", APIEvent::Type::VSAByteParseFailure)
|
||||||
.value("VSAExtendedMessageError", APIEvent::Type::VSAExtendedMessageError)
|
.value("VSAExtendedMessageError", APIEvent::Type::VSAExtendedMessageError)
|
||||||
.value("VSAOtherError", APIEvent::Type::VSAOtherError)
|
.value("VSAOtherError", APIEvent::Type::VSAOtherError)
|
||||||
|
.value("ServdBindError", APIEvent::Type::ServdBindError)
|
||||||
|
.value("ServdNonblockError", APIEvent::Type::ServdNonblockError)
|
||||||
|
.value("ServdTransceiveError", APIEvent::Type::ServdTransceiveError)
|
||||||
|
.value("ServdOutdatedError", APIEvent::Type::ServdOutdatedError)
|
||||||
|
.value("ServdInvalidResponseError", APIEvent::Type::ServdInvalidResponseError)
|
||||||
|
.value("ServdLockError", APIEvent::Type::ServdLockError)
|
||||||
|
.value("ServdSendError", APIEvent::Type::ServdSendError)
|
||||||
|
.value("ServdRecvError", APIEvent::Type::ServdRecvError)
|
||||||
|
.value("ServdPollError", APIEvent::Type::ServdPollError)
|
||||||
|
.value("ServdNoDataError", APIEvent::Type::ServdNoDataError)
|
||||||
|
.value("ServdJoinMulticastError", APIEvent::Type::ServdJoinMulticastError)
|
||||||
|
.value("DXXErrorSys", APIEvent::Type::DXXErrorSys)
|
||||||
|
.value("DXXErrorInt", APIEvent::Type::DXXErrorInt)
|
||||||
|
.value("DXXErrorOverflow", APIEvent::Type::DXXErrorOverflow)
|
||||||
|
.value("DXXErrorIO", APIEvent::Type::DXXErrorIO)
|
||||||
|
.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);
|
||||||
|
|
||||||
pybind11::enum_<APIEvent::Severity>(apiEvent, "Severity")
|
pybind11::enum_<APIEvent::Severity>(apiEvent, "Severity")
|
||||||
.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);
|
||||||
|
|
||||||
apiEvent
|
apiEvent
|
||||||
.def("get_type", &APIEvent::getType)
|
.def("get_type", &APIEvent::getType)
|
||||||
.def("get_severity", &APIEvent::getSeverity)
|
.def("get_severity", &APIEvent::getSeverity)
|
||||||
@@ -166,5 +156,5 @@ void init_event(pybind11::module_& m) {
|
|||||||
.def_readwrite("serial", &EventFilter::serial);
|
.def_readwrite("serial", &EventFilter::serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ void init_ethernetstatusmessage(pybind11::module_& m) {
|
|||||||
.value("LinkModeAuto", EthernetStatusMessage::LinkMode::LinkModeAuto)
|
.value("LinkModeAuto", EthernetStatusMessage::LinkMode::LinkModeAuto)
|
||||||
.value("LinkModeMaster", EthernetStatusMessage::LinkMode::LinkModeMaster)
|
.value("LinkModeMaster", EthernetStatusMessage::LinkMode::LinkModeMaster)
|
||||||
.value("LinkModeSlave", EthernetStatusMessage::LinkMode::LinkModeSlave)
|
.value("LinkModeSlave", EthernetStatusMessage::LinkMode::LinkModeSlave)
|
||||||
.value("LinkModeInvalid", EthernetStatusMessage::LinkMode::LinkModeInvalid);
|
.value("LinkModeInvalid", EthernetStatusMessage::LinkMode::LinkModeInvalid)
|
||||||
|
.value("LinkModeNone", EthernetStatusMessage::LinkMode::LinkModeNone);
|
||||||
|
|
||||||
ethernetStatusMessage
|
ethernetStatusMessage
|
||||||
.def_readonly("network", &EthernetStatusMessage::network)
|
.def_readonly("network", &EthernetStatusMessage::network)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/ethphymessage.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_ethphymessage(pybind11::module_& m) {
|
||||||
|
pybind11::class_<PhyMessage, std::shared_ptr<PhyMessage>>(m, "PhyMessage")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("Enabled", &PhyMessage::Enabled)
|
||||||
|
.def_readwrite("WriteEnable", &PhyMessage::WriteEnable)
|
||||||
|
.def_readwrite("Clause45Enable", &PhyMessage::Clause45Enable)
|
||||||
|
.def_readwrite("Version", &PhyMessage::Version)
|
||||||
|
.def_readwrite("BusIndex", &PhyMessage::BusIndex)
|
||||||
|
.def_readwrite("Clause22", &PhyMessage::Clause22)
|
||||||
|
.def_readwrite("Clause45", &PhyMessage::Clause45);
|
||||||
|
pybind11::class_<Clause22Message>(m, "Clause22Message")
|
||||||
|
.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_readwrite("messages", &EthPhyMessage::messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
#include <pybind11/pybind11.h>
|
|
||||||
#include <pybind11/stl.h>
|
|
||||||
#include <pybind11/functional.h>
|
|
||||||
|
|
||||||
#include "icsneo/communication/message/flexray/flexraymessage.h"
|
|
||||||
#include "icsneo/device/extensions/flexray/symbol.h"
|
|
||||||
#include "icsneo/device/extensions/flexray/channel.h"
|
|
||||||
#include "icsneo/device/extensions/flexray/crcstatus.h"
|
|
||||||
|
|
||||||
namespace icsneo {
|
|
||||||
|
|
||||||
struct FlexRayNamespace {
|
|
||||||
using Symbol = icsneo::FlexRay::Symbol;
|
|
||||||
using CRCStatus = icsneo::FlexRay::CRCStatus;
|
|
||||||
using Channel = icsneo::FlexRay::Channel;
|
|
||||||
};
|
|
||||||
|
|
||||||
void init_flexraymessage(pybind11::module_& m) {
|
|
||||||
// dummy class to hold the enums
|
|
||||||
pybind11::class_<FlexRayNamespace> flexray(m, "FlexRay");
|
|
||||||
// enumerations
|
|
||||||
pybind11::enum_<FlexRayNamespace::Symbol>(flexray, "Symbol")
|
|
||||||
.value("None", FlexRayNamespace::Symbol::None)
|
|
||||||
.value("Unknown", FlexRayNamespace::Symbol::Unknown)
|
|
||||||
.value("Wakeup", FlexRayNamespace::Symbol::Wakeup)
|
|
||||||
.value("CAS", FlexRayNamespace::Symbol::CAS);
|
|
||||||
pybind11::enum_<FlexRayNamespace::CRCStatus>(flexray, "CRCStatus")
|
|
||||||
.value("OK", FlexRayNamespace::CRCStatus::OK)
|
|
||||||
.value("Error", FlexRayNamespace::CRCStatus::Error)
|
|
||||||
.value("NoCRC", FlexRayNamespace::CRCStatus::NoCRC);
|
|
||||||
pybind11::enum_<FlexRayNamespace::Channel>(flexray, "Channel")
|
|
||||||
.value("None", FlexRayNamespace::Channel::None)
|
|
||||||
.value("A", FlexRayNamespace::Channel::A)
|
|
||||||
.value("B", FlexRayNamespace::Channel::B)
|
|
||||||
.value("AB", FlexRayNamespace::Channel::AB);
|
|
||||||
// read-only until transmit is supported
|
|
||||||
pybind11::class_<FlexRayMessage, std::shared_ptr<FlexRayMessage>, Frame>(m, "FlexRayMessage")
|
|
||||||
.def(pybind11::init())
|
|
||||||
.def_readonly("slotid", &FlexRayMessage::slotid)
|
|
||||||
.def_readonly("tsslen", &FlexRayMessage::tsslen)
|
|
||||||
.def_readonly("framelen", &FlexRayMessage::framelen)
|
|
||||||
.def_readonly("symbol", &FlexRayMessage::symbol)
|
|
||||||
.def_readonly("header_crc_status", &FlexRayMessage::headerCRCStatus)
|
|
||||||
.def_readonly("header_crc", &FlexRayMessage::headerCRC)
|
|
||||||
.def_readonly("frame_crc_status", &FlexRayMessage::crcStatus)
|
|
||||||
.def_readonly("frame_crc", &FlexRayMessage::frameCRC)
|
|
||||||
.def_readonly("channel", &FlexRayMessage::channel)
|
|
||||||
.def_readonly("null_frame", &FlexRayMessage::nullFrame)
|
|
||||||
.def_readonly("payload_preamble", &FlexRayMessage::payloadPreamble)
|
|
||||||
.def_readonly("sync_frame", &FlexRayMessage::sync)
|
|
||||||
.def_readonly("startup_frame", &FlexRayMessage::startup)
|
|
||||||
.def_readonly("dynamic_frame", &FlexRayMessage::dynamic)
|
|
||||||
.def_readonly("cycle", &FlexRayMessage::cycle);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace icsneo
|
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/spimessage.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_spimessage(pybind11::module_& m) {
|
||||||
|
pybind11::class_<SPIMessage, std::shared_ptr<SPIMessage>, Frame> spiMessage(m, "SPIMessage");
|
||||||
|
pybind11::enum_<SPIMessage::Direction>(spiMessage, "Direction")
|
||||||
|
.value("Write", SPIMessage::Direction::Write)
|
||||||
|
.value("Read", SPIMessage::Direction::Read);
|
||||||
|
spiMessage
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("direction", &SPIMessage::direction)
|
||||||
|
.def_readwrite("address", &SPIMessage::address)
|
||||||
|
.def_readwrite("mms", &SPIMessage::mms)
|
||||||
|
.def_readwrite("stats", &SPIMessage::stats)
|
||||||
|
.def_readwrite("payload", &SPIMessage::payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
@@ -123,6 +123,7 @@ void init_network(pybind11::module_& m) {
|
|||||||
.value("I2C_03", Network::NetID::I2C_03)
|
.value("I2C_03", Network::NetID::I2C_03)
|
||||||
.value("I2C_04", Network::NetID::I2C_04)
|
.value("I2C_04", Network::NetID::I2C_04)
|
||||||
.value("ETHERNET_02", Network::NetID::ETHERNET_02)
|
.value("ETHERNET_02", Network::NetID::ETHERNET_02)
|
||||||
|
.value("ETHERNET_TX_WRAP", Network::NetID::ETHERNET_TX_WRAP)
|
||||||
.value("A2B_01", Network::NetID::A2B_01)
|
.value("A2B_01", Network::NetID::A2B_01)
|
||||||
.value("A2B_02", Network::NetID::A2B_02)
|
.value("A2B_02", Network::NetID::A2B_02)
|
||||||
.value("ETHERNET_03", Network::NetID::ETHERNET_03)
|
.value("ETHERNET_03", Network::NetID::ETHERNET_03)
|
||||||
@@ -178,10 +179,11 @@ void init_network(pybind11::module_& m) {
|
|||||||
.value("LSFTCAN", Network::Type::LSFTCAN)
|
.value("LSFTCAN", Network::Type::LSFTCAN)
|
||||||
.value("SWCAN", Network::Type::SWCAN)
|
.value("SWCAN", Network::Type::SWCAN)
|
||||||
.value("ISO9141", Network::Type::ISO9141)
|
.value("ISO9141", Network::Type::ISO9141)
|
||||||
.value("I2C_01", Network::Type::I2C)
|
.value("I2C", Network::Type::I2C)
|
||||||
.value("A2B", Network::Type::A2B)
|
.value("A2B", Network::Type::A2B)
|
||||||
.value("SPI", Network::Type::SPI)
|
.value("SPI", Network::Type::SPI)
|
||||||
.value("MDIO", Network::Type::MDIO)
|
.value("MDIO", Network::Type::MDIO)
|
||||||
|
.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);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/device/chipid.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_chipid(pybind11::module_& m) {
|
||||||
|
pybind11::enum_<ChipID>(m, "ChipID")
|
||||||
|
.value("neoVIFIRE_MCHIP", ChipID::neoVIFIRE_MCHIP)
|
||||||
|
.value("neoVIFIRE_LCHIP", ChipID::neoVIFIRE_LCHIP)
|
||||||
|
.value("neoVIFIRE_UCHIP", ChipID::neoVIFIRE_UCHIP)
|
||||||
|
.value("neoVIFIRE_JCHIP", ChipID::neoVIFIRE_JCHIP)
|
||||||
|
.value("ValueCAN3_MCHIP", ChipID::ValueCAN3_MCHIP)
|
||||||
|
.value("neoVIECU_MPIC", ChipID::neoVIECU_MPIC)
|
||||||
|
.value("neoVIIEVB_MPIC", ChipID::neoVIIEVB_MPIC)
|
||||||
|
.value("neoVIPENDANT_MPIC", ChipID::neoVIPENDANT_MPIC)
|
||||||
|
.value("neoVIFIRE_VNET_MCHIP", ChipID::neoVIFIRE_VNET_MCHIP)
|
||||||
|
.value("neoVIFIRE_VNET_LCHIP", ChipID::neoVIFIRE_VNET_LCHIP)
|
||||||
|
.value("neoVIPLASMA_Core", ChipID::neoVIPLASMA_Core)
|
||||||
|
.value("neoVIPLASMA_HID", ChipID::neoVIPLASMA_HID)
|
||||||
|
.value("neoVIANALOG_MPIC", ChipID::neoVIANALOG_MPIC)
|
||||||
|
.value("neoVIPLASMA_ANALOG_Core", ChipID::neoVIPLASMA_ANALOG_Core)
|
||||||
|
.value("neoVIPLASMA_FlexRay_Core", ChipID::neoVIPLASMA_FlexRay_Core)
|
||||||
|
.value("neoVIPLASMA_Core_1_12", ChipID::neoVIPLASMA_Core_1_12)
|
||||||
|
.value("neoVIFIRE_Slave_VNET_MCHIP", ChipID::neoVIFIRE_Slave_VNET_MCHIP)
|
||||||
|
.value("neoVIFIRE_Slave_VNET_LCHIP", ChipID::neoVIFIRE_Slave_VNET_LCHIP)
|
||||||
|
.value("neoVIION_Core", ChipID::neoVIION_Core)
|
||||||
|
.value("neoVIION_HID", ChipID::neoVIION_HID)
|
||||||
|
.value("neoVIION_Core_Loader", ChipID::neoVIION_Core_Loader)
|
||||||
|
.value("neoVIION_HID_Loader", ChipID::neoVIION_HID_Loader)
|
||||||
|
.value("neoVIION_FPGA_BIT", ChipID::neoVIION_FPGA_BIT)
|
||||||
|
.value("neoVIFIRE_VNET_EP_MCHIP", ChipID::neoVIFIRE_VNET_EP_MCHIP)
|
||||||
|
.value("neoVIFIRE_VNET_EP_LCHIP", ChipID::neoVIFIRE_VNET_EP_LCHIP)
|
||||||
|
.value("neoVIAnalogOut_MCHIP", ChipID::neoVIAnalogOut_MCHIP)
|
||||||
|
.value("neoVIMOST25_MCHIP", ChipID::neoVIMOST25_MCHIP)
|
||||||
|
.value("neoVIMOST50_MCHIP", ChipID::neoVIMOST50_MCHIP)
|
||||||
|
.value("neoVIMOST150_MCHIP", ChipID::neoVIMOST150_MCHIP)
|
||||||
|
.value("ValueCAN4_4_MCHIP", ChipID::ValueCAN4_4_MCHIP)
|
||||||
|
.value("ValueCAN4_4_SCHIP", ChipID::ValueCAN4_4_SCHIP)
|
||||||
|
.value("cmProbe_ZYNQ", ChipID::cmProbe_ZYNQ)
|
||||||
|
.value("EEVB_STM32", ChipID::EEVB_STM32)
|
||||||
|
.value("neoVIFIRE_Slave_VNET_EP_MCHIP", ChipID::neoVIFIRE_Slave_VNET_EP_MCHIP)
|
||||||
|
.value("neoVIFIRE_Slave_VNET_EP_LCHIP", ChipID::neoVIFIRE_Slave_VNET_EP_LCHIP)
|
||||||
|
.value("RADStar_MCHIP", ChipID::RADStar_MCHIP)
|
||||||
|
.value("ValueCANrf_MCHIP", ChipID::ValueCANrf_MCHIP)
|
||||||
|
.value("neoVIFIRE2_MCHIP", ChipID::neoVIFIRE2_MCHIP)
|
||||||
|
.value("neoVIFIRE2_CCHIP", ChipID::neoVIFIRE2_CCHIP)
|
||||||
|
.value("neoVIFIRE2_Core", ChipID::neoVIFIRE2_Core)
|
||||||
|
.value("neoVIFIRE2_BLECHIP", ChipID::neoVIFIRE2_BLECHIP)
|
||||||
|
.value("neoVIFIRE2_ZYNQ", ChipID::neoVIFIRE2_ZYNQ)
|
||||||
|
.value("neoVIFIRE2_SECURITYCHIP", ChipID::neoVIFIRE2_SECURITYCHIP)
|
||||||
|
.value("RADGalaxy_ZYNQ", ChipID::RADGalaxy_ZYNQ)
|
||||||
|
.value("neoVIFIRE2_VNET_MCHIP", ChipID::neoVIFIRE2_VNET_MCHIP)
|
||||||
|
.value("neoVIFIRE2_Slave_VNET_A_MCHIP", ChipID::neoVIFIRE2_Slave_VNET_A_MCHIP)
|
||||||
|
.value("neoVIFIRE2_Slave_VNET_A_CCHIP", ChipID::neoVIFIRE2_Slave_VNET_A_CCHIP)
|
||||||
|
.value("neoVIFIRE2_VNET_CCHIP", ChipID::neoVIFIRE2_VNET_CCHIP)
|
||||||
|
.value("neoVIFIRE2_VNET_Core", ChipID::neoVIFIRE2_VNET_Core)
|
||||||
|
.value("RADStar2_ZYNQ", ChipID::RADStar2_ZYNQ)
|
||||||
|
.value("VividCAN_MCHIP", ChipID::VividCAN_MCHIP)
|
||||||
|
.value("neoOBD2SIM_MCHIP", ChipID::neoOBD2SIM_MCHIP)
|
||||||
|
.value("neoVIFIRE2_VNETZ_MCHIP", ChipID::neoVIFIRE2_VNETZ_MCHIP)
|
||||||
|
.value("neoVIFIRE2_VNETZ_ZYNQ", ChipID::neoVIFIRE2_VNETZ_ZYNQ)
|
||||||
|
.value("neoVIFIRE2_Slave_VNETZ_A_MCHIP", ChipID::neoVIFIRE2_Slave_VNETZ_A_MCHIP)
|
||||||
|
.value("neoVIFIRE2_Slave_VNETZ_A_ZYNQ", ChipID::neoVIFIRE2_Slave_VNETZ_A_ZYNQ)
|
||||||
|
.value("VividCAN_EXT_FLASH", ChipID::VividCAN_EXT_FLASH)
|
||||||
|
.value("VividCAN_NRF52", ChipID::VividCAN_NRF52)
|
||||||
|
.value("cmProbe_ZYNQ_Unused", ChipID::cmProbe_ZYNQ_Unused)
|
||||||
|
.value("neoOBD2PRO_MCHIP", ChipID::neoOBD2PRO_MCHIP)
|
||||||
|
.value("ValueCAN4_1_MCHIP", ChipID::ValueCAN4_1_MCHIP)
|
||||||
|
.value("ValueCAN4_2_MCHIP", ChipID::ValueCAN4_2_MCHIP)
|
||||||
|
.value("ValueCAN4_4_2EL_Core", ChipID::ValueCAN4_4_2EL_Core)
|
||||||
|
.value("neoOBD2PRO_SCHIP", ChipID::neoOBD2PRO_SCHIP)
|
||||||
|
.value("ValueCAN4_2EL_MCHIP", ChipID::ValueCAN4_2EL_MCHIP)
|
||||||
|
.value("neoECUAVBTSN_MCHIP", ChipID::neoECUAVBTSN_MCHIP)
|
||||||
|
.value("neoOBD2PRO_Core", ChipID::neoOBD2PRO_Core)
|
||||||
|
.value("RADSupermoon_ZYNQ", ChipID::RADSupermoon_ZYNQ)
|
||||||
|
.value("RADMoon2_ZYNQ", ChipID::RADMoon2_ZYNQ)
|
||||||
|
.value("VividCANPRO_MCHIP", ChipID::VividCANPRO_MCHIP)
|
||||||
|
.value("VividCANPRO_EXT_FLASH", ChipID::VividCANPRO_EXT_FLASH)
|
||||||
|
.value("RADPluto_MCHIP", ChipID::RADPluto_MCHIP)
|
||||||
|
.value("RADMars_ZYNQ", ChipID::RADMars_ZYNQ)
|
||||||
|
.value("neoECU12_MCHIP", ChipID::neoECU12_MCHIP)
|
||||||
|
.value("RADIOCANHUB_MCHIP", ChipID::RADIOCANHUB_MCHIP)
|
||||||
|
.value("FlexRay_VNETZ_ZCHIP", ChipID::FlexRay_VNETZ_ZCHIP)
|
||||||
|
.value("neoOBD2_LCBADGE_MCHIP", ChipID::neoOBD2_LCBADGE_MCHIP)
|
||||||
|
.value("neoOBD2_LCBADGE_SCHIP", ChipID::neoOBD2_LCBADGE_SCHIP)
|
||||||
|
.value("RADMoonDuo_MCHIP", ChipID::RADMoonDuo_MCHIP)
|
||||||
|
.value("neoVIFIRE3_ZCHIP", ChipID::neoVIFIRE3_ZCHIP)
|
||||||
|
.value("FlexRay_VNETZ_FCHIP", ChipID::FlexRay_VNETZ_FCHIP)
|
||||||
|
.value("RADJupiter_MCHIP", ChipID::RADJupiter_MCHIP)
|
||||||
|
.value("ValueCAN4Industrial_MCHIP", ChipID::ValueCAN4Industrial_MCHIP)
|
||||||
|
.value("EtherBADGE_MCHIP", ChipID::EtherBADGE_MCHIP)
|
||||||
|
.value("RADMars_3_ZYNQ", ChipID::RADMars_3_ZYNQ)
|
||||||
|
.value("RADGigastar_USBZ_ZYNQ", ChipID::RADGigastar_USBZ_ZYNQ)
|
||||||
|
.value("RADGigastar_ZYNQ", ChipID::RADGigastar_ZYNQ)
|
||||||
|
.value("RAD4G_MCHIP", ChipID::RAD4G_MCHIP)
|
||||||
|
.value("neoVIFIRE3_SCHIP", ChipID::neoVIFIRE3_SCHIP)
|
||||||
|
.value("RADEpsilon_MCHIP", ChipID::RADEpsilon_MCHIP)
|
||||||
|
.value("RADA2B_ZCHIP", ChipID::RADA2B_ZCHIP)
|
||||||
|
.value("neoOBD2Dev_MCHIP", ChipID::neoOBD2Dev_MCHIP)
|
||||||
|
.value("neoOBD2Dev_SCHIP", ChipID::neoOBD2Dev_SCHIP)
|
||||||
|
.value("neoOBD2SIMDoIP_MCHIP", ChipID::neoOBD2SIMDoIP_MCHIP)
|
||||||
|
.value("SFPModule_MCHIP", ChipID::SFPModule_MCHIP)
|
||||||
|
.value("RADEpsilonT_MCHIP", ChipID::RADEpsilonT_MCHIP)
|
||||||
|
.value("RADEpsilonExpress_MCHIP", ChipID::RADEpsilonExpress_MCHIP)
|
||||||
|
.value("RADProxima_MCHIP", ChipID::RADProxima_MCHIP)
|
||||||
|
.value("NewDevice57_ZCHIP", ChipID::NewDevice57_ZCHIP)
|
||||||
|
.value("RAD_GALAXY_2_ZMPCHIP_ID", ChipID::RAD_GALAXY_2_ZMPCHIP_ID)
|
||||||
|
.value("NewDevice59_MCHIP", ChipID::NewDevice59_MCHIP)
|
||||||
|
.value("RADMoon2_Z7010_ZYNQ", ChipID::RADMoon2_Z7010_ZYNQ)
|
||||||
|
.value("neoVIFIRE2_CORE_SG4", ChipID::neoVIFIRE2_CORE_SG4)
|
||||||
|
.value("RADBMS_MCHIP", ChipID::RADBMS_MCHIP)
|
||||||
|
.value("RADMoon2_ZL_MCHIP", ChipID::RADMoon2_ZL_MCHIP)
|
||||||
|
.value("RADGigastar_USBZ_Z7010_ZYNQ", ChipID::RADGigastar_USBZ_Z7010_ZYNQ)
|
||||||
|
.value("neoVIFIRE3_LINUX", ChipID::neoVIFIRE3_LINUX)
|
||||||
|
.value("RADGigastar_USBZ_Z7007S_ZYNQ", ChipID::RADGigastar_USBZ_Z7007S_ZYNQ)
|
||||||
|
.value("VEM_01_8DW_ZCHIP", ChipID::VEM_01_8DW_ZCHIP)
|
||||||
|
.value("RADGalaxy_FFG_Zynq", ChipID::RADGalaxy_FFG_Zynq)
|
||||||
|
.value("RADMoon3_MCHIP", ChipID::RADMoon3_MCHIP)
|
||||||
|
.value("RADComet_ZYNQ", ChipID::RADComet_ZYNQ)
|
||||||
|
.value("VEM_02_FR_ZCHIP", ChipID::VEM_02_FR_ZCHIP)
|
||||||
|
.value("RADA2B_REVB_ZCHIP", ChipID::RADA2B_REVB_ZCHIP)
|
||||||
|
.value("RADGigastar_FFG_ZYNQ", ChipID::RADGigastar_FFG_ZYNQ)
|
||||||
|
.value("VEM_02_FR_FCHIP", ChipID::VEM_02_FR_FCHIP)
|
||||||
|
.value("Connect_ZCHIP", ChipID::Connect_ZCHIP)
|
||||||
|
.value("RADGALAXY2_SYSMON_CHIP", ChipID::RADGALAXY2_SYSMON_CHIP)
|
||||||
|
.value("RADCOMET3_ZCHIP", ChipID::RADCOMET3_ZCHIP)
|
||||||
|
.value("Connect_LINUX", ChipID::Connect_LINUX)
|
||||||
|
.value("RADGigastar2_ZYNQ", ChipID::RADGigastar2_ZYNQ)
|
||||||
|
.value("RADGemini_MCHIP", ChipID::RADGemini_MCHIP)
|
||||||
|
.value("Invalid", ChipID::Invalid);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <pybind11/chrono.h>
|
#include <pybind11/chrono.h>
|
||||||
|
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
|
#include "icsneo/device/extensions/deviceextension.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@@ -17,9 +18,11 @@ void init_device(pybind11::module_& m) {
|
|||||||
.def("close", &Device::close, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("close", &Device::close, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("describe", &Device::describe)
|
.def("describe", &Device::describe)
|
||||||
.def("disable_message_polling", &Device::disableMessagePolling, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("disable_message_polling", &Device::disableMessagePolling, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("enable_message_polling", &Device::enableMessagePolling, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("enable_message_polling", &Device::enableMessagePolling, pybind11::arg("filter") = std::nullopt, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_current_message_count", &Device::getCurrentMessageCount)
|
.def("get_current_message_count", &Device::getCurrentMessageCount)
|
||||||
.def("get_digital_io", &Device::getDigitalIO, pybind11::arg("type"), pybind11::arg("number"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_digital_io", &Device::getDigitalIO, pybind11::arg("type"), pybind11::arg("number"), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
|
.def("get_extension", static_cast<std::shared_ptr<DeviceExtension>(Device::*)(const std::string&) const>(&Device::getExtension)) // This has to be static_casted rather than overload_casted because DeviceExtension is forward declared in device.h
|
||||||
|
.def("get_flexray_controllers", &Device::getFlexRayControllers)
|
||||||
.def("get_gptp_status", &Device::getGPTPStatus, pybind11::arg("timeout") = std::chrono::milliseconds(100), pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_gptp_status", &Device::getGPTPStatus, pybind11::arg("timeout") = std::chrono::milliseconds(100), pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_messages", [](Device& device) { return device.getMessages(); }, pybind11::call_guard<pybind11::gil_scoped_release>())
|
.def("get_messages", [](Device& device) { return device.getMessages(); }, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def("get_polling_message_limit", &Device::getPollingMessageLimit)
|
.def("get_polling_message_limit", &Device::getPollingMessageLimit)
|
||||||
@@ -52,6 +55,8 @@ void init_device(pybind11::module_& m) {
|
|||||||
.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("get_chip_versions", &Device::getChipVersions, pybind11::arg("refreshComponents") = true, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||||
.def_readonly("settings", &Device::settings);
|
.def_readonly("settings", &Device::settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,11 @@ void init_devicetype(pybind11::module_& m) {
|
|||||||
.value("RADEpsilonXL", DeviceType::Enum::RADEpsilonXL)
|
.value("RADEpsilonXL", DeviceType::Enum::RADEpsilonXL)
|
||||||
.value("RADGalaxy2", DeviceType::Enum::RADGalaxy2)
|
.value("RADGalaxy2", DeviceType::Enum::RADGalaxy2)
|
||||||
.value("RADMoon3", DeviceType::Enum::RADMoon3)
|
.value("RADMoon3", DeviceType::Enum::RADMoon3)
|
||||||
|
.value("RADGemini", DeviceType::Enum::RADGemini)
|
||||||
.value("RADComet", DeviceType::Enum::RADComet)
|
.value("RADComet", DeviceType::Enum::RADComet)
|
||||||
.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_SENT", DeviceType::Enum::FIRE3_T1S_SENT)
|
||||||
.value("Connect", DeviceType::Enum::Connect)
|
.value("Connect", DeviceType::Enum::Connect)
|
||||||
.value("RADComet3", DeviceType::Enum::RADComet3)
|
.value("RADComet3", DeviceType::Enum::RADComet3)
|
||||||
.value("RADMoonT1S", DeviceType::Enum::RADMoonT1S)
|
.value("RADMoonT1S", DeviceType::Enum::RADMoonT1S)
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/device/extensions/deviceextension.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_deviceextension(pybind11::module_& m) {
|
||||||
|
pybind11::class_<DeviceExtension, std::shared_ptr<DeviceExtension>>(m, "DeviceExtension")
|
||||||
|
.def("get_name", &DeviceExtension::getName);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -40,7 +40,7 @@ void init_idevicesettings(pybind11::module_& m) {
|
|||||||
.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::arg("ignoreChecksum") = 0, pybind11::call_guard<pybind11::gil_scoped_release>());
|
.def("refresh", &IDeviceSettings::refresh, pybind11::call_guard<pybind11::gil_scoped_release>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/device/versionreport.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_versionreport(pybind11::module_& m) {
|
||||||
|
pybind11::class_<VersionReport>(m, "VersionReport")
|
||||||
|
.def_readonly("id", &VersionReport::id)
|
||||||
|
.def_readonly("name", &VersionReport::name)
|
||||||
|
.def_readonly("major", &VersionReport::major)
|
||||||
|
.def_readonly("minor", &VersionReport::minor)
|
||||||
|
.def_readonly("maintenance", &VersionReport::maintenance)
|
||||||
|
.def_readonly("build", &VersionReport::build);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/flexray/flexraymessage.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/symbol.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/channel.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/crcstatus.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/controller.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
struct FlexRayNamespace {
|
||||||
|
using Symbol = icsneo::FlexRay::Symbol;
|
||||||
|
using CRCStatus = icsneo::FlexRay::CRCStatus;
|
||||||
|
using Channel = icsneo::FlexRay::Channel;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace FlexRay {
|
||||||
|
|
||||||
|
struct ClusterNamespace {
|
||||||
|
using SpeedType = icsneo::FlexRay::Cluster::SpeedType;
|
||||||
|
using SPPType = icsneo::FlexRay::Cluster::SPPType;
|
||||||
|
};
|
||||||
|
|
||||||
|
void init_extension(pybind11::class_<FlexRayNamespace>& c) {
|
||||||
|
pybind11::class_<MessageBuffer, std::shared_ptr<MessageBuffer>>(c, "MessageBuffer")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("is_dynamic", &MessageBuffer::isDynamic)
|
||||||
|
.def_readwrite("is_sync", &MessageBuffer::isSync)
|
||||||
|
.def_readwrite("is_startup", &MessageBuffer::isStartup)
|
||||||
|
.def_readwrite("is_network_management_frame", &MessageBuffer::isNetworkManagementFrame)
|
||||||
|
.def_readwrite("is_transmit", &MessageBuffer::isTransmit)
|
||||||
|
.def_readwrite("frame_id", &MessageBuffer::frameID)
|
||||||
|
.def_readwrite("channel_a", &MessageBuffer::channelA)
|
||||||
|
.def_readwrite("channel_b", &MessageBuffer::channelB)
|
||||||
|
.def_readwrite("frame_length_bytes", &MessageBuffer::frameLengthBytes)
|
||||||
|
.def_readwrite("base_cycle", &MessageBuffer::baseCycle)
|
||||||
|
.def_readwrite("cycle_repetition", &MessageBuffer::cycleRepetition)
|
||||||
|
.def_readwrite("continuous_mode", &MessageBuffer::continuousMode);
|
||||||
|
|
||||||
|
auto controller = pybind11::class_<Controller, std::shared_ptr<Controller>>(c, "Controller")
|
||||||
|
.def("get_network", &Controller::getNetwork)
|
||||||
|
.def("get_configuration", &Controller::getConfiguration)
|
||||||
|
.def("set_configuration", &Controller::setConfiguration)
|
||||||
|
.def("get_start_when_going_online", &Controller::getStartWhenGoingOnline)
|
||||||
|
.def("set_start_when_going_online", &Controller::setStartWhenGoingOnline)
|
||||||
|
.def("get_allow_coldstart", &Controller::getAllowColdstart)
|
||||||
|
.def("set_allow_coldstart", &Controller::setAllowColdstart)
|
||||||
|
.def("get_wakeup_before_start", &Controller::getWakeupBeforeStart)
|
||||||
|
.def("set_wakeup_before_start", &Controller::setWakeupBeforeStart)
|
||||||
|
.def("add_message_buffer", &Controller::addMessageBuffer)
|
||||||
|
.def("clear_message_buffers", &Controller::clearMessageBuffers)
|
||||||
|
.def("wakeup", &Controller::wakeup)
|
||||||
|
.def("configure", &Controller::getReady)
|
||||||
|
.def("start", &Controller::start)
|
||||||
|
.def("transmit", &Controller::transmit)
|
||||||
|
.def("halt", &Controller::halt)
|
||||||
|
.def("freeze", &Controller::freeze)
|
||||||
|
.def("trigger_mts", &Controller::triggerMTS);
|
||||||
|
|
||||||
|
pybind11::class_<Controller::Configuration>(controller, "Configuration")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("accept_startup_range_microticks", &Controller::Configuration::AcceptStartupRangeMicroticks)
|
||||||
|
.def_readwrite("allow_passive_to_active_cycle_pairs", &Controller::Configuration::AllowPassiveToActiveCyclePairs)
|
||||||
|
.def_readwrite("cluster_drift_damping", &Controller::Configuration::ClusterDriftDamping)
|
||||||
|
.def_readwrite("channel_a", &Controller::Configuration::ChannelA)
|
||||||
|
.def_readwrite("channel_b", &Controller::Configuration::ChannelB)
|
||||||
|
.def_readwrite("decoding_correction_microticks", &Controller::Configuration::DecodingCorrectionMicroticks)
|
||||||
|
.def_readwrite("delay_compensation_a_microticks", &Controller::Configuration::DelayCompensationAMicroticks)
|
||||||
|
.def_readwrite("delay_compensation_b_microticks", &Controller::Configuration::DelayCompensationBMicroticks)
|
||||||
|
.def_readwrite("extern_offset_correction_control", &Controller::Configuration::ExternOffsetCorrectionControl)
|
||||||
|
.def_readwrite("extern_rate_correction_control", &Controller::Configuration::ExternRateCorrectionControl)
|
||||||
|
.def_readwrite("extern_offset_correction_microticks", &Controller::Configuration::ExternOffsetCorrectionMicroticks)
|
||||||
|
.def_readwrite("extern_rate_correction_microticks", &Controller::Configuration::ExternRateCorrectionMicroticks)
|
||||||
|
.def_readwrite("key_slot_id", &Controller::Configuration::KeySlotID)
|
||||||
|
.def_readwrite("key_slot_used_for_startup", &Controller::Configuration::KeySlotUsedForStartup)
|
||||||
|
.def_readwrite("key_slot_used_for_sync", &Controller::Configuration::KeySlotUsedForSync)
|
||||||
|
.def_readwrite("latest_tx_minislot", &Controller::Configuration::LatestTxMinislot)
|
||||||
|
.def_readwrite("listen_timeout", &Controller::Configuration::ListenTimeout)
|
||||||
|
.def_readwrite("macro_initial_offset_a", &Controller::Configuration::MacroInitialOffsetA)
|
||||||
|
.def_readwrite("macro_initial_offset_b", &Controller::Configuration::MacroInitialOffsetB)
|
||||||
|
.def_readwrite("micro_initial_offset_a", &Controller::Configuration::MicroInitialOffsetA)
|
||||||
|
.def_readwrite("micro_initial_offset_b", &Controller::Configuration::MicroInitialOffsetB)
|
||||||
|
.def_readwrite("micro_per_cycle", &Controller::Configuration::MicroPerCycle)
|
||||||
|
.def_readwrite("mts_on_a", &Controller::Configuration::MTSOnA)
|
||||||
|
.def_readwrite("mts_on_b", &Controller::Configuration::MTSOnB)
|
||||||
|
.def_readwrite("offset_correction_out_microticks", &Controller::Configuration::OffsetCorrectionOutMicroticks)
|
||||||
|
.def_readwrite("rate_correction_out_microticks", &Controller::Configuration::RateCorrectionOutMicroticks)
|
||||||
|
.def_readwrite("second_key_slot_id", &Controller::Configuration::SecondKeySlotID)
|
||||||
|
.def_readwrite("two_key_slot_mode", &Controller::Configuration::TwoKeySlotMode)
|
||||||
|
.def_readwrite("wakeup_pattern", &Controller::Configuration::WakeupPattern)
|
||||||
|
.def_readwrite("wakeup_on_channel_b", &Controller::Configuration::WakeupOnChannelB);
|
||||||
|
|
||||||
|
// Dummy class for cluster namespace
|
||||||
|
pybind11::class_<ClusterNamespace> cluster(c, "Cluster");
|
||||||
|
|
||||||
|
pybind11::enum_<Cluster::SpeedType>(cluster, "SpeedType")
|
||||||
|
.value("FLEXRAY_BAUDRATE_10M", Cluster::SpeedType::FLEXRAY_BAUDRATE_10M)
|
||||||
|
.value("FLEXRAY_BAUDRATE_5M", Cluster::SpeedType::FLEXRAY_BAUDRATE_5M)
|
||||||
|
.value("FLEXRAY_BAUDRATE_2M5", Cluster::SpeedType::FLEXRAY_BAUDRATE_2M5)
|
||||||
|
.value("FLEXRAY_BAUDRATE_2M5_ALT", Cluster::SpeedType::FLEXRAY_BAUDRATE_2M5_ALT);
|
||||||
|
|
||||||
|
pybind11::enum_<Cluster::SPPType>(cluster, "SPPType")
|
||||||
|
.value("FLEXRAY_SPP_5", Cluster::SPPType::FLEXRAY_SPP_5)
|
||||||
|
.value("FLEXRAY_SPP_4", Cluster::SPPType::FLEXRAY_SPP_4)
|
||||||
|
.value("FLEXRAY_SPP_6", Cluster::SPPType::FLEXRAY_SPP_6)
|
||||||
|
.value("FLEXRAY_SPP_5_ALT", Cluster::SPPType::FLEXRAY_SPP_5_ALT);
|
||||||
|
|
||||||
|
pybind11::class_<Cluster::Configuration>(cluster, "Configuration")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("speed", &Cluster::Configuration::Speed)
|
||||||
|
.def_readwrite("strobe_point_position", &Cluster::Configuration::StrobePointPosition)
|
||||||
|
.def_readwrite("action_point_offset", &Cluster::Configuration::ActionPointOffset)
|
||||||
|
.def_readwrite("casr_x_low_max", &Cluster::Configuration::CASRxLowMax)
|
||||||
|
.def_readwrite("cold_start_attempts", &Cluster::Configuration::ColdStartAttempts)
|
||||||
|
.def_readwrite("dynamic_slot_idle_phase_minislots", &Cluster::Configuration::DynamicSlotIdlePhaseMinislots)
|
||||||
|
.def_readwrite("listen_noise_macroticks", &Cluster::Configuration::ListenNoiseMacroticks)
|
||||||
|
.def_readwrite("macroticks_per_cycle", &Cluster::Configuration::MacroticksPerCycle)
|
||||||
|
.def_readwrite("macrotick_duration_micro_sec", &Cluster::Configuration::MacrotickDurationMicroSec)
|
||||||
|
.def_readwrite("max_without_clock_correction_fatal", &Cluster::Configuration::MaxWithoutClockCorrectionFatal)
|
||||||
|
.def_readwrite("max_without_clock_correction_passive", &Cluster::Configuration::MaxWithoutClockCorrectionPassive)
|
||||||
|
.def_readwrite("minislot_action_point_offset_macroticks", &Cluster::Configuration::MinislotActionPointOffsetMacroticks)
|
||||||
|
.def_readwrite("minislot_duration_macroticks", &Cluster::Configuration::MinislotDurationMacroticks)
|
||||||
|
.def_readwrite("network_idle_time_macroticks", &Cluster::Configuration::NetworkIdleTimeMacroticks)
|
||||||
|
.def_readwrite("network_management_vector_length_bytes", &Cluster::Configuration::NetworkManagementVectorLengthBytes)
|
||||||
|
.def_readwrite("number_of_minislots", &Cluster::Configuration::NumberOfMinislots)
|
||||||
|
.def_readwrite("number_of_static_slots", &Cluster::Configuration::NumberOfStaticSlots)
|
||||||
|
.def_readwrite("offset_correction_start_macroticks", &Cluster::Configuration::OffsetCorrectionStartMacroticks)
|
||||||
|
.def_readwrite("payload_length_of_static_slot_in_words", &Cluster::Configuration::PayloadLengthOfStaticSlotInWords)
|
||||||
|
.def_readwrite("static_slot_macroticks", &Cluster::Configuration::StaticSlotMacroticks)
|
||||||
|
.def_readwrite("symbol_window_macroticks", &Cluster::Configuration::SymbolWindowMacroticks)
|
||||||
|
.def_readwrite("symbol_window_action_point_offset_macroticks", &Cluster::Configuration::SymbolWindowActionPointOffsetMacroticks)
|
||||||
|
.def_readwrite("sync_frame_id_count_max", &Cluster::Configuration::SyncFrameIDCountMax)
|
||||||
|
.def_readwrite("transmission_start_sequence_duration_bits", &Cluster::Configuration::TransmissionStartSequenceDurationBits)
|
||||||
|
.def_readwrite("wakeup_rx_idle_bits", &Cluster::Configuration::WakeupRxIdleBits)
|
||||||
|
.def_readwrite("wakeup_rx_low_bits", &Cluster::Configuration::WakeupRxLowBits)
|
||||||
|
.def_readwrite("wakeup_rx_window_bits", &Cluster::Configuration::WakeupRxWindowBits)
|
||||||
|
.def_readwrite("wakeup_tx_active_bits", &Cluster::Configuration::WakeupTxActiveBits)
|
||||||
|
.def_readwrite("wakeup_tx_idle_bits", &Cluster::Configuration::WakeupTxIdleBits);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace FlexRay
|
||||||
|
|
||||||
|
void init_flexraymessage(pybind11::module_& m) {
|
||||||
|
pybind11::class_<FlexRayMessage, std::shared_ptr<FlexRayMessage>, Frame>(m, "FlexRayMessage")
|
||||||
|
.def(pybind11::init())
|
||||||
|
.def_readwrite("slotid", &FlexRayMessage::slotid)
|
||||||
|
.def_readwrite("tsslen", &FlexRayMessage::tsslen)
|
||||||
|
.def_readwrite("framelen", &FlexRayMessage::framelen)
|
||||||
|
.def_readwrite("symbol", &FlexRayMessage::symbol)
|
||||||
|
.def_readwrite("header_crc_status", &FlexRayMessage::headerCRCStatus)
|
||||||
|
.def_readwrite("header_crc", &FlexRayMessage::headerCRC)
|
||||||
|
.def_readwrite("frame_crc_status", &FlexRayMessage::crcStatus)
|
||||||
|
.def_readwrite("frame_crc", &FlexRayMessage::frameCRC)
|
||||||
|
.def_readwrite("channel", &FlexRayMessage::channel)
|
||||||
|
.def_readwrite("null_frame", &FlexRayMessage::nullFrame)
|
||||||
|
.def_readwrite("payload_preamble", &FlexRayMessage::payloadPreamble)
|
||||||
|
.def_readwrite("sync_frame", &FlexRayMessage::sync)
|
||||||
|
.def_readwrite("startup_frame", &FlexRayMessage::startup)
|
||||||
|
.def_readwrite("dynamic_frame", &FlexRayMessage::dynamic)
|
||||||
|
.def_readwrite("cycle", &FlexRayMessage::cycle);
|
||||||
|
|
||||||
|
//// TODO: Eliminate FlexRayControlMessage class references in controller class and eliminate getStatus function in bindings
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_flexray(pybind11::module_& m) {
|
||||||
|
// Dummy class to act as FlexRay namespace
|
||||||
|
pybind11::class_<FlexRayNamespace> flexray(m, "FlexRay");
|
||||||
|
|
||||||
|
pybind11::enum_<FlexRayNamespace::Symbol>(flexray, "Symbol")
|
||||||
|
.value("None", FlexRayNamespace::Symbol::None)
|
||||||
|
.value("Unknown", FlexRayNamespace::Symbol::Unknown)
|
||||||
|
.value("Wakeup", FlexRayNamespace::Symbol::Wakeup)
|
||||||
|
.value("CAS", FlexRayNamespace::Symbol::CAS);
|
||||||
|
pybind11::enum_<FlexRayNamespace::CRCStatus>(flexray, "CRCStatus")
|
||||||
|
.value("OK", FlexRayNamespace::CRCStatus::OK)
|
||||||
|
.value("Error", FlexRayNamespace::CRCStatus::Error)
|
||||||
|
.value("NoCRC", FlexRayNamespace::CRCStatus::NoCRC);
|
||||||
|
pybind11::enum_<FlexRayNamespace::Channel>(flexray, "Channel")
|
||||||
|
.value("None", FlexRayNamespace::Channel::None)
|
||||||
|
.value("A", FlexRayNamespace::Channel::A)
|
||||||
|
.value("B", FlexRayNamespace::Channel::B)
|
||||||
|
.value("AB", FlexRayNamespace::Channel::AB);
|
||||||
|
|
||||||
|
init_flexraymessage(m);
|
||||||
|
FlexRay::init_extension(flexray);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
@@ -20,16 +20,21 @@ 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_mdiomessage(pybind11::module_&);
|
void init_mdiomessage(pybind11::module_&);
|
||||||
|
void init_spimessage(pybind11::module_&);
|
||||||
void init_ethernetstatusmessage(pybind11::module_&);
|
void init_ethernetstatusmessage(pybind11::module_&);
|
||||||
void init_macsecmessage(pybind11::module_&);
|
void init_macsecmessage(pybind11::module_&);
|
||||||
void init_scriptstatusmessage(pybind11::module_&);
|
void init_scriptstatusmessage(pybind11::module_&);
|
||||||
void init_diskdriver(pybind11::module_&);
|
void init_diskdriver(pybind11::module_&);
|
||||||
|
void init_deviceextension(pybind11::module_&);
|
||||||
|
void init_chipid(pybind11::module_&);
|
||||||
|
void init_versionreport(pybind11::module_&);
|
||||||
void init_device(pybind11::module_&);
|
void init_device(pybind11::module_&);
|
||||||
void init_messagefilter(pybind11::module_&);
|
void init_messagefilter(pybind11::module_&);
|
||||||
void init_messagecallback(pybind11::module_&);
|
void init_messagecallback(pybind11::module_&);
|
||||||
void init_version(pybind11::module_&);
|
void init_version(pybind11::module_&);
|
||||||
void init_flexraymessage(pybind11::module_& m);
|
void init_flexray(pybind11::module_& m);
|
||||||
void init_idevicesettings(pybind11::module_&);
|
void init_idevicesettings(pybind11::module_&);
|
||||||
|
void init_ethphymessage(pybind11::module_&);
|
||||||
|
|
||||||
PYBIND11_MODULE(icsneopy, m) {
|
PYBIND11_MODULE(icsneopy, m) {
|
||||||
pybind11::options options;
|
pybind11::options options;
|
||||||
@@ -54,11 +59,16 @@ PYBIND11_MODULE(icsneopy, m) {
|
|||||||
init_ethernetstatusmessage(m);
|
init_ethernetstatusmessage(m);
|
||||||
init_macsecmessage(m);
|
init_macsecmessage(m);
|
||||||
init_scriptstatusmessage(m);
|
init_scriptstatusmessage(m);
|
||||||
|
init_spimessage(m);
|
||||||
init_messagefilter(m);
|
init_messagefilter(m);
|
||||||
init_messagecallback(m);
|
init_messagecallback(m);
|
||||||
init_diskdriver(m);
|
init_diskdriver(m);
|
||||||
|
init_flexray(m);
|
||||||
|
init_ethphymessage(m);
|
||||||
|
init_chipid(m);
|
||||||
|
init_versionreport(m);
|
||||||
init_device(m);
|
init_device(m);
|
||||||
init_flexraymessage(m);
|
init_deviceextension(m);
|
||||||
init_idevicesettings(m);
|
init_idevicesettings(m);
|
||||||
|
|
||||||
m.def("find_all_devices", &FindAllDevices);
|
m.def("find_all_devices", &FindAllDevices);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
yum install -y flex ca-certificates || exit 1
|
||||||
|
|
||||||
|
echo "$ICS_IPA_CA_CRT" >/etc/pki/ca-trust/source/anchors/ica-ipa-ca.crt
|
||||||
|
|
||||||
|
update-ca-trust || exit 1
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
VERSION="1.0.27"
|
|
||||||
ROOT="$PWD/libusb"
|
|
||||||
SOURCE="$ROOT/source"
|
|
||||||
BUILD="$ROOT/build"
|
|
||||||
INSTALL="$ROOT/install"
|
|
||||||
|
|
||||||
mkdir -p "$ROOT"
|
|
||||||
cd "$ROOT" || exit 1
|
|
||||||
|
|
||||||
curl -LO "https://github.com/libusb/libusb/releases/download/v$VERSION/libusb-$VERSION.tar.bz2" || exit 1
|
|
||||||
tar -xf "libusb-$VERSION.tar.bz2" || exit 1
|
|
||||||
mv "libusb-$VERSION" "$SOURCE" || exit 1
|
|
||||||
|
|
||||||
mkdir "$BUILD" || exit 1
|
|
||||||
cd "$BUILD" || exit 1
|
|
||||||
"$SOURCE/configure" --prefix="$INSTALL" --disable-shared --disable-udev --disable-eventfd --disable-timerfd --with-pic || exit 1
|
|
||||||
make || exit 1
|
|
||||||
make install || exit 1
|
|
||||||
|
|
||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
export CFLAGS="-Wall -Werror"
|
|
||||||
export CXXFLAGS="-Wall -Werror"
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
+8
-11
@@ -1,12 +1,9 @@
|
|||||||
REM clean intermediate directories
|
@setlocal
|
||||||
rmdir /s /q build
|
@echo off
|
||||||
mkdir build
|
|
||||||
|
|
||||||
REM build
|
mkdir build >nul 2>&1
|
||||||
cd build
|
|
||||||
set CFLAGS=/WX /W4 /wd4127
|
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DLIBICSNEO_BUILD_UNIT_TESTS=ON ^
|
||||||
set CXXFLAGS=/WX /W4 /wd4127
|
-DLIBICSNEO_ENABLE_TCP=ON || exit /b 1
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBICSNEO_BUILD_UNIT_TESTS=ON -DLIBICSNEO_ENABLE_TCP=ON ..
|
|
||||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
cmake --build build || exit /b 1
|
||||||
cmake --build .
|
|
||||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
find_path(FTD3XX_INCLUDE_DIR
|
|
||||||
NAMES ftd3xx.h FTD3XX.h
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(FTD3XX_LIBRARY
|
|
||||||
NAMES libftd3xx.a libftd3xx-static.a FTD3XX.lib
|
|
||||||
PATH_SUFFIXES x64/Static
|
|
||||||
)
|
|
||||||
|
|
||||||
mark_as_advanced(FTD3XX_FOUND FTD3XX_INCLUDE_DIR FTD3XX_LIBRARY)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(FTD3XX
|
|
||||||
REQUIRED_VARS FTD3XX_INCLUDE_DIR FTD3XX_LIBRARY
|
|
||||||
)
|
|
||||||
if(FTD3XX_FOUND AND NOT TARGET D3XX::D3XX)
|
|
||||||
add_library(FTD3XX::FTD3XX INTERFACE IMPORTED)
|
|
||||||
set_target_properties(FTD3XX::FTD3XX PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${FTD3XX_INCLUDE_DIR}"
|
|
||||||
INTERFACE_LINK_LIBRARIES "${FTD3XX_LIBRARY}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
@@ -14,6 +14,12 @@
|
|||||||
#include "icsneo/communication/message/readsettingsmessage.h"
|
#include "icsneo/communication/message/readsettingsmessage.h"
|
||||||
#include "icsneo/communication/message/versionmessage.h"
|
#include "icsneo/communication/message/versionmessage.h"
|
||||||
#include "icsneo/communication/message/componentversionsmessage.h"
|
#include "icsneo/communication/message/componentversionsmessage.h"
|
||||||
|
#include "icsneo/communication/message/filter/extendedresponsefilter.h"
|
||||||
|
#include "icsneo/communication/message/clientidmessage.h"
|
||||||
|
#include "icsneo/communication/icspb.h"
|
||||||
|
|
||||||
|
#include <commands/generic/v1/client_id.pb.h>
|
||||||
|
#include <commands/network/v1/mutex.pb.h>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
@@ -313,3 +319,32 @@ std::optional< std::vector<ComponentVersion> > Communication::getComponentVersio
|
|||||||
|
|
||||||
return std::make_optional< std::vector<ComponentVersion> >(std::move(ver->versions));
|
return std::make_optional< std::vector<ComponentVersion> >(std::move(ver->versions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<uint32_t> Communication::getClientIDSync() {
|
||||||
|
constexpr auto timeout = std::chrono::milliseconds(250);
|
||||||
|
commands::generic::v1::ClientId msg;
|
||||||
|
msg.Clear();
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = protoapi::getPayload(protoapi::Command::GET, msg);
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = waitForMessageSync(
|
||||||
|
[this, payload](){
|
||||||
|
return sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::ClientId),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto clientIdMessage = std::dynamic_pointer_cast<ClientIdMessage>(response);
|
||||||
|
if(!clientIdMessage) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientIdMessage->clientId;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "icsneo/communication/message/gptpstatusmessage.h"
|
#include "icsneo/communication/message/gptpstatusmessage.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/clientidmessage.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"
|
||||||
@@ -43,6 +45,9 @@
|
|||||||
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
||||||
#include "icsneo/communication/packet/livedatapacket.h"
|
#include "icsneo/communication/packet/livedatapacket.h"
|
||||||
#include "icsneo/communication/packet/hardwareinfopacket.h"
|
#include "icsneo/communication/packet/hardwareinfopacket.h"
|
||||||
|
#include "icsneo/communication/packet/spipacket.h"
|
||||||
|
#include "icsneo/communication/icspb.h"
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -57,8 +62,9 @@ uint64_t Decoder::GetUInt64FromLEBytes(const uint8_t* bytes) {
|
|||||||
|
|
||||||
bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet) {
|
bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet) {
|
||||||
switch(packet->network.getType()) {
|
switch(packet->network.getType()) {
|
||||||
case Network::Type::Ethernet: {
|
case Network::Type::Ethernet:
|
||||||
result = HardwareEthernetPacket::DecodeToMessage(packet->data, report);
|
case Network::Type::AutomotiveEthernet: {
|
||||||
|
result = HardwareEthernetPacket::DecodeToMessage(packet->data);
|
||||||
if(!result) {
|
if(!result) {
|
||||||
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
return false; // A nullptr was returned, the packet was not long enough to decode
|
return false; // A nullptr was returned, the packet was not long enough to decode
|
||||||
@@ -184,6 +190,19 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
msg.timestamp *= timestampResolution;
|
msg.timestamp *= timestampResolution;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case Network::Type::SPI: {
|
||||||
|
result = HardwareSPIPacket::DecodeToMessage(packet->data);
|
||||||
|
|
||||||
|
if(!result) {
|
||||||
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
|
return false; // A nullptr was returned, the packet was not long enough to decode
|
||||||
|
}
|
||||||
|
|
||||||
|
SPIMessage& msg = *static_cast<SPIMessage*>(result.get());
|
||||||
|
msg.network = packet->network;
|
||||||
|
msg.timestamp *= timestampResolution;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case Network::Type::MDIO: {
|
case Network::Type::MDIO: {
|
||||||
result = HardwareMDIOPacket::DecodeToMessage(packet->data);
|
result = HardwareMDIOPacket::DecodeToMessage(packet->data);
|
||||||
|
|
||||||
@@ -259,7 +278,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
result = can;
|
result = can;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->timestamp *= timestampResolution;
|
result->timestamp = can->timestamp * timestampResolution;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case Network::NetID::DeviceStatus: {
|
case Network::NetID::DeviceStatus: {
|
||||||
@@ -324,6 +343,36 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||||||
result = GPTPStatus::DecodeToMessage(packet->data, report);
|
result = GPTPStatus::DecodeToMessage(packet->data, report);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case ExtendedCommand::ProtobufAPI: {
|
||||||
|
// get the proto id
|
||||||
|
std::vector<uint8_t> responseBody(
|
||||||
|
packet->data.begin() + sizeof(ExtendedResponseMessage::ResponseHeader),
|
||||||
|
packet->data.end()
|
||||||
|
);
|
||||||
|
protoapi::Id protoId = protoapi::getProtoId(responseBody.data(), responseBody.size());
|
||||||
|
switch(protoId) {
|
||||||
|
case protoapi::Id::NetworkMutex:
|
||||||
|
result = NetworkMutexMessage::DecodeToMessage(responseBody);
|
||||||
|
return true;
|
||||||
|
case protoapi::Id::ClientId:
|
||||||
|
result = ClientIdMessage::DecodeToMessage(responseBody);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case ExtendedCommand::GetDiskDetails:
|
||||||
|
case ExtendedCommand::DiskFormatProgress: {
|
||||||
|
std::vector<uint8_t> responseBody(
|
||||||
|
packet->data.begin() + sizeof(ExtendedResponseMessage::ResponseHeader),
|
||||||
|
packet->data.end()
|
||||||
|
);
|
||||||
|
auto response = std::make_shared<ExtendedResponseMessage>(resp.command);
|
||||||
|
response->data = std::move(responseBody);
|
||||||
|
result = response;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// No defined handler, treat this as a RawMessage
|
// No defined handler, treat this as a RawMessage
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -38,18 +38,10 @@ bool Driver::waitForRx(std::function<bool()> predicate, std::chrono::millisecond
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Driver::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout, size_t limit) {
|
bool Driver::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout, size_t limit) {
|
||||||
// A limit of zero indicates no limit
|
// wait until we have enough data, or the timeout occurs
|
||||||
if(limit == 0)
|
|
||||||
limit = (size_t)-1;
|
|
||||||
|
|
||||||
if(limit > (readBuffer.size() + 4))
|
|
||||||
limit = (readBuffer.size() + 4);
|
|
||||||
|
|
||||||
|
|
||||||
// wait until we have enough data, or the timout occurs
|
|
||||||
waitForRx(limit, timeout);
|
waitForRx(limit, timeout);
|
||||||
|
|
||||||
size_t actuallyRead = std::min(readBuffer.size(), limit);
|
size_t actuallyRead = readBuffer.size();
|
||||||
bytes.resize(actuallyRead);
|
bytes.resize(actuallyRead);
|
||||||
|
|
||||||
readBuffer.read(bytes.data(), 0, actuallyRead);
|
readBuffer.read(bytes.data(), 0, actuallyRead);
|
||||||
@@ -79,8 +71,12 @@ bool Driver::write(const std::vector<uint8_t>& bytes) {
|
|||||||
|
|
||||||
if(writeBlocks) {
|
if(writeBlocks) {
|
||||||
if(writeQueueFull()) {
|
if(writeQueueFull()) {
|
||||||
while(writeQueueAlmostFull()) // Wait until we have some decent amount of space
|
while(writeQueueAlmostFull() && !isDisconnected() && !isClosing()) // Wait until we have some decent amount of space
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
|
||||||
|
if(isDisconnected() || isClosing()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(writeQueueFull()) {
|
if(writeQueueFull()) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "icsneo/communication/packet/a2bpacket.h"
|
#include "icsneo/communication/packet/a2bpacket.h"
|
||||||
#include "icsneo/communication/packet/linpacket.h"
|
#include "icsneo/communication/packet/linpacket.h"
|
||||||
#include "icsneo/communication/packet/mdiopacket.h"
|
#include "icsneo/communication/packet/mdiopacket.h"
|
||||||
|
#include "icsneo/communication/packet/spipacket.h"
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
@@ -31,19 +32,30 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
|||||||
netid = uint16_t(frame->network.getNetID());
|
netid = uint16_t(frame->network.getNetID());
|
||||||
|
|
||||||
switch(frame->network.getType()) {
|
switch(frame->network.getType()) {
|
||||||
case Network::Type::Ethernet: {
|
case Network::Type::Ethernet:
|
||||||
|
case Network::Type::AutomotiveEthernet: {
|
||||||
auto ethmsg = std::dynamic_pointer_cast<EthernetMessage>(message);
|
auto ethmsg = std::dynamic_pointer_cast<EthernetMessage>(message);
|
||||||
if(!ethmsg) {
|
if(!ethmsg) {
|
||||||
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
return false; // The message was not a properly formed EthernetMessage
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shortFormat = false; // Ensure long-format RED header is added
|
||||||
|
netid = static_cast<uint16_t>(Network::NetID::ETHERNET_TX_WRAP);
|
||||||
buffer = &result;
|
buffer = &result;
|
||||||
if(!HardwareEthernetPacket::EncodeFromMessage(*ethmsg, result, report))
|
|
||||||
|
if(!HardwareEthernetPacket::EncodeFromMessage(*ethmsg, result, report)) {
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result.empty()) {
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} // End of Network::Type::Ethernet
|
}
|
||||||
case Network::Type::CAN:
|
case Network::Type::CAN:
|
||||||
case Network::Type::SWCAN:
|
case Network::Type::SWCAN:
|
||||||
case Network::Type::LSFTCAN: {
|
case Network::Type::LSFTCAN: {
|
||||||
@@ -123,6 +135,17 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} // End of Network::Type::MDIO
|
} // End of Network::Type::MDIO
|
||||||
|
case Network::Type::SPI: {
|
||||||
|
auto msg = std::dynamic_pointer_cast<SPIMessage>(message);
|
||||||
|
if(!msg) {
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return false; // The message was not a properly formed LiveDataMessage
|
||||||
|
}
|
||||||
|
if(!HardwareSPIPacket::EncodeFromMessage(*msg, result, report))
|
||||||
|
return false;
|
||||||
|
result = packetizer.packetWrap(result, false);
|
||||||
|
return true;
|
||||||
|
} // End of Network::Type::SPI
|
||||||
default:
|
default:
|
||||||
report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error);
|
report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
@@ -230,7 +253,6 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
|||||||
(uint8_t)(netid >> 8)
|
(uint8_t)(netid >> 8)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result = packetizer.packetWrap(*buffer, shortFormat);
|
result = packetizer.packetWrap(*buffer, shortFormat);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "icsneo/communication/livedata.h"
|
#include "icsneo/communication/livedata.h"
|
||||||
|
#include <cmath>
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
namespace LiveDataUtil {
|
namespace LiveDataUtil {
|
||||||
@@ -18,5 +19,61 @@ double liveDataValueToDouble(const LiveDataValue& val) {
|
|||||||
return val.value * liveDataFixedPointToDouble;
|
return val.value * liveDataFixedPointToDouble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool liveDataDoubleToValue(const double& dFloat, LiveDataValue& value) {
|
||||||
|
union {
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ValueFractionPart;
|
||||||
|
int32_t ValueInt32;
|
||||||
|
} parts;
|
||||||
|
int64_t ValueLarge;
|
||||||
|
} CminiFixedPt;
|
||||||
|
constexpr double CM_FIXED_POINT_TO_DOUBLEVALUE = (1.0 / (double)(1ULL << 32)); // 2^-32
|
||||||
|
constexpr double CM_DOUBLEVALUE_TO_FIXED_POINT = ((double)(1ULL << 32)); // 2^32
|
||||||
|
// Use const for limits (C++98 compatible)
|
||||||
|
const double INT32_MAX_DOUBLE =
|
||||||
|
static_cast<double>(std::numeric_limits<int32_t>::max()) + (1.0 - std::numeric_limits<double>::epsilon());
|
||||||
|
const double INT32_MIN_DOUBLE = static_cast<double>(std::numeric_limits<int32_t>::min());
|
||||||
|
const double MIN_FIXED_POINT_DOUBLE = (double)(1ull * CM_FIXED_POINT_TO_DOUBLEVALUE);
|
||||||
|
|
||||||
|
// This needs to be assigned separately, otherwise, for dFloat >= 2^31,
|
||||||
|
// long double dBigFloat = dFloat * CM_DOUBLEVALUE_TO_FIXED_POINT overflows
|
||||||
|
// long long (value is >= 2^63) and so the assignment ValueLarge = dBigFloat is undefined
|
||||||
|
|
||||||
|
int32_t intPart; //creating temp variable due to static analysis warning about writing and reading to different union members
|
||||||
|
if(dFloat < 0.0)
|
||||||
|
intPart = (int32_t)std::floor(dFloat);
|
||||||
|
else
|
||||||
|
intPart = (int32_t)dFloat;
|
||||||
|
|
||||||
|
//using temp varialbes to avoid static analysis warning about read/write to different union members
|
||||||
|
double frac = dFloat - (double)(intPart);
|
||||||
|
uint32_t fracPart = (uint32_t)std::floor((frac * CM_DOUBLEVALUE_TO_FIXED_POINT) + 0.5);
|
||||||
|
|
||||||
|
//write temp vars back into the union
|
||||||
|
CminiFixedPt.parts.ValueInt32 = intPart;
|
||||||
|
CminiFixedPt.parts.ValueFractionPart = fracPart;
|
||||||
|
value.value = CminiFixedPt.ValueLarge;
|
||||||
|
|
||||||
|
if(dFloat == (double)0.0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//check if double can be stored as 32.32
|
||||||
|
// 0x1 0000 0000 0000 0000 * CM_FIXED_POINT_TO_DOUBLEVALUE = 0x1 0000 0000
|
||||||
|
if(dFloat > INT32_MAX_DOUBLE || dFloat < INT32_MIN_DOUBLE) {
|
||||||
|
EventManager::GetInstance().add(APIEvent::Type::FixedPointOverflow, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use absolute value for minimum fixed point check
|
||||||
|
double absFloat = (dFloat < 0.0) ? -dFloat : dFloat;
|
||||||
|
if(absFloat < MIN_FIXED_POINT_DOUBLE) {
|
||||||
|
EventManager::GetInstance().add(APIEvent::Type::FixedPointPrecision, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace LiveDataUtil
|
} // namespace LiveDataUtil
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include "icsneo/communication/message/clientidmessage.h"
|
||||||
|
#include "icsneo/communication/icspb.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<ClientIdMessage> ClientIdMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
ClientIdMessage decoded;
|
||||||
|
commands::generic::v1::ClientId msg;
|
||||||
|
|
||||||
|
if(!protoapi::processResponse(bytestream.data(), bytestream.size(), msg)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(msg.has_client_id()) {
|
||||||
|
decoded.clientId.emplace(msg.client_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_shared<ClientIdMessage>(decoded);
|
||||||
|
}
|
||||||
@@ -13,7 +13,15 @@ enum LinkSpeed {
|
|||||||
ethSpeed10000,
|
ethSpeed10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LinkMode {
|
enum TLinkMode {
|
||||||
|
T_LINK_NONE,
|
||||||
|
T_LINK_MASTER,
|
||||||
|
T_LINK_SLAVE,
|
||||||
|
T_LINK_AUTO,
|
||||||
|
T_LINK_INVALID = 255,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum AELinkMode {
|
||||||
AE_LINK_AUTO,
|
AE_LINK_AUTO,
|
||||||
AE_LINK_MASTER,
|
AE_LINK_MASTER,
|
||||||
AE_LINK_SLAVE,
|
AE_LINK_SLAVE,
|
||||||
@@ -46,11 +54,26 @@ std::shared_ptr<Message> EthernetStatusMessage::DecodeToMessage(const std::vecto
|
|||||||
default: return nullptr;
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
LinkMode mode;
|
LinkMode mode;
|
||||||
switch(packet->mode) {
|
switch(Network::GetTypeOfNetID((Network::NetID)packet->network, false)) {
|
||||||
case AE_LINK_INVALID: mode = EthernetStatusMessage::LinkMode::LinkModeInvalid; break;
|
case Network::Type::Ethernet:
|
||||||
case AE_LINK_AUTO: mode = EthernetStatusMessage::LinkMode::LinkModeAuto; break;
|
switch(packet->mode) {
|
||||||
case AE_LINK_MASTER: mode = EthernetStatusMessage::LinkMode::LinkModeMaster; break;
|
case T_LINK_NONE: mode = EthernetStatusMessage::LinkMode::LinkModeNone; break;
|
||||||
case AE_LINK_SLAVE: mode = EthernetStatusMessage::LinkMode::LinkModeSlave; break;
|
case T_LINK_MASTER: mode = EthernetStatusMessage::LinkMode::LinkModeMaster; break;
|
||||||
|
case T_LINK_SLAVE: mode = EthernetStatusMessage::LinkMode::LinkModeSlave; break;
|
||||||
|
case T_LINK_AUTO: mode = EthernetStatusMessage::LinkMode::LinkModeAuto; break;
|
||||||
|
case T_LINK_INVALID: mode = EthernetStatusMessage::LinkMode::LinkModeInvalid; break;
|
||||||
|
default: return nullptr;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Network::Type::AutomotiveEthernet:
|
||||||
|
switch(packet->mode) {
|
||||||
|
case AE_LINK_AUTO: mode = EthernetStatusMessage::LinkMode::LinkModeAuto; break;
|
||||||
|
case AE_LINK_MASTER: mode = EthernetStatusMessage::LinkMode::LinkModeMaster; break;
|
||||||
|
case AE_LINK_SLAVE: mode = EthernetStatusMessage::LinkMode::LinkModeSlave; break;
|
||||||
|
case AE_LINK_INVALID: mode = EthernetStatusMessage::LinkMode::LinkModeInvalid; break;
|
||||||
|
default: return nullptr;
|
||||||
|
}
|
||||||
|
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, speed, packet->duplex, mode);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
|
|||||||
msg->Clause45Enable = clause45;
|
msg->Clause45Enable = clause45;
|
||||||
msg->Enabled = enabled;
|
msg->Enabled = enabled;
|
||||||
msg->WriteEnable = writeEnable;
|
msg->WriteEnable = writeEnable;
|
||||||
msg->version = 1u;
|
msg->Version = 1u;
|
||||||
if( (FiveBits < phyAddrOrPort) ||
|
if( (FiveBits < phyAddrOrPort) ||
|
||||||
(clause45 && (FiveBits < pageOrDevice)) ||
|
(clause45 && (FiveBits < pageOrDevice)) ||
|
||||||
(!clause45 && (FiveBits < regAddr)) )
|
(!clause45 && (FiveBits < regAddr)) )
|
||||||
@@ -18,17 +18,17 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
|
|||||||
|
|
||||||
if(clause45)
|
if(clause45)
|
||||||
{
|
{
|
||||||
msg->clause45.port = phyAddrOrPort;
|
msg->Clause45.port = phyAddrOrPort;
|
||||||
msg->clause45.device = pageOrDevice;
|
msg->Clause45.device = pageOrDevice;
|
||||||
msg->clause45.regAddr = regAddr;
|
msg->Clause45.regAddr = regAddr;
|
||||||
msg->clause45.regVal = regVal;
|
msg->Clause45.regVal = regVal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg->clause22.phyAddr = phyAddrOrPort;
|
msg->Clause22.phyAddr = phyAddrOrPort;
|
||||||
msg->clause22.page = pageOrDevice;
|
msg->Clause22.page = pageOrDevice;
|
||||||
msg->clause22.regAddr = regAddr;
|
msg->Clause22.regAddr = regAddr;
|
||||||
msg->clause22.regVal = regVal;
|
msg->Clause22.regVal = regVal;
|
||||||
}
|
}
|
||||||
return appendPhyMessage(msg);
|
return appendPhyMessage(msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
std::vector<uint8_t> FlexRayControlMessage::BuildBaseControlArgs(uint8_t controller, FlexRay::Opcode op, const std::vector<uint8_t>& args) {
|
std::vector<uint8_t> FlexRayControlMessage::BuildBaseControlArgs(uint8_t controller, FlexRay::Opcode op, const std::vector<uint8_t>& args) {
|
||||||
std::vector<uint8_t> ret(args.size() + 4);
|
std::vector<uint8_t> ret;
|
||||||
ret.push_back(controller);
|
ret.push_back(controller);
|
||||||
const uint16_t size = uint16_t((std::min)(args.size() + 1, size_t(std::numeric_limits<uint16_t>::max()))); // Add 1 for the opcode
|
const uint16_t size = static_cast<uint16_t>(std::min(args.size() + 1, size_t(std::numeric_limits<uint16_t>::max()))); // Add 1 for the opcode
|
||||||
ret.push_back(uint8_t(size));
|
ret.push_back(uint8_t(size));
|
||||||
ret.push_back(uint8_t(size >> 8));
|
ret.push_back(uint8_t(size >> 8));
|
||||||
ret.push_back(uint8_t(op));
|
ret.push_back(uint8_t(op));
|
||||||
|
|||||||
@@ -12,4 +12,14 @@ void LiveDataCommandMessage::appendSignalArg(LiveDataValueType valueType) {
|
|||||||
arg->valueType = valueType;
|
arg->valueType = valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LiveDataSetValueMessage::appendSetValue(LiveDataValueType valueType, const LiveDataValue& value) {
|
||||||
|
auto& arg = args.emplace_back(std::make_shared<LiveDataArgument>());
|
||||||
|
arg->objectType = LiveDataObjectType::MISC;
|
||||||
|
arg->objectIndex = 0u;
|
||||||
|
arg->signalIndex = 0u;
|
||||||
|
arg->valueType = valueType;
|
||||||
|
|
||||||
|
values.push_back(std::make_shared<LiveDataValue>(value));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
|
|||||||
can.status.canfdESI = canmsg->errorStateIndicator;
|
can.status.canfdESI = canmsg->errorStateIndicator;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Network::Type::Ethernet: {
|
case Network::Type::Ethernet:
|
||||||
|
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;
|
||||||
@@ -142,7 +143,8 @@ std::shared_ptr<Message> icsneo::CreateMessageFromNeoMessage(const neomessage_t*
|
|||||||
canmsg->errorStateIndicator = can.status.canfdESI;
|
canmsg->errorStateIndicator = can.status.canfdESI;
|
||||||
return canmsg;
|
return canmsg;
|
||||||
}
|
}
|
||||||
case Network::Type::Ethernet: {
|
case Network::Type::Ethernet:
|
||||||
|
case Network::Type::AutomotiveEthernet: {
|
||||||
neomessage_eth_t& eth = *(neomessage_eth_t*)neomessage;
|
neomessage_eth_t& eth = *(neomessage_eth_t*)neomessage;
|
||||||
auto ethmsg = std::make_shared<EthernetMessage>();
|
auto ethmsg = std::make_shared<EthernetMessage>();
|
||||||
ethmsg->network = network;
|
ethmsg->network = network;
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
#include "icsneo/communication/message/networkmutexmessage.h"
|
||||||
|
#include "icsneo/communication/icspb.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<NetworkMutexMessage> NetworkMutexMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
NetworkMutexMessage decoded;
|
||||||
|
commands::network::v1::NetworkMutex msg;
|
||||||
|
|
||||||
|
if(!protoapi::processResponse(bytestream.data(), bytestream.size(), msg)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(msg.has_client_id()) {
|
||||||
|
decoded.owner_id.emplace(msg.client_id());
|
||||||
|
}
|
||||||
|
if(msg.has_type()) {
|
||||||
|
decoded.type.emplace(static_cast<NetworkMutexType>(msg.type()));
|
||||||
|
}
|
||||||
|
if(msg.has_priority()) {
|
||||||
|
decoded.priority.emplace(msg.priority());
|
||||||
|
}
|
||||||
|
if(msg.has_ttl()){
|
||||||
|
decoded.ttlMs.emplace(msg.ttl());
|
||||||
|
}
|
||||||
|
if(msg.has_event()){
|
||||||
|
decoded.event.emplace(static_cast<NetworkMutexEvent>(msg.event()));
|
||||||
|
}
|
||||||
|
for(int i = 0 ; i < msg.network_ids_size(); ++i){
|
||||||
|
decoded.networks.emplace(static_cast<Network::NetID>(msg.network_ids(i)));
|
||||||
|
}
|
||||||
|
return std::make_shared<NetworkMutexMessage>(decoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> NetworkMutexMessage::EncodeArgumentsForLock(uint32_t client_id, NetworkMutexType type, uint32_t priority, uint32_t ttlMs, const std::set<Network::NetID>& networks, const device_eventhandler_t& /* report */) {
|
||||||
|
commands::network::v1::NetworkMutex msg;
|
||||||
|
for(auto&& network_id : networks) {
|
||||||
|
msg.add_network_ids(static_cast<commands::network::v1::NetworkId>(network_id));
|
||||||
|
}
|
||||||
|
msg.set_client_id(client_id);
|
||||||
|
msg.set_priority(priority);
|
||||||
|
msg.set_ttl(ttlMs);
|
||||||
|
msg.set_type(static_cast<commands::network::v1::MutexType>(type));
|
||||||
|
|
||||||
|
return protoapi::getPayload(protoapi::Command::PUT, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> NetworkMutexMessage::EncodeArgumentsForLockAll(uint32_t client_id, NetworkMutexType type, uint32_t priority, uint32_t ttlMs, const device_eventhandler_t& /* report */) {
|
||||||
|
commands::network::v1::NetworkMutex msg;
|
||||||
|
msg.set_client_id(client_id);
|
||||||
|
msg.set_priority(priority);
|
||||||
|
msg.set_ttl(ttlMs);
|
||||||
|
msg.set_type(static_cast<commands::network::v1::MutexType>(type));
|
||||||
|
msg.set_global(true);
|
||||||
|
|
||||||
|
return protoapi::getPayload(protoapi::Command::PUT, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> NetworkMutexMessage::EncodeArgumentsForUnlock(uint32_t client_id, const std::set<Network::NetID>& networks, const device_eventhandler_t& /* report */) {
|
||||||
|
commands::network::v1::NetworkMutex msg;
|
||||||
|
msg.Clear();
|
||||||
|
for(auto&& network_id : networks)
|
||||||
|
{
|
||||||
|
msg.add_network_ids(static_cast<commands::network::v1::NetworkId>(network_id));
|
||||||
|
}
|
||||||
|
msg.set_client_id(client_id);
|
||||||
|
msg.set_release(true);
|
||||||
|
|
||||||
|
return protoapi::getPayload(protoapi::Command::PUT, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> NetworkMutexMessage::EncodeArgumentsForUnlockAll(uint32_t client_id, const device_eventhandler_t& /* report */) {
|
||||||
|
commands::network::v1::NetworkMutex msg;
|
||||||
|
msg.Clear();
|
||||||
|
msg.set_client_id(client_id);
|
||||||
|
msg.set_release(true);
|
||||||
|
msg.set_global(true);
|
||||||
|
|
||||||
|
return protoapi::getPayload(protoapi::Command::PUT, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> NetworkMutexMessage::EncodeArgumentsForStatus(Network::NetID network, const device_eventhandler_t& /* report */) {
|
||||||
|
commands::network::v1::NetworkMutex msg;
|
||||||
|
msg.add_network_ids(static_cast<commands::network::v1::NetworkId>(network));
|
||||||
|
return protoapi::getPayload(protoapi::Command::GET, msg);
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
#include "icsneo/communication/message/transmitmessage.h"
|
||||||
|
|
||||||
|
// packet defs
|
||||||
|
#include "icsneo/communication/packet/ethernetpacket.h"
|
||||||
|
#include "icsneo/communication/packet/canpacket.h"
|
||||||
|
#include "icsneo/communication/packet/linpacket.h"
|
||||||
|
|
||||||
|
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) {
|
||||||
|
auto ethmsg = std::dynamic_pointer_cast<EthernetMessage>(frame);
|
||||||
|
if(!ethmsg) {
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> encoded;
|
||||||
|
size_t messageLen = ethmsg->data.size();
|
||||||
|
encoded.resize(sizeof(TransmitMessage) + messageLen);
|
||||||
|
|
||||||
|
TransmitMessage* const msg = (TransmitMessage*)encoded.data();
|
||||||
|
HardwareEthernetPacket* const ethpacket = (HardwareEthernetPacket*)(msg->commonHeader);
|
||||||
|
uint8_t* const payload = encoded.data() + sizeof(TransmitMessage);
|
||||||
|
|
||||||
|
ethpacket->header.ENABLE_PADDING = ethmsg->noPadding ? 0 : 1;
|
||||||
|
ethpacket->header.FCS_OVERRIDE = ethmsg->fcs ? 1 : 0;
|
||||||
|
ethpacket->eid.txlen = static_cast<uint16_t>(messageLen);
|
||||||
|
ethpacket->Length = static_cast<uint16_t>(messageLen);
|
||||||
|
ethpacket->stats = ethmsg->description;
|
||||||
|
ethpacket->NetworkID = static_cast<uint16_t>(ethmsg->network.getNetID());
|
||||||
|
std::copy(ethmsg->data.begin(), ethmsg->data.end(), payload);
|
||||||
|
return encoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<uint8_t> EncodeFromMessageCAN(std::shared_ptr<Frame> frame, const device_eventhandler_t& report) {
|
||||||
|
auto canmsg = std::dynamic_pointer_cast<CANMessage>(frame);
|
||||||
|
if(!canmsg) {
|
||||||
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if(canmsg->isCANFD && canmsg->isRemote) {
|
||||||
|
report(APIEvent::Type::RTRNotSupported, APIEvent::Severity::Error);
|
||||||
|
return {}; // RTR frames can not be used with CAN FD
|
||||||
|
}
|
||||||
|
std::vector<uint8_t> encoded;
|
||||||
|
size_t messageLen = canmsg->data.size();
|
||||||
|
size_t extraLen = 0;
|
||||||
|
if(messageLen > 8) {
|
||||||
|
extraLen = messageLen - 8;
|
||||||
|
}
|
||||||
|
encoded.resize(sizeof(TransmitMessage) + extraLen);
|
||||||
|
|
||||||
|
TransmitMessage* const msg = (TransmitMessage*)encoded.data();
|
||||||
|
HardwareCANPacket* const canpacket = (HardwareCANPacket*)(msg->commonHeader);
|
||||||
|
uint8_t* const extra_payload = encoded.data() + sizeof(TransmitMessage);
|
||||||
|
|
||||||
|
const size_t dataSize = canmsg->data.size();
|
||||||
|
std::optional<uint8_t> dlc = CAN_LengthToDLC(dataSize, canmsg->isCANFD);
|
||||||
|
if(!dlc.has_value()) {
|
||||||
|
report(APIEvent::Type::MessageMaxLengthExceeded, APIEvent::Severity::Error);
|
||||||
|
return {}; // Too much data for the protocol
|
||||||
|
}
|
||||||
|
// arb id
|
||||||
|
if(canmsg->isExtended) {
|
||||||
|
canpacket->header.IDE = 1;
|
||||||
|
canpacket->header.SID = (canmsg->arbid >> 18) & 0x7FF;
|
||||||
|
canpacket->eid.EID = (canmsg->arbid >> 6) & 0xfff;
|
||||||
|
canpacket->dlc.EID2 = canmsg->arbid & 0x3f;
|
||||||
|
} else {
|
||||||
|
canpacket->header.IDE = 0;
|
||||||
|
canpacket->header.SID = canmsg->arbid & 0x7FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DLC
|
||||||
|
canpacket->dlc.DLC = dlc.value();
|
||||||
|
|
||||||
|
// FDF/BRS or remote frames
|
||||||
|
if(canmsg->isCANFD) {
|
||||||
|
canpacket->header.EDL = 1;
|
||||||
|
canpacket->header.BRS = canmsg->baudrateSwitch ? 1 : 0;
|
||||||
|
canpacket->header.ESI = canmsg->errorStateIndicator ? 1 : 0;
|
||||||
|
canpacket->dlc.RTR = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
canpacket->header.EDL = 0;
|
||||||
|
canpacket->header.BRS = 0;
|
||||||
|
canpacket->header.ESI = 0;
|
||||||
|
canpacket->dlc.RTR = canmsg->isRemote ? 1 : 0;
|
||||||
|
}
|
||||||
|
// network
|
||||||
|
canpacket->NetworkID = static_cast<uint16_t>(canmsg->network.getNetID());
|
||||||
|
canpacket->Length = static_cast<uint16_t>(extraLen);
|
||||||
|
// description id
|
||||||
|
canpacket->stats = canmsg->description;
|
||||||
|
// first 8 bytes
|
||||||
|
std::copy(canmsg->data.begin(), canmsg->data.begin() + (messageLen > 8 ? 8 : messageLen), canpacket->data);
|
||||||
|
// extra bytes
|
||||||
|
if(extraLen > 0) {
|
||||||
|
// copy extra data after the can packet
|
||||||
|
std::copy(canmsg->data.begin() + 8, canmsg->data.end(), extra_payload);
|
||||||
|
}
|
||||||
|
return encoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<uint8_t> EncodeFromMessageLIN(std::shared_ptr<Frame> /* frame */, const device_eventhandler_t& report) {
|
||||||
|
// TODO
|
||||||
|
report(APIEvent::Type::UnsupportedTXNetwork, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> TransmitMessage::EncodeFromMessage(std::shared_ptr<Frame> frame, uint32_t client_id, const device_eventhandler_t& report) {
|
||||||
|
std::vector<uint8_t> result;
|
||||||
|
switch(frame->network.getType()) {
|
||||||
|
case Network::Type::Ethernet:
|
||||||
|
case Network::Type::AutomotiveEthernet:
|
||||||
|
result = EncodeFromMessageEthernet(frame, report);
|
||||||
|
break;
|
||||||
|
case Network::Type::CAN:
|
||||||
|
result = EncodeFromMessageCAN(frame, report);
|
||||||
|
break;
|
||||||
|
case Network::Type::LIN:
|
||||||
|
result = EncodeFromMessageLIN(frame, report);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// common fields
|
||||||
|
TransmitMessage* const msg = (TransmitMessage*)result.data();
|
||||||
|
msg->options.clientId = client_id;
|
||||||
|
msg->options.networkId = static_cast<uint32_t>(frame->network.getNetID());
|
||||||
|
msg->options.reserved[0] = 0;
|
||||||
|
msg->options.reserved[1] = 0;
|
||||||
|
msg->options.reserved[2] = 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ using namespace icsneo;
|
|||||||
MultiChannelCommunication::MultiChannelCommunication(device_eventhandler_t err, std::unique_ptr<Driver> com,
|
MultiChannelCommunication::MultiChannelCommunication(device_eventhandler_t err, std::unique_ptr<Driver> com,
|
||||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer, std::unique_ptr<Encoder> e,
|
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer, std::unique_ptr<Encoder> e,
|
||||||
std::unique_ptr<Decoder> md, size_t vnetCount) :
|
std::unique_ptr<Decoder> md, size_t vnetCount) :
|
||||||
Communication(err, std::move(com), makeConfiguredPacketizer, std::move(e), std::move(md)), numVnets(vnetCount) {
|
Communication(err, std::move(com), makeConfiguredPacketizer, std::move(e), std::move(md)), numVnets(vnetCount), packetRB(2048) {
|
||||||
vnetThreads.resize(numVnets);
|
vnetThreads.resize(numVnets);
|
||||||
vnetQueues.resize(numVnets);
|
vnetQueues.resize(numVnets);
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ void MultiChannelCommunication::spawnThreads() {
|
|||||||
|
|
||||||
void MultiChannelCommunication::joinThreads() {
|
void MultiChannelCommunication::joinThreads() {
|
||||||
closing = true;
|
closing = true;
|
||||||
|
ringBufCV.notify_all();
|
||||||
if(hidReadThread.joinable())
|
if(hidReadThread.joinable())
|
||||||
hidReadThread.join();
|
hidReadThread.join();
|
||||||
for(auto& thread : vnetThreads) {
|
for(auto& thread : vnetThreads) {
|
||||||
@@ -148,9 +149,13 @@ void MultiChannelCommunication::hidReadTask() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!currentQueue->enqueue(std::move(payloadBytes)) && gotPacket)
|
{
|
||||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::FailedToRead, APIEvent::Severity::Error));
|
std::unique_lock lk(ringBufMutex);
|
||||||
payloadBytes.clear();
|
if(!packetRB.write(std::move(payloadBytes)) && gotPacket)
|
||||||
|
EventManager::GetInstance().add(APIEvent(APIEvent::Type::FailedToRead, APIEvent::Severity::Error));
|
||||||
|
payloadBytes.clear();
|
||||||
|
}
|
||||||
|
ringBufCV.notify_all();
|
||||||
gotPacket = true;
|
gotPacket = true;
|
||||||
state = PreprocessState::SearchForCommand;
|
state = PreprocessState::SearchForCommand;
|
||||||
break;
|
break;
|
||||||
@@ -160,7 +165,6 @@ void MultiChannelCommunication::hidReadTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
|
void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
|
||||||
moodycamel::BlockingReaderWriterQueue< std::vector<uint8_t> >& queue = vnetQueues[vnetIndex];
|
|
||||||
std::vector<uint8_t> payloadBytes;
|
std::vector<uint8_t> payloadBytes;
|
||||||
std::unique_ptr<Packetizer> packetizerLifetime;
|
std::unique_ptr<Packetizer> packetizerLifetime;
|
||||||
Packetizer* vnetPacketizer;
|
Packetizer* vnetPacketizer;
|
||||||
@@ -174,14 +178,19 @@ void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
|
|||||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||||
|
|
||||||
while(!closing) {
|
while(!closing) {
|
||||||
if(queue.wait_dequeue_timed(payloadBytes, std::chrono::milliseconds(250))) {
|
std::unique_lock lk(ringBufMutex);
|
||||||
if(closing)
|
ringBufCV.wait(lk);
|
||||||
break;
|
if(closing) {
|
||||||
|
break;
|
||||||
auto& ringBuffer = driver->getReadBuffer();
|
|
||||||
ringBuffer.write(payloadBytes);
|
|
||||||
|
|
||||||
handleInput(*vnetPacketizer);
|
|
||||||
}
|
}
|
||||||
|
if(vnetPacketizer->input(packetRB)) {
|
||||||
|
for(const auto& packet : vnetPacketizer->output()) {
|
||||||
|
std::shared_ptr<Message> msg;
|
||||||
|
if(!decoder->decode(msg, packet))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dispatchMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ std::shared_ptr<Message> HardwareCANPacket::DecodeToMessage(const std::vector<ui
|
|||||||
msg->data.insert(msg->data.end(), data->data, data->data + (length > 8 ? 8 : length));
|
msg->data.insert(msg->data.end(), data->data, data->data + (length > 8 ? 8 : length));
|
||||||
if(length > 8) { // If there are more than 8 bytes, they come at the end of the message
|
if(length > 8) { // If there are more than 8 bytes, they come at the end of the message
|
||||||
// Messages with extra data are formatted as message, then uint16_t netid, then uint16_t length, then extra data
|
// Messages with extra data are formatted as message, then uint16_t netid, then uint16_t length, then extra data
|
||||||
const auto extraDataStart = bytestream.begin() + sizeof(HardwareCANPacket) + 2 + 2;
|
const auto extraDataStart = bytestream.begin() + sizeof(HardwareCANPacket);
|
||||||
msg->data.insert(msg->data.end(), extraDataStart, extraDataStart + (length - 8));
|
msg->data.insert(msg->data.end(), extraDataStart, extraDataStart + (length - 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,34 @@
|
|||||||
#include "icsneo/communication/packet/ethernetpacket.h"
|
#include "icsneo/communication/packet/ethernetpacket.h"
|
||||||
#include <cstring> // memcpy
|
#include <algorithm> // for std::copy
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const std::vector<uint8_t>& bytestream, const device_eventhandler_t& report) {
|
std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
const HardwareEthernetPacket* packet = (const HardwareEthernetPacket*)((const void*)bytestream.data());
|
const HardwareEthernetPacket* packet = (const HardwareEthernetPacket*)((const void*)bytestream.data());
|
||||||
const uint16_t* rawWords = (const uint16_t*)bytestream.data();
|
const uint16_t* rawWords = (const uint16_t*)bytestream.data();
|
||||||
|
|
||||||
// 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
|
// 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)
|
if(packet->Length < 4)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const size_t fcsSize = packet->header.FCS_AVAIL ? 4 : 0;
|
const size_t fcsSize = packet->header.FCS_AVAIL ? 4 : 0;
|
||||||
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;
|
||||||
|
|
||||||
// Check for oversized packets, noting that some devices will send an extra byte to have an even number of bytes
|
|
||||||
if(bytestreamActualSize > bytestreamExpectedSize + 1)
|
|
||||||
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::EventWarning);
|
|
||||||
|
|
||||||
auto messagePtr = std::make_shared<EthernetMessage>();
|
auto messagePtr = std::make_shared<EthernetMessage>();
|
||||||
EthernetMessage& message = *messagePtr;
|
EthernetMessage& message = *messagePtr;
|
||||||
|
|
||||||
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;
|
message.preemptionEnabled = packet->header.PREEMPTION_ENABLED;
|
||||||
if(message.preemptionEnabled)
|
if(message.preemptionEnabled)
|
||||||
message.preemptionFlags = (uint8_t)((rawWords[0] & 0x03F8) >> 4);
|
message.preemptionFlags = (uint8_t)((rawWords[0] & 0x03F8) >> 4);
|
||||||
|
|
||||||
message.frameTooShort = packet->header.RUNT_FRAME;
|
message.frameTooShort = packet->header.RUNT_FRAME;
|
||||||
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;
|
||||||
@@ -48,7 +36,7 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
|
|||||||
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);
|
||||||
|
|
||||||
if(fcsSize) {
|
if(fcsSize) {
|
||||||
uint32_t& fcs = message.fcs.emplace();
|
uint32_t& fcs = message.fcs.emplace();
|
||||||
std::copy(dataend, dataend + fcsSize, (uint8_t*)&fcs);
|
std::copy(dataend, dataend + fcsSize, (uint8_t*)&fcs);
|
||||||
@@ -59,41 +47,83 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
|
|||||||
|
|
||||||
bool HardwareEthernetPacket::EncodeFromMessage(const EthernetMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t&) {
|
bool HardwareEthernetPacket::EncodeFromMessage(const EthernetMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t&) {
|
||||||
const size_t unpaddedSize = message.data.size();
|
const size_t unpaddedSize = message.data.size();
|
||||||
size_t paddedSize = unpaddedSize;
|
if(unpaddedSize == 0)
|
||||||
uint16_t description = message.description;
|
return false;
|
||||||
|
|
||||||
if(!message.noPadding && unpaddedSize < 60)
|
|
||||||
paddedSize = 60; // Pad out short messages
|
|
||||||
|
|
||||||
size_t sizeWithHeader = paddedSize + 4; // DescriptionID and Padded Count
|
|
||||||
|
|
||||||
// Description ID Most Significant bit is used to identify preemption frames
|
// Description ID Most Significant bit is used to identify preemption frames
|
||||||
|
uint16_t description = message.description;
|
||||||
if(description & 0x8000)
|
if(description & 0x8000)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(message.preemptionEnabled) {
|
const bool preempt = message.preemptionEnabled;
|
||||||
sizeWithHeader++; // Make space for the preemption flags
|
// full header including parent
|
||||||
|
const size_t headerByteCount = preempt ? 15 : 14;
|
||||||
|
// local header for netID, description, and flags
|
||||||
|
const size_t localHeader = preempt ? 10 : 9;
|
||||||
|
// allocate space for fcs override
|
||||||
|
const size_t fcsSize = message.fcs ? 4 : 0;
|
||||||
|
|
||||||
|
if(preempt)
|
||||||
description |= 0x8000;
|
description |= 0x8000;
|
||||||
|
|
||||||
|
size_t paddedSize = unpaddedSize;
|
||||||
|
if(!message.noPadding && unpaddedSize < 60)
|
||||||
|
paddedSize = 60;
|
||||||
|
|
||||||
|
// size of full payload including optional fcs
|
||||||
|
size_t payloadSize = paddedSize + fcsSize;
|
||||||
|
|
||||||
|
|
||||||
|
// totalBufferSize is local header + ethernet payload and option fcs
|
||||||
|
const size_t totalBufferSize = localHeader + paddedSize + fcsSize;
|
||||||
|
|
||||||
|
bytestream.clear();
|
||||||
|
bytestream.reserve(totalBufferSize);
|
||||||
|
|
||||||
|
// Header size field (little endian)
|
||||||
|
bytestream.push_back(static_cast<uint8_t>(payloadSize & 0xFF));
|
||||||
|
bytestream.push_back(static_cast<uint8_t>((payloadSize >> 8) & 0xFF));
|
||||||
|
|
||||||
|
// Description (big endian)
|
||||||
|
bytestream.push_back(static_cast<uint8_t>(description >> 8));
|
||||||
|
bytestream.push_back(static_cast<uint8_t>(description));
|
||||||
|
|
||||||
|
bytestream.push_back(0x00);
|
||||||
|
bytestream.push_back(static_cast<uint8_t>(headerByteCount));
|
||||||
|
|
||||||
|
// Network ID (little endian)
|
||||||
|
uint16_t realID = static_cast<uint16_t>(message.network.getNetID());
|
||||||
|
bytestream.push_back(static_cast<uint8_t>(realID & 0xFF));
|
||||||
|
bytestream.push_back(static_cast<uint8_t>((realID >> 8) & 0xFF));
|
||||||
|
|
||||||
|
// Flags
|
||||||
|
constexpr uint8_t FLAG_PADDING = 0x01;
|
||||||
|
constexpr uint8_t FLAG_FCS = 0x04;
|
||||||
|
constexpr uint8_t FLAG_PREEMPTION = 0x08;
|
||||||
|
|
||||||
|
uint8_t flags = 0x00;
|
||||||
|
if(!message.noPadding) flags |= FLAG_PADDING;
|
||||||
|
if(message.fcs) flags |= FLAG_FCS;
|
||||||
|
if(message.preemptionEnabled) flags |= FLAG_PREEMPTION;
|
||||||
|
|
||||||
|
bytestream.push_back(flags);
|
||||||
|
|
||||||
|
if(preempt)
|
||||||
|
bytestream.push_back(static_cast<uint8_t>(message.preemptionFlags));
|
||||||
|
|
||||||
|
bytestream.insert(bytestream.end(), message.data.begin(), message.data.end());
|
||||||
|
|
||||||
|
// Only zero-fill when we want padding
|
||||||
|
if(!message.noPadding && unpaddedSize < 60) {
|
||||||
|
size_t paddingNeeded = 60 - unpaddedSize;
|
||||||
|
bytestream.insert(bytestream.end(), paddingNeeded, 0); // Zero-fill for padding
|
||||||
}
|
}
|
||||||
|
|
||||||
bytestream.reserve(sizeWithHeader + 8); // Also reserve space for the bytes we'll use later on
|
|
||||||
bytestream.resize(sizeWithHeader);
|
|
||||||
size_t index = 0;
|
|
||||||
|
|
||||||
// Padded size, little endian
|
if(message.fcs) {
|
||||||
bytestream[index++] = uint8_t(paddedSize);
|
uint32_t fcs = message.fcs.value();
|
||||||
bytestream[index++] = uint8_t(paddedSize >> 8);
|
const uint8_t* fcsBytes = reinterpret_cast<const uint8_t*>(&fcs);
|
||||||
|
bytestream.insert(bytestream.end(), fcsBytes, fcsBytes + sizeof(fcs));
|
||||||
// Description ID, big endian
|
}
|
||||||
bytestream[index++] = uint8_t(description >> 8);
|
|
||||||
bytestream[index++] = uint8_t(description);
|
|
||||||
|
|
||||||
// The header is one byte larger if preemption is enabled, shifting the data
|
|
||||||
if(message.preemptionEnabled)
|
|
||||||
bytestream[index++] = message.preemptionFlags;
|
|
||||||
|
|
||||||
// We only copy in the unpadded size, the rest will be 0
|
|
||||||
memcpy(bytestream.data() + index, message.data.data(), unpaddedSize);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,12 @@ std::shared_ptr<EthPhyMessage> HardwareEthernetPhyRegisterPacket::DecodeToMessag
|
|||||||
phyMessage->Enabled = (pEntry->Enabled != 0u);
|
phyMessage->Enabled = (pEntry->Enabled != 0u);
|
||||||
phyMessage->WriteEnable = (pEntry->WriteEnable != 0u);
|
phyMessage->WriteEnable = (pEntry->WriteEnable != 0u);
|
||||||
phyMessage->Clause45Enable = (pEntry->Clause45Enable != 0u);
|
phyMessage->Clause45Enable = (pEntry->Clause45Enable != 0u);
|
||||||
phyMessage->version = static_cast<uint8_t>(pEntry->version);
|
phyMessage->BusIndex = static_cast<uint8_t>(pEntry->BusIndex);
|
||||||
|
phyMessage->Version = static_cast<uint8_t>(pEntry->version);
|
||||||
if(phyMessage->Clause45Enable)
|
if(phyMessage->Clause45Enable)
|
||||||
phyMessage->clause45 = pEntry->clause45;
|
phyMessage->Clause45 = pEntry->clause45;
|
||||||
else
|
else
|
||||||
phyMessage->clause22 = pEntry->clause22;
|
phyMessage->Clause22 = pEntry->clause22;
|
||||||
msg->messages.push_back(phyMessage);
|
msg->messages.push_back(phyMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,34 +70,35 @@ bool HardwareEthernetPhyRegisterPacket::EncodeFromMessage(const EthPhyMessage& m
|
|||||||
PhyRegisterPacket_t tempPacket;
|
PhyRegisterPacket_t tempPacket;
|
||||||
tempPacket.Enabled = phyMessage->Enabled ? 0x1u : 0x0u;
|
tempPacket.Enabled = phyMessage->Enabled ? 0x1u : 0x0u;
|
||||||
tempPacket.WriteEnable = phyMessage->WriteEnable ? 0x1u : 0x0u;
|
tempPacket.WriteEnable = phyMessage->WriteEnable ? 0x1u : 0x0u;
|
||||||
tempPacket.version = (phyMessage->version & 0xF);
|
tempPacket.BusIndex = (phyMessage->BusIndex & 0xF);
|
||||||
|
tempPacket.version = (phyMessage->Version & 0xF);
|
||||||
if(phyMessage->Clause45Enable)
|
if(phyMessage->Clause45Enable)
|
||||||
{
|
{
|
||||||
if( (FiveBits < phyMessage->clause45.port) ||
|
if( (FiveBits < phyMessage->Clause45.port) ||
|
||||||
(FiveBits < phyMessage->clause45.device) )
|
(FiveBits < phyMessage->Clause45.device) )
|
||||||
{
|
{
|
||||||
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tempPacket.Clause45Enable = 0x1u;
|
tempPacket.Clause45Enable = 0x1u;
|
||||||
tempPacket.clause45.port = phyMessage->clause45.port;
|
tempPacket.clause45.port = phyMessage->Clause45.port;
|
||||||
tempPacket.clause45.device = phyMessage->clause45.device;
|
tempPacket.clause45.device = phyMessage->Clause45.device;
|
||||||
tempPacket.clause45.regAddr = phyMessage->clause45.regAddr;
|
tempPacket.clause45.regAddr = phyMessage->Clause45.regAddr;
|
||||||
tempPacket.clause45.regVal = phyMessage->clause45.regVal;
|
tempPacket.clause45.regVal = phyMessage->Clause45.regVal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( (FiveBits < phyMessage->clause22.phyAddr) ||
|
if( (FiveBits < phyMessage->Clause22.phyAddr) ||
|
||||||
(FiveBits < phyMessage->clause22.regAddr) )
|
(FiveBits < phyMessage->Clause22.regAddr) )
|
||||||
{
|
{
|
||||||
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tempPacket.Clause45Enable = 0x0u;
|
tempPacket.Clause45Enable = 0x0u;
|
||||||
tempPacket.clause22.phyAddr = phyMessage->clause22.phyAddr;
|
tempPacket.clause22.phyAddr = phyMessage->Clause22.phyAddr;
|
||||||
tempPacket.clause22.page = phyMessage->clause22.page;
|
tempPacket.clause22.page = phyMessage->Clause22.page;
|
||||||
tempPacket.clause22.regAddr = phyMessage->clause22.regAddr;
|
tempPacket.clause22.regAddr = phyMessage->Clause22.regAddr;
|
||||||
tempPacket.clause22.regVal = phyMessage->clause22.regVal;
|
tempPacket.clause22.regVal = phyMessage->Clause22.regVal;
|
||||||
}
|
}
|
||||||
uint8_t* pktPtr = reinterpret_cast<uint8_t*>(&tempPacket);
|
uint8_t* pktPtr = reinterpret_cast<uint8_t*>(&tempPacket);
|
||||||
bytestream.insert(bytestream.end(), pktPtr, pktPtr + sizeof(PhyRegisterPacket_t));
|
bytestream.insert(bytestream.end(), pktPtr, pktPtr + sizeof(PhyRegisterPacket_t));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace icsneo
|
|||||||
report(APIEvent::Type::I2CMessageExceedsMaxLength, APIEvent::Severity::Error);
|
report(APIEvent::Type::I2CMessageExceedsMaxLength, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(message.controlBytes.empty() || message.dataBytes.empty())
|
if(message.controlBytes.empty() && message.dataBytes.empty())
|
||||||
{
|
{
|
||||||
//You'll need to provide a target R/W register in controlBytes
|
//You'll need to provide a target R/W register in controlBytes
|
||||||
//alternatively, you're expecting to read without providing a dataBytes payload
|
//alternatively, you're expecting to read without providing a dataBytes payload
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ std::shared_ptr<Message> HardwareLINPacket::DecodeToMessage(const std::vector<ui
|
|||||||
size_t numDataBytes = packet->CoreMiniBitsLIN.len;
|
size_t numDataBytes = packet->CoreMiniBitsLIN.len;
|
||||||
size_t numHeaderBytes = sizeof(HardwareLINPacket::CoreMiniBitsLIN);
|
size_t numHeaderBytes = sizeof(HardwareLINPacket::CoreMiniBitsLIN);
|
||||||
|
|
||||||
if( (sizeof(HardwareLINPacket) != bytestream.size()) ||
|
if( (sizeof(HardwareLINPacket) > bytestream.size()) ||
|
||||||
((numDataBytes + numHeaderBytes) > bytestream.size()) )
|
((numDataBytes + numHeaderBytes) > bytestream.size()) )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ std::shared_ptr<Message> HardwareLINPacket::DecodeToMessage(const std::vector<ui
|
|||||||
--numDataBytes; //If data is present, there will be a checksum included
|
--numDataBytes; //If data is present, there will be a checksum included
|
||||||
|
|
||||||
auto msg = std::make_shared<LINMessage>(static_cast<uint8_t>(packet->CoreMiniBitsLIN.ID));
|
auto msg = std::make_shared<LINMessage>(static_cast<uint8_t>(packet->CoreMiniBitsLIN.ID));
|
||||||
msg->network = Network::GetNetIDFromCoreMiniNetwork(static_cast<Network::CoreMini>(packet->networkID));
|
|
||||||
msg->isEnhancedChecksum = static_cast<bool>(packet->CoreMiniBitsLIN.TxChkSumEnhanced);
|
msg->isEnhancedChecksum = static_cast<bool>(packet->CoreMiniBitsLIN.TxChkSumEnhanced);
|
||||||
|
|
||||||
/* Minimum one responder byte and one checksum byte. */
|
/* Minimum one responder byte and one checksum byte. */
|
||||||
|
|||||||
@@ -99,6 +99,33 @@ bool HardwareLiveDataPacket::EncodeFromMessage(LiveDataMessage& message, std::ve
|
|||||||
clearMsg->cmd = static_cast<uint32_t>(message.cmd);
|
clearMsg->cmd = static_cast<uint32_t>(message.cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LiveDataCommand::SET_VALUE: {
|
||||||
|
auto setValMsg = reinterpret_cast<LiveDataSetValueMessage*>(&message);
|
||||||
|
const auto numArgs = setValMsg->args.size();
|
||||||
|
if(numArgs) {
|
||||||
|
payloadSize = static_cast<uint16_t>(sizeof(LiveDataSetValue) + (sizeof(LiveDataSetValueEntry) * (numArgs-1)));
|
||||||
|
bytestream.resize((payloadSize + sizeof(ExtendedCommandHeader)),0);
|
||||||
|
LiveDataSetValue* out = reinterpret_cast<LiveDataSetValue*>(bytestream.data() + sizeof(ExtendedCommandHeader));
|
||||||
|
out->version = icsneo::LiveDataUtil::LiveDataVersion;
|
||||||
|
out->cmd = static_cast<uint32_t>(setValMsg->cmd);
|
||||||
|
if(!setValMsg->handle)
|
||||||
|
setValMsg->handle = LiveDataUtil::getNewHandle();
|
||||||
|
out->handle = setValMsg->handle;
|
||||||
|
out->numSetValues = (uint32_t)numArgs;
|
||||||
|
for(size_t i = 0; i < numArgs; ++i) {
|
||||||
|
out->values[i].arg.objectType = setValMsg->args[i]->objectType;
|
||||||
|
out->values[i].arg.objectIndex = setValMsg->args[i]->objectIndex;
|
||||||
|
out->values[i].arg.signalIndex = setValMsg->args[i]->signalIndex;
|
||||||
|
out->values[i].arg.valueType = setValMsg->args[i]->valueType;
|
||||||
|
out->values[i].value.value = setValMsg->values[i]->value;
|
||||||
|
out->values[i].value.header.length = sizeof(LiveDataValue::value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
report(APIEvent::Type::LiveDataInvalidArgument, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
report(APIEvent::Type::LiveDataInvalidCommand, APIEvent::Severity::Error);
|
report(APIEvent::Type::LiveDataInvalidCommand, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#include "icsneo/communication/packet/spipacket.h"
|
||||||
|
#include "icsneo/communication/command.h"
|
||||||
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
static size_t SPISubHeaderLength = 5u;
|
||||||
|
|
||||||
|
std::shared_ptr<Message> HardwareSPIPacket::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||||
|
if(bytestream.size() < sizeof(HardwareSPIPacket)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
const HardwareSPIPacket* packet = (const HardwareSPIPacket*)bytestream.data();
|
||||||
|
size_t totalPackedLength = static_cast<size_t>(bytestream.size()) - sizeof(HardwareSPIPacket); // First 28 bytes are message header.
|
||||||
|
if(totalPackedLength < SPISubHeaderLength) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t* bytes = bytestream.data() + sizeof(HardwareSPIPacket);
|
||||||
|
std::shared_ptr<SPIMessage> msg = std::make_shared<SPIMessage>();
|
||||||
|
msg->direction = static_cast<SPIMessage::Direction>(bytes[0]);
|
||||||
|
msg->address = *reinterpret_cast<const uint16_t*>(&bytes[1]);
|
||||||
|
msg->mms = bytes[3];
|
||||||
|
msg->stats = packet->stats;
|
||||||
|
msg->timestamp = packet->timestamp.TS;
|
||||||
|
|
||||||
|
size_t numWords = (totalPackedLength - SPISubHeaderLength) / 4;
|
||||||
|
msg->payload.reserve(numWords);
|
||||||
|
for(size_t offset = SPISubHeaderLength; offset < totalPackedLength; offset += 4) {
|
||||||
|
msg->payload.push_back(*reinterpret_cast<const uint32_t*>(bytes + offset));
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HardwareSPIPacket::EncodeFromMessage(const SPIMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& /*report*/) {
|
||||||
|
// Payload length is everything excluding cmdHeader (note at the beginning there is an offset of 2)
|
||||||
|
uint16_t payloadLength = static_cast<uint16_t>(
|
||||||
|
2 +
|
||||||
|
sizeof(HardwareSPIPacket) +
|
||||||
|
SPISubHeaderLength +
|
||||||
|
message.payload.size() * sizeof(uint32_t)
|
||||||
|
);
|
||||||
|
if(payloadLength % 2) {
|
||||||
|
// Pad payload to even number
|
||||||
|
payloadLength++;
|
||||||
|
}
|
||||||
|
// +1 for AA, another +1 for firmware nuance
|
||||||
|
uint16_t fullSize = 1 + sizeof(ExtendedCommandHeader) + payloadLength + 1;
|
||||||
|
uint16_t unwrappedSize = sizeof(ExtendedCommandHeader) + payloadLength; // fullSize without AA and firmware nuance
|
||||||
|
|
||||||
|
bytestream.resize(unwrappedSize, 0);
|
||||||
|
uint32_t offset = 0;
|
||||||
|
auto* cmdHeader = reinterpret_cast<ExtendedCommandHeader*>(bytestream.data() + offset);
|
||||||
|
cmdHeader->netid = static_cast<uint8_t>(Network::NetID::Main51);
|
||||||
|
cmdHeader->fullLength = fullSize;
|
||||||
|
cmdHeader->command = static_cast<uint8_t>(Command::Extended);
|
||||||
|
cmdHeader->extendedCommand = static_cast<uint16_t>(ExtendedCommand::TransmitCoreminiMessage);
|
||||||
|
cmdHeader->payloadLength = payloadLength;
|
||||||
|
|
||||||
|
offset += sizeof(ExtendedCommandHeader) + 2; // Offset of 2 between header and packet
|
||||||
|
auto* packet = reinterpret_cast<HardwareSPIPacket*>(bytestream.data() + offset);
|
||||||
|
packet->header.frameLength = static_cast<uint16_t>(SPISubHeaderLength + message.payload.size() * sizeof(uint32_t));
|
||||||
|
packet->networkID = static_cast<uint16_t>(message.network.getNetID());
|
||||||
|
packet->length = packet->header.frameLength;
|
||||||
|
packet->timestamp.IsExtended = 1;
|
||||||
|
|
||||||
|
offset += sizeof(HardwareSPIPacket);
|
||||||
|
// Write the sub header details
|
||||||
|
bytestream[offset++] = static_cast<uint8_t>(message.direction);
|
||||||
|
bytestream[offset++] = static_cast<uint8_t>(message.address & 0xFF);
|
||||||
|
bytestream[offset++] = static_cast<uint8_t>((message.address >> 8) & 0xFF);
|
||||||
|
bytestream[offset++] = static_cast<uint8_t>(message.mms);
|
||||||
|
bytestream[offset++] = static_cast<uint8_t>(message.payload.size());
|
||||||
|
|
||||||
|
// Write the words
|
||||||
|
for(uint32_t word : message.payload) {
|
||||||
|
*reinterpret_cast<uint32_t*>(bytestream.data() + offset) = word;
|
||||||
|
offset += sizeof(uint32_t);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -31,24 +31,46 @@ std::shared_ptr<WiVI::ResponseMessage> WiVI::CommandPacket::DecodeToMessage(cons
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WiVI::Command::GetAll: {
|
case WiVI::Command::GetAll: {
|
||||||
if(bytestream.size() < sizeof(WiVI::CommandPacket::GetAll))
|
if(bytestream.size() < sizeof(WiVI::CommandPacket::GetAllHeader))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const auto& getAll = *reinterpret_cast<const WiVI::CommandPacket::GetAll*>(bytestream.data());
|
const auto& getAll = *reinterpret_cast<const WiVI::CommandPacket::GetAllHeader*>(bytestream.data());
|
||||||
msg->responseTo = WiVI::Command::GetAll;
|
msg->responseTo = WiVI::Command::GetAll;
|
||||||
msg->info.emplace();
|
msg->info.emplace();
|
||||||
msg->info->sleepRequest = getAll.sleepRequest;
|
msg->info->sleepRequest = getAll.sleepRequest;
|
||||||
msg->info->connectionTimeoutMinutes = getAll.connectionTimeoutMinutes;
|
msg->info->connectionTimeoutMinutes = getAll.connectionTimeoutMinutes;
|
||||||
|
|
||||||
// Check that we have enough data for the capture infos
|
// Check that we have enough data for the capture infos
|
||||||
if(bytestream.size() < sizeof(WiVI::CommandPacket::GetAll) + (sizeof(WiVI::CaptureInfo) * getAll.numCaptureInfos))
|
size_t captureInfosSize = sizeof(WiVI::CaptureInfo) * getAll.numCaptureInfos;
|
||||||
|
if(bytestream.size() < sizeof(WiVI::CommandPacket::GetAllHeader) + captureInfosSize)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
const WiVI::CaptureInfo* const captureInfos = (const WiVI::CaptureInfo*)(bytestream.data() + sizeof(WiVI::CommandPacket::GetAllHeader));
|
||||||
msg->info->captures.resize(getAll.numCaptureInfos);
|
msg->info->captures.resize(getAll.numCaptureInfos);
|
||||||
for(uint16_t i = 0; i < getAll.numCaptureInfos; i++)
|
for(uint16_t i = 0; i < getAll.numCaptureInfos; i++)
|
||||||
msg->info->captures[i] = getAll.captureInfos[i];
|
msg->info->captures[i] = captureInfos[i];
|
||||||
|
|
||||||
|
|
||||||
|
// New field vinAvail was added - check if it is present:
|
||||||
|
if(bytestream.size() >= sizeof(WiVI::CommandPacket::GetAllHeader) + captureInfosSize + 2) {
|
||||||
|
msg->info->vinAvailable = *(bytestream.data() + sizeof(WiVI::CommandPacket::GetAllHeader) + captureInfosSize);
|
||||||
|
} else {
|
||||||
|
msg->info->vinAvailable = 0;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case WiVI::Command::GetVIN: {
|
||||||
|
if (bytestream.size() < sizeof(WiVI::CommandPacket::GetVIN))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const auto& getVIN = *reinterpret_cast<const WiVI::CommandPacket::GetVIN*>(bytestream.data());
|
||||||
|
msg->responseTo = WiVI::Command::GetVIN;
|
||||||
|
msg->vin = getVIN.VIN;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: // Unknown command response
|
default: // Unknown command response
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -78,9 +100,9 @@ std::vector<uint8_t> WiVI::CommandPacket::SetSignal::Encode(WiVI::SignalType typ
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> WiVI::CommandPacket::GetAll::Encode() {
|
std::vector<uint8_t> WiVI::CommandPacket::GetAllHeader::Encode() {
|
||||||
std::vector<uint8_t> ret(sizeof(WiVI::CommandPacket::GetAll));
|
std::vector<uint8_t> ret(sizeof(WiVI::CommandPacket::GetAllHeader));
|
||||||
auto& frame = *reinterpret_cast<WiVI::CommandPacket::GetAll*>(ret.data());
|
auto& frame = *reinterpret_cast<WiVI::CommandPacket::GetAllHeader*>(ret.data());
|
||||||
|
|
||||||
frame.header.cmd = WiVI::Command::GetAll;
|
frame.header.cmd = WiVI::Command::GetAll;
|
||||||
frame.header.length = sizeof(frame) - sizeof(frame.header);
|
frame.header.length = sizeof(frame) - sizeof(frame.header);
|
||||||
@@ -98,3 +120,15 @@ std::vector<uint8_t> WiVI::CommandPacket::ClearUploads::Encode(const std::vector
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> WiVI::CommandPacket::GetVIN::Encode()
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> ret(sizeof(WiVI::CommandPacket::GetVIN));
|
||||||
|
auto& frame = *reinterpret_cast<WiVI::CommandPacket::GetVIN*>(ret.data());
|
||||||
|
|
||||||
|
frame.header.cmd = WiVI::Command::GetVIN;
|
||||||
|
frame.header.length = sizeof(frame) - sizeof(frame.header);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+676
-22
@@ -5,6 +5,9 @@
|
|||||||
#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/fat.h"
|
#include "icsneo/disk/fat.h"
|
||||||
|
#include "icsneo/communication/message/filter/extendedresponsefilter.h"
|
||||||
|
#include "icsneo/communication/message/networkmutexmessage.h"
|
||||||
|
#include "icsneo/communication/message/transmitmessage.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable : 4996) // STL time functions
|
#pragma warning(disable : 4996) // STL time functions
|
||||||
@@ -104,15 +107,21 @@ std::string Device::describe() const {
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::enableMessagePolling() {
|
bool Device::enableMessagePolling(std::optional<MessageFilter> filter) {
|
||||||
if(isMessagePollingEnabled()) {// We are already polling
|
if(isMessagePollingEnabled()) {// We are already polling
|
||||||
report(APIEvent::Type::DeviceCurrentlyPolling, APIEvent::Severity::Error);
|
report(APIEvent::Type::DeviceCurrentlyPolling, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
messagePollingCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>([this](std::shared_ptr<Message> message) {
|
if(!filter.has_value()) {
|
||||||
|
// If no filter is provided, use a default that includes all messages
|
||||||
|
filter.emplace(MessageFilter());
|
||||||
|
filter->includeInternalInAny = true;
|
||||||
|
}
|
||||||
|
auto callback = std::make_shared<MessageCallback>(*filter, [this](std::shared_ptr<Message> message) {
|
||||||
pollingContainer.enqueue(message);
|
pollingContainer.enqueue(message);
|
||||||
enforcePollingMessageLimit();
|
enforcePollingMessageLimit();
|
||||||
}));
|
});
|
||||||
|
messagePollingCallbackID = com->addMessageCallback(callback);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,6 +209,75 @@ bool Device::refreshComponentVersions() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<VersionReport> Device::getChipVersions(bool refreshComponents) {
|
||||||
|
if(refreshComponents) {
|
||||||
|
refreshComponentVersions();
|
||||||
|
}
|
||||||
|
std::vector<VersionReport> chipVersions;
|
||||||
|
|
||||||
|
if (supportsComponentVersions()) {
|
||||||
|
const auto& compVersions = getComponentVersions();
|
||||||
|
auto disectVersion = [](uint32_t dotVersion) {
|
||||||
|
std::array<uint8_t, 4> result = {0,0,0,0};
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
if(dotVersion & 0xFF000000ul) {
|
||||||
|
result[i++] = (uint8_t)((dotVersion & 0xFF000000ul) >> 24);
|
||||||
|
result[i++] = (uint8_t)((dotVersion & 0x00FF0000ul) >> 16);
|
||||||
|
} else if(dotVersion & 0x00FF0000ul) {
|
||||||
|
result[i++] = (uint8_t)((dotVersion & 0x00FF0000ul) >> 16);
|
||||||
|
}
|
||||||
|
result[i++] = (uint8_t)((dotVersion & 0x0000FF00ul) >> 8);
|
||||||
|
result[i] = (uint8_t)((dotVersion & 0x000000FFul) >> 0);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
for(const auto& chipInfo : getChipInfo()) {
|
||||||
|
for(const auto& component : compVersions) {
|
||||||
|
if(!component.valid) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(component.identifier == (uint32_t)chipInfo.id) {
|
||||||
|
chipVersions.emplace_back();
|
||||||
|
auto& version = chipVersions.back();
|
||||||
|
|
||||||
|
auto disectedVersion = disectVersion(component.dotVersion);
|
||||||
|
version.id = chipInfo.id;
|
||||||
|
version.name = chipInfo.name;
|
||||||
|
version.major = disectedVersion[0];
|
||||||
|
version.minor = disectedVersion[1];
|
||||||
|
version.maintenance = disectedVersion[2];
|
||||||
|
version.build = disectedVersion[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const auto& appVersions = getVersions();
|
||||||
|
for(const auto& chipInfo : getChipInfo()) {
|
||||||
|
if(!chipInfo.defaultEnabled) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(appVersions.size() <= chipInfo.versionIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto& appVer = appVersions[chipInfo.versionIndex];
|
||||||
|
if(!appVer) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
chipVersions.emplace_back();
|
||||||
|
auto& version = chipVersions.back();
|
||||||
|
|
||||||
|
version.id = chipInfo.id;
|
||||||
|
version.name = chipInfo.name;
|
||||||
|
version.major = appVer->major;
|
||||||
|
version.minor = appVer->minor;
|
||||||
|
version.maintenance = 0;
|
||||||
|
version.build = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chipVersions;
|
||||||
|
}
|
||||||
|
|
||||||
bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
||||||
if(!com) {
|
if(!com) {
|
||||||
report(APIEvent::Type::Unknown, APIEvent::Severity::Error);
|
report(APIEvent::Type::Unknown, APIEvent::Severity::Error);
|
||||||
@@ -277,7 +355,7 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
|||||||
std::condition_variable heartbeatCV;
|
std::condition_variable heartbeatCV;
|
||||||
std::mutex receivedMessageMutex;
|
std::mutex receivedMessageMutex;
|
||||||
bool receivedMessage = false;
|
bool receivedMessage = false;
|
||||||
auto messageReceivedCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>(filter, [&](std::shared_ptr<Message> message) {
|
auto messageReceivedCallbackID = com->addMessageCallback(std::make_shared<MessageCallback>(filter, [&](std::shared_ptr<Message>) {
|
||||||
{
|
{
|
||||||
std::scoped_lock<std::mutex> lk(receivedMessageMutex);
|
std::scoped_lock<std::mutex> lk(receivedMessageMutex);
|
||||||
receivedMessage = true;
|
receivedMessage = true;
|
||||||
@@ -335,6 +413,38 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::reconnect(std::chrono::milliseconds timeout, std::chrono::milliseconds interval) {
|
||||||
|
if(isOnline()) {
|
||||||
|
goOffline();
|
||||||
|
}
|
||||||
|
bool readsArePaused = com->readsArePaused();
|
||||||
|
if(!com->close()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<FoundDevice> foundDevices;
|
||||||
|
auto findAll = com->driver->getFinder();
|
||||||
|
auto start = std::chrono::system_clock::now();
|
||||||
|
while((std::chrono::system_clock::now() - start) < timeout) {
|
||||||
|
foundDevices.clear();
|
||||||
|
findAll(foundDevices);
|
||||||
|
for(auto& fd : foundDevices) {
|
||||||
|
if(!memcmp(fd.serial, data.serial, 6)) {
|
||||||
|
com->driver = fd.makeDriver(report, getWritableNeoDevice());
|
||||||
|
if(readsArePaused) {
|
||||||
|
// Pause reads again
|
||||||
|
com->pauseReads();
|
||||||
|
}
|
||||||
|
return com->open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
APIEvent::Type Device::attemptToBeginCommunication() {
|
APIEvent::Type Device::attemptToBeginCommunication() {
|
||||||
versions.clear();
|
versions.clear();
|
||||||
|
|
||||||
@@ -414,7 +524,8 @@ bool Device::disableLogData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Device::goOnline() {
|
bool Device::goOnline() {
|
||||||
if(!enableNetworkCommunication(true))
|
static constexpr uint32_t onlineTimeoutMs = 5000;
|
||||||
|
if(!enableNetworkCommunication(true, onlineTimeoutMs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto startTime = std::chrono::system_clock::now();
|
auto startTime = std::chrono::system_clock::now();
|
||||||
@@ -443,13 +554,46 @@ bool Device::goOnline() {
|
|||||||
return false;
|
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
|
||||||
|
keeponline = std::make_unique<Periodic>([this] { return enableNetworkCommunication(true, onlineTimeoutMs); }, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
||||||
|
|
||||||
online = true;
|
online = true;
|
||||||
|
|
||||||
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() {
|
||||||
|
keeponline.reset();
|
||||||
|
|
||||||
|
if(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()) {
|
||||||
@@ -780,9 +924,12 @@ bool Device::transmit(std::shared_ptr<Frame> frame) {
|
|||||||
return transmitStatusFromExtension;
|
return transmitStatusFromExtension;
|
||||||
|
|
||||||
std::vector<uint8_t> packet;
|
std::vector<uint8_t> packet;
|
||||||
|
if(assignedClientId.has_value()) {
|
||||||
|
packet = TransmitMessage::EncodeFromMessage(frame, *assignedClientId, report);
|
||||||
|
return packet.size() && com->sendCommand(ExtendedCommand::TransmitMessage, packet);
|
||||||
|
}
|
||||||
if(!com->encoder->encode(*com->packetizer, packet, frame))
|
if(!com->encoder->encode(*com->packetizer, packet, frame))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return com->sendPacket(packet);
|
return com->sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1164,7 +1311,7 @@ void Device::wiviThreadBody() {
|
|||||||
|
|
||||||
// Use the command GetAll to get a WiVI::Info structure from the device
|
// Use the command GetAll to get a WiVI::Info structure from the device
|
||||||
const auto generic = com->waitForMessageSync([this]() {
|
const auto generic = com->waitForMessageSync([this]() {
|
||||||
return com->sendCommand(Command::WiVICommand, WiVI::CommandPacket::GetAll::Encode());
|
return com->sendCommand(Command::WiVICommand, WiVI::CommandPacket::GetAllHeader::Encode());
|
||||||
}, filter, std::chrono::milliseconds(1000));
|
}, filter, std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
if(!generic || generic->type != Message::Type::WiVICommandResponse) {
|
if(!generic || generic->type != Message::Type::WiVICommandResponse) {
|
||||||
@@ -1276,6 +1423,22 @@ void Device::wiviThreadBody() {
|
|||||||
for(auto& cb : sleepRequestedCallbacks)
|
for(auto& cb : sleepRequestedCallbacks)
|
||||||
cb.second = false;
|
cb.second = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process vin available callbacks
|
||||||
|
if (resp->info->vinAvailable & 1) {
|
||||||
|
for (auto& cb : vinAvailableCallbacks) {
|
||||||
|
if (!cb.second && cb.first) {
|
||||||
|
cb.second = true;
|
||||||
|
lk.unlock();
|
||||||
|
try {
|
||||||
|
cb.first();
|
||||||
|
} catch(...) {
|
||||||
|
report(APIEvent::Type::Unknown, APIEvent::Severity::Error);
|
||||||
|
}
|
||||||
|
lk.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1450,6 +1613,110 @@ bool Device::allowSleep(bool remoteWakeup) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lifetime Device::addVINAvailableCallback(VINAvailableCallback cb)
|
||||||
|
{
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!supportsWiVI()) {
|
||||||
|
report(APIEvent::Type::WiVINotSupported, APIEvent::Severity::Error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lk(wiviMutex);
|
||||||
|
if(!wiviThread.joinable()) {
|
||||||
|
// Start the thread
|
||||||
|
stopWiVIThread = false;
|
||||||
|
wiviThread = std::thread([this]() { wiviThreadBody(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t idx = 0;
|
||||||
|
for(; idx < vinAvailableCallbacks.size(); idx++) {
|
||||||
|
if(!vinAvailableCallbacks[idx].first) // Empty space (previously erased callback)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(idx == vinAvailableCallbacks.size()) // Create a new space
|
||||||
|
vinAvailableCallbacks.emplace_back(std::move(cb), false);
|
||||||
|
else
|
||||||
|
vinAvailableCallbacks[idx] = { std::move(cb), false };
|
||||||
|
|
||||||
|
// Cleanup function to remove this sleep requested callback
|
||||||
|
return Lifetime([this, idx]() {
|
||||||
|
// TODO: Hold a weak ptr to the `this` instead of relying on the user to keep `this` valid
|
||||||
|
std::unique_lock<std::mutex> lk2(wiviMutex);
|
||||||
|
vinAvailableCallbacks[idx].first = VINAvailableCallback();
|
||||||
|
stopWiVIThreadIfNecessary(std::move(lk2));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<bool> Device::isVINEnabled() const
|
||||||
|
{
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!supportsWiVI()) {
|
||||||
|
report(APIEvent::Type::WiVINotSupported, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>(Message::Type::WiVICommandResponse);
|
||||||
|
// Hold this lock so the WiVI stack doesn't issue a WiVICommand at the same time as us
|
||||||
|
std::lock_guard<std::mutex> lk(wiviMutex);
|
||||||
|
const auto generic = com->waitForMessageSync([this]() {
|
||||||
|
return com->sendCommand(Command::WiVICommand, WiVI::CommandPacket::GetSignal::Encode(WiVI::SignalType::VINEnabled));
|
||||||
|
}, filter, std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
|
if(!generic || generic->type != Message::Type::WiVICommandResponse) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto resp = std::static_pointer_cast<WiVI::ResponseMessage>(generic);
|
||||||
|
if(!resp->success || !resp->value.has_value()) {
|
||||||
|
report(APIEvent::Type::ValueNotYetPresent, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *resp->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> Device::getVIN() const
|
||||||
|
{
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!supportsWiVI()) {
|
||||||
|
report(APIEvent::Type::WiVINotSupported, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>(Message::Type::WiVICommandResponse);
|
||||||
|
std::lock_guard<std::mutex> lk(wiviMutex);
|
||||||
|
const auto generic = com->waitForMessageSync([this]() {
|
||||||
|
return com->sendCommand(Command::WiVICommand, WiVI::CommandPacket::GetVIN::Encode());
|
||||||
|
}, filter, std::chrono::milliseconds(1000));
|
||||||
|
|
||||||
|
if(!generic || generic->type != Message::Type::WiVICommandResponse) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto resp = std::static_pointer_cast<WiVI::ResponseMessage>(generic);
|
||||||
|
if(!resp->success || !resp->vin.has_value()) {
|
||||||
|
report(APIEvent::Type::ValueNotYetPresent, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *resp->vin;
|
||||||
|
}
|
||||||
|
|
||||||
void Device::scriptStatusThreadBody()
|
void Device::scriptStatusThreadBody()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(scriptStatusMutex);
|
std::unique_lock<std::mutex> lk(scriptStatusMutex);
|
||||||
@@ -1736,6 +2003,15 @@ void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
|||||||
case Message::Type::RawMessage: {
|
case Message::Type::RawMessage: {
|
||||||
auto rawMessage = std::static_pointer_cast<RawMessage>(message);
|
auto rawMessage = std::static_pointer_cast<RawMessage>(message);
|
||||||
switch(rawMessage->network.getNetID()) {
|
switch(rawMessage->network.getNetID()) {
|
||||||
|
case Network::NetID::Device: {
|
||||||
|
// Device is not guaranteed to be a CANMessage, it might be a RawMessage
|
||||||
|
// if it couldn't be decoded to a CANMessage. We only care about the
|
||||||
|
// CANMessage decoding right now.
|
||||||
|
auto canmsg = std::dynamic_pointer_cast<CANMessage>(message);
|
||||||
|
if(canmsg)
|
||||||
|
handleNeoVIMessage(std::move(canmsg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Network::NetID::DeviceStatus:
|
case Network::NetID::DeviceStatus:
|
||||||
// Device Status format is unique per device, so the devices need to decode it themselves
|
// Device Status format is unique per device, so the devices need to decode it themselves
|
||||||
handleDeviceStatus(rawMessage);
|
handleDeviceStatus(rawMessage);
|
||||||
@@ -1745,15 +2021,6 @@ void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Message::Type::Frame: {
|
|
||||||
// Device is not guaranteed to be a CANMessage, it might be a RawMessage
|
|
||||||
// if it couldn't be decoded to a CANMessage. We only care about the
|
|
||||||
// CANMessage decoding right now.
|
|
||||||
auto canmsg = std::dynamic_pointer_cast<CANMessage>(message);
|
|
||||||
if(canmsg)
|
|
||||||
handleNeoVIMessage(std::move(canmsg));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
forEachExtension([&](const std::shared_ptr<DeviceExtension>& ext) {
|
forEachExtension([&](const std::shared_ptr<DeviceExtension>& ext) {
|
||||||
@@ -1832,7 +2099,7 @@ std::optional<EthPhyMessage> Device::sendEthPhyMsg(const EthPhyMessage& message,
|
|||||||
HardwareEthernetPhyRegisterPacket::EncodeFromMessage(message, bytes, report);
|
HardwareEthernetPhyRegisterPacket::EncodeFromMessage(message, bytes, report);
|
||||||
std::shared_ptr<Message> response = com->waitForMessageSync(
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
[this, bytes](){ return com->sendCommand(Command::PHYControlRegisters, bytes); },
|
[this, bytes](){ return com->sendCommand(Command::PHYControlRegisters, bytes); },
|
||||||
std::make_shared<MessageFilter>(Network::NetID::EthPHYControl), timeout);
|
std::make_shared<MessageFilter>(Message::Type::EthernetPhyRegister), timeout);
|
||||||
|
|
||||||
if(!response) {
|
if(!response) {
|
||||||
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
@@ -2235,6 +2502,61 @@ bool Device::clearAllLiveData() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::setValueLiveData(std::shared_ptr<LiveDataSetValueMessage> message) {
|
||||||
|
if(!supportsLiveData()) {
|
||||||
|
report(APIEvent::Type::LiveDataNotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if((message->args.size() != message->values.size()) || message->args.empty()) {
|
||||||
|
report(APIEvent::Type::LiveDataInvalidArgument, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> bytes;
|
||||||
|
if(!com->encoder->encode(*com->packetizer, bytes, message)) {
|
||||||
|
report(APIEvent::Type::LiveDataEncoderError, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this, &bytes](){ return com->sendPacket(bytes); },
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::LiveData));
|
||||||
|
|
||||||
|
if(response) {
|
||||||
|
auto statusMsg = std::dynamic_pointer_cast<LiveDataStatusMessage>(response);
|
||||||
|
if(statusMsg && statusMsg->requestedCommand == message->cmd) {
|
||||||
|
switch(statusMsg->status) {
|
||||||
|
case LiveDataStatus::SUCCESS:
|
||||||
|
return true;
|
||||||
|
case LiveDataStatus::ERR_DUPLICATE:
|
||||||
|
case LiveDataStatus::ERR_HANDLE:
|
||||||
|
{
|
||||||
|
report(APIEvent::Type::LiveDataInvalidHandle, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case LiveDataStatus::ERR_FULL:
|
||||||
|
{
|
||||||
|
report(APIEvent::Type::LiveDataMaxSignalsReached, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case LiveDataStatus::ERR_UNKNOWN_COMMAND:
|
||||||
|
{
|
||||||
|
report(APIEvent::Type::LiveDataCommandFailed, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
report(APIEvent::Type::LiveDataNoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Device::readVSA(const VSAExtractionSettings& extractionSettings) {
|
bool Device::readVSA(const VSAExtractionSettings& extractionSettings) {
|
||||||
if(isOnline()) {
|
if(isOnline()) {
|
||||||
goOffline();
|
goOffline();
|
||||||
@@ -2731,7 +3053,6 @@ std::optional<bool> Device::isVSAOverlapped(std::optional<VSAMetadata> optMetada
|
|||||||
lastSectorRecord->getTimestamp() > metadata.coreMiniTimestamp;
|
lastSectorRecord->getTimestamp() > metadata.coreMiniTimestamp;
|
||||||
} else if(lastSectorStatus == VSAParser::RecordParseStatus::NotARecordStart) {
|
} else if(lastSectorStatus == VSAParser::RecordParseStatus::NotARecordStart) {
|
||||||
// The vsa record buffer is not full
|
// The vsa record buffer is not full
|
||||||
report(APIEvent::Type::VSAOtherError, APIEvent::Severity::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
report(APIEvent::Type::VSABufferFormatError, APIEvent::Severity::Error);
|
report(APIEvent::Type::VSABufferFormatError, APIEvent::Severity::Error);
|
||||||
@@ -3246,10 +3567,18 @@ std::optional<uint64_t> Device::vsaReadLogicalDisk(uint64_t pos, uint8_t* into,
|
|||||||
return readLogicalDisk(pos, into, amount);
|
return readLogicalDisk(pos, into, amount);
|
||||||
}
|
}
|
||||||
uint64_t firstReadAmount = diskSize - pos;
|
uint64_t firstReadAmount = diskSize - pos;
|
||||||
if(!readLogicalDisk(pos, into, firstReadAmount)) {
|
uint64_t bytesRead = 0;
|
||||||
|
if(auto optBytesReadFirst = readLogicalDisk(pos, into, firstReadAmount)) {
|
||||||
|
bytesRead = *optBytesReadFirst;
|
||||||
|
} else {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return readLogicalDisk(VSA::RecordStartOffset, into + firstReadAmount, amount - firstReadAmount);
|
if(auto optBytesReadSecond = readLogicalDisk(VSA::RecordStartOffset, into + firstReadAmount, amount - firstReadAmount)) {
|
||||||
|
bytesRead += *optBytesReadSecond;
|
||||||
|
} else {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::dispatchVSAMessages(VSAParser& parser) {
|
bool Device::dispatchVSAMessages(VSAParser& parser) {
|
||||||
@@ -3420,15 +3749,340 @@ bool Device::writeMACsecConfig(const MACsecMessage& message, uint16_t binaryInde
|
|||||||
return writeBinaryFile(raw, binaryIndex);
|
return writeBinaryFile(raw, binaryIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::enableNetworkCommunication(bool enable) {
|
bool Device::enableNetworkCommunication(bool enable, uint32_t timeout) {
|
||||||
bool sendMsg = false;
|
bool sendMsg = false;
|
||||||
if(!com->driver->enableCommunication(enable, sendMsg)) {
|
if(!com->driver->enableCommunication(enable, sendMsg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(sendMsg) {
|
if(sendMsg) {
|
||||||
if(!com->sendCommand(Command::EnableNetworkCommunication, enable)) {
|
const uint8_t* i = (uint8_t*)&timeout;
|
||||||
|
if(!com->sendCommand(Command::EnableNetworkCommunication, {enable, 0, 0, 0, i[0], i[1], i[2], i[3]})) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool Device::formatDisk(const DiskDetails& config, const DiskFormatProgress& handler, std::chrono::milliseconds interval) {
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
struct DiskFormatProgressResponse {
|
||||||
|
uint16_t state;
|
||||||
|
uint64_t sectorsRemaining;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
auto diskCount = getDiskCount();
|
||||||
|
|
||||||
|
if(!diskCount) {
|
||||||
|
report(APIEvent::Type::DiskFormatNotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(config.disks.size() != diskCount) {
|
||||||
|
report(APIEvent::Type::DiskFormatInvalidCount, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = DiskDetails::Encode(config);
|
||||||
|
if(!com->sendCommand(ExtendedCommand::DiskFormatStart, payload)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t sectorsFormatted = 0;
|
||||||
|
uint64_t sectorsTotal = 0;
|
||||||
|
uint16_t lastState = 1;
|
||||||
|
do {
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this](){
|
||||||
|
return com->sendCommand(ExtendedCommand::DiskFormatProgress, {});
|
||||||
|
},
|
||||||
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::DiskFormatProgress),
|
||||||
|
std::chrono::milliseconds(200)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extResponse = std::dynamic_pointer_cast<ExtendedResponseMessage>(response);
|
||||||
|
if(!extResponse) {
|
||||||
|
// Should never happen
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(extResponse->data.size() < sizeof(DiskFormatProgressResponse)) {
|
||||||
|
report(APIEvent::Type::BufferInsufficient, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* progress = reinterpret_cast<DiskFormatProgressResponse*>(extResponse->data.data());
|
||||||
|
lastState = progress->state;
|
||||||
|
|
||||||
|
if(sectorsTotal == 0) {
|
||||||
|
sectorsTotal = progress->sectorsRemaining;
|
||||||
|
} else {
|
||||||
|
sectorsFormatted = sectorsTotal - progress->sectorsRemaining;
|
||||||
|
|
||||||
|
if(handler) {
|
||||||
|
auto directive = handler(sectorsFormatted, sectorsTotal);
|
||||||
|
|
||||||
|
if(directive == DiskFormatDirective::Stop) {
|
||||||
|
return com->sendCommand(ExtendedCommand::DiskFormatCancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(interval);
|
||||||
|
} while(lastState);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::forceDiskConfigUpdate(const DiskDetails& config) {
|
||||||
|
auto diskCount = getDiskCount();
|
||||||
|
|
||||||
|
if(!diskCount) {
|
||||||
|
report(APIEvent::Type::DiskFormatNotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(config.disks.size() != diskCount) {
|
||||||
|
report(APIEvent::Type::DiskFormatInvalidCount, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return com->sendCommand(ExtendedCommand::DiskFormatUpdate, DiskDetails::Encode(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DiskDetails> Device::getDiskDetails(std::chrono::milliseconds timeout) {
|
||||||
|
if(!supportsDiskFormatting()) {
|
||||||
|
report(APIEvent::Type::DiskFormatNotSupported, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isOpen()) {
|
||||||
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this](){
|
||||||
|
return com->sendCommand(ExtendedCommand::GetDiskDetails, {});
|
||||||
|
},
|
||||||
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::GetDiskDetails),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extResponse = std::dynamic_pointer_cast<ExtendedResponseMessage>(response);
|
||||||
|
if(!extResponse) {
|
||||||
|
// Should never happen
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DiskDetails::Decode(extResponse->data, getDiskCount(), report);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
if(!assignedClientId.has_value()) {
|
||||||
|
report(APIEvent::Type::RequiredParameterNull, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto timeout = std::chrono::milliseconds(250);
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = NetworkMutexMessage::EncodeArgumentsForLock(*assignedClientId, type, priority, ttlMs, networks, report);
|
||||||
|
|
||||||
|
std::optional<int> handle = std::nullopt;
|
||||||
|
if(on_event) {
|
||||||
|
handle.emplace(addMessageCallback(
|
||||||
|
std::make_shared<MessageCallback>(
|
||||||
|
on_event,
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::NetworkMutex)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this, payload](){
|
||||||
|
return com->sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::ProtobufAPI),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extResponse = std::dynamic_pointer_cast<ExtendedResponseMessage>(response);
|
||||||
|
if(!extResponse) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(extResponse->response != ExtendedResponse::OK && extResponse->response != ExtendedResponse::OperationPending) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::unlockNetworks(const std::set<Network::NetID>& networks)
|
||||||
|
{
|
||||||
|
if(!supportsNetworkMutex()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!assignedClientId.has_value()) {
|
||||||
|
report(APIEvent::Type::RequiredParameterNull, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
constexpr auto timeout = std::chrono::milliseconds(250);
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = NetworkMutexMessage::EncodeArgumentsForUnlock(*assignedClientId, networks, report);
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this, payload](){
|
||||||
|
return com->sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::ProtobufAPI),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extResponse = std::dynamic_pointer_cast<ExtendedResponseMessage>(response);
|
||||||
|
if(!extResponse) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(extResponse->response != ExtendedResponse::OK) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<NetworkMutexMessage> Device::getNetworkMutexStatus(Network::NetID network)
|
||||||
|
{
|
||||||
|
if(!supportsNetworkMutex()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto timeout = std::chrono::milliseconds(1000);
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = NetworkMutexMessage::EncodeArgumentsForStatus(network, report);
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this, payload](){
|
||||||
|
return com->sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::NetworkMutex),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
return std::dynamic_pointer_cast<NetworkMutexMessage>(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[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()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
if(!assignedClientId.has_value()) {
|
||||||
|
report(APIEvent::Type::RequiredParameterNull, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
constexpr auto timeout = std::chrono::milliseconds(1000);
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = NetworkMutexMessage::EncodeArgumentsForLockAll(*assignedClientId, type, priority, ttlMs, report);
|
||||||
|
|
||||||
|
int handle = addMessageCallback(
|
||||||
|
std::make_shared<MessageCallback>(
|
||||||
|
on_event,
|
||||||
|
std::make_shared<MessageFilter>(Message::Type::NetworkMutex)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this, payload](){
|
||||||
|
return com->sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::ProtobufAPI),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extResponse = std::dynamic_pointer_cast<ExtendedResponseMessage>(response);
|
||||||
|
if(!extResponse) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(extResponse->response != ExtendedResponse::OK && extResponse->response != ExtendedResponse::OperationPending) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_optional(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::unlockAllNetworks()
|
||||||
|
{
|
||||||
|
if(!supportsNetworkMutex()) {
|
||||||
|
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!assignedClientId.has_value()) {
|
||||||
|
report(APIEvent::Type::RequiredParameterNull, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
constexpr auto timeout = std::chrono::milliseconds(1000);
|
||||||
|
|
||||||
|
std::vector<uint8_t> payload = NetworkMutexMessage::EncodeArgumentsForUnlockAll(*assignedClientId, report);
|
||||||
|
|
||||||
|
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||||
|
[this, payload](){
|
||||||
|
return com->sendCommand(ExtendedCommand::ProtobufAPI, payload);
|
||||||
|
},
|
||||||
|
std::make_shared<ExtendedResponseFilter>(ExtendedCommand::ProtobufAPI),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!response) {
|
||||||
|
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto extResponse = std::dynamic_pointer_cast<ExtendedResponseMessage>(response);
|
||||||
|
if(!extResponse) {
|
||||||
|
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(extResponse->response != ExtendedResponse::OK) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
+24
-25
@@ -16,12 +16,8 @@
|
|||||||
#include "icsneo/platform/cdcacm.h"
|
#include "icsneo/platform/cdcacm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ICSNEO_ENABLE_FTDI
|
#ifdef ICSNEO_ENABLE_DXX
|
||||||
#include "icsneo/platform/ftdi.h"
|
#include "icsneo/platform/dxx.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ICSNEO_ENABLE_FTD3XX
|
|
||||||
#include "icsneo/platform/ftd3xx.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ICSNEO_ENABLE_TCP
|
#ifdef ICSNEO_ENABLE_TCP
|
||||||
@@ -39,15 +35,6 @@ static void makeIfSerialMatches(const FoundDevice& dev, std::vector<std::shared_
|
|||||||
into.push_back(std::make_shared<T>(dev));
|
into.push_back(std::make_shared<T>(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static void makeIfPIDMatches(const FoundDevice& dev, std::vector<std::shared_ptr<Device>>& into) {
|
|
||||||
// Relies on the subclass to have a `static constexpr uint16_t PRODUCT_ID = 0x1111`
|
|
||||||
// and also a public constructor `T(const FoundDevice& dev)`
|
|
||||||
// Use macro ICSNEO_FINDABLE_DEVICE_BY_PID() to create these
|
|
||||||
if(dev.productId == T::PRODUCT_ID)
|
|
||||||
into.push_back(std::make_shared<T>(dev));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void makeIfSerialRangeMatches(const FoundDevice& dev, std::vector<std::shared_ptr<Device>>& into) {
|
static void makeIfSerialRangeMatches(const FoundDevice& dev, std::vector<std::shared_ptr<Device>>& into) {
|
||||||
// Relies on the subclass to have
|
// Relies on the subclass to have
|
||||||
@@ -83,12 +70,8 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
CDCACM::Find(newDriverFoundDevices);
|
CDCACM::Find(newDriverFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ICSNEO_ENABLE_FTDI
|
#ifdef ICSNEO_ENABLE_DXX
|
||||||
FTDI::Find(newDriverFoundDevices);
|
DXX::Find(newDriverFoundDevices);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ICSNEO_ENABLE_FTD3XX
|
|
||||||
FTD3XX::Find(newDriverFoundDevices);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +130,7 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __NEOVIFIRE_H_
|
#ifdef __NEOVIFIRE_H_
|
||||||
makeIfPIDMatches<NeoVIFIRE>(dev, newFoundDevices);
|
makeIfSerialRangeMatches<NeoVIFIRE>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __NEOVIFIRE2_H_
|
#ifdef __NEOVIFIRE2_H_
|
||||||
@@ -162,16 +145,20 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
makeIfSerialMatches<NeoVIFIRE3FlexRay>(dev, newFoundDevices);
|
makeIfSerialMatches<NeoVIFIRE3FlexRay>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __NEOVIFIRE3T1SLIN_H_
|
||||||
|
makeIfSerialMatches<NeoVIFIRE3T1SLIN>(dev, newFoundDevices);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __NEOVIRED2_H_
|
#ifdef __NEOVIRED2_H_
|
||||||
makeIfSerialMatches<NeoVIRED2>(dev, newFoundDevices);
|
makeIfSerialMatches<NeoVIRED2>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __NEOVIION_H_
|
#ifdef __NEOVIION_H_
|
||||||
makeIfPIDMatches<NeoVIION>(dev, newFoundDevices);
|
makeIfSerialMatches<NeoVIION>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __NEOVIPLASMA_H_
|
#ifdef __NEOVIPLASMA_H_
|
||||||
makeIfPIDMatches<NeoVIPLASMA>(dev, newFoundDevices);
|
makeIfSerialMatches<NeoVIPLASMA>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __RADA2B_H_
|
#ifdef __RADA2B_H_
|
||||||
@@ -238,6 +225,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
makeIfSerialMatches<RADMoon3>(dev, newFoundDevices);
|
makeIfSerialMatches<RADMoon3>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __RADGEMINI_H_
|
||||||
|
makeIfSerialMatches<RADGemini>(dev, newFoundDevices);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __RADMOONDUO_H_
|
#ifdef __RADMOONDUO_H_
|
||||||
makeIfSerialMatches<RADMoonDuo>(dev, newFoundDevices);
|
makeIfSerialMatches<RADMoonDuo>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
@@ -255,7 +246,7 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN3_H_
|
#ifdef __VALUECAN3_H_
|
||||||
makeIfPIDMatches<ValueCAN3>(dev, newFoundDevices);
|
makeIfSerialRangeMatches<ValueCAN3>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN4_1_H_
|
#ifdef __VALUECAN4_1_H_
|
||||||
@@ -333,6 +324,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
|||||||
NeoVIFIRE3FlexRay::DEVICE_TYPE,
|
NeoVIFIRE3FlexRay::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __NEOVIFIRE3T1SLIN_H_
|
||||||
|
NeoVIFIRE3T1SLIN::DEVICE_TYPE,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __NEOVIION_H_
|
#ifdef __NEOVIION_H_
|
||||||
NeoVIION::DEVICE_TYPE,
|
NeoVIION::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
@@ -393,6 +388,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
|||||||
RADMoon3::DEVICE_TYPE,
|
RADMoon3::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __RADGEMINI_H_
|
||||||
|
RADGemini::DEVICE_TYPE,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __RADMOONDUO_H_
|
#ifdef __RADMOONDUO_H_
|
||||||
RADMoonDuo::DEVICE_TYPE,
|
RADMoonDuo::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,16 +3,6 @@
|
|||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
void FlexRay::Controller::_setStatus(std::shared_ptr<FlexRayControlMessage> msg) {
|
|
||||||
std::lock_guard<std::mutex> lk(statusLock);
|
|
||||||
status = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<FlexRayControlMessage> FlexRay::Controller::getStatus() const {
|
|
||||||
std::lock_guard<std::mutex> lk(statusLock);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<const FlexRay::Cluster::Configuration&, const FlexRay::Controller::Configuration&> FlexRay::Controller::getConfiguration() const {
|
std::pair<const FlexRay::Cluster::Configuration&, const FlexRay::Controller::Configuration&> FlexRay::Controller::getConfiguration() const {
|
||||||
return { clusterConfig, controllerConfig };
|
return { clusterConfig, controllerConfig };
|
||||||
}
|
}
|
||||||
@@ -74,7 +64,7 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
|||||||
((controllerConfig.KeySlotUsedForStartup & 0x1) << 8) | // TXST
|
((controllerConfig.KeySlotUsedForStartup & 0x1) << 8) | // TXST
|
||||||
((controllerConfig.KeySlotUsedForSync & 0x1) << 9) | // TXSY
|
((controllerConfig.KeySlotUsedForSync & 0x1) << 9) | // TXSY
|
||||||
((clusterConfig.ColdStartAttempts & 0x1f) << 11) | // CSA
|
((clusterConfig.ColdStartAttempts & 0x1f) << 11) | // CSA
|
||||||
((controllerConfig.AllowPassiveToActiveCyclePairs & 0x1f) << 16) | // PTA
|
((controllerConfig.AllowPassiveToActiveCyclePairs & 0x1F) << 16) | // PTA
|
||||||
((controllerConfig.WakeupOnChannelB & 0x1) << 21) | // WUCS
|
((controllerConfig.WakeupOnChannelB & 0x1) << 21) | // WUCS
|
||||||
((controllerConfig.KeySlotOnlyEnabled & 0x1) << 22) | // TSM
|
((controllerConfig.KeySlotOnlyEnabled & 0x1) << 22) | // TSM
|
||||||
((controllerConfig.AllowHaltDueToClock & 0x1) << 23) | // HCSE
|
((controllerConfig.AllowHaltDueToClock & 0x1) << 23) | // HCSE
|
||||||
@@ -85,99 +75,100 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::SUCC2,
|
registerWrites.push_back({ ERAYRegister::SUCC2,
|
||||||
((controllerConfig.ListenTimeout & 0x1fffff)) |
|
((controllerConfig.ListenTimeout & 0x1FFFFF)) |
|
||||||
((clusterConfig.ListenNoiseMacroticks - 1) << 24)
|
(((clusterConfig.ListenNoiseMacroticks - 1) & 0xF) << 24)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::SUCC3,
|
registerWrites.push_back({ ERAYRegister::SUCC3,
|
||||||
(clusterConfig.MaxWithoutClockCorrectionPassive & 0xF) |
|
(clusterConfig.MaxWithoutClockCorrectionPassive & 0xF) |
|
||||||
((clusterConfig.MaxWithoutClockCorrectionFatal) << 4)
|
((clusterConfig.MaxWithoutClockCorrectionFatal & 0xF) << 4)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::NEMC,
|
registerWrites.push_back({ ERAYRegister::NEMC,
|
||||||
clusterConfig.NetworkManagementVectorLengthBytes
|
clusterConfig.NetworkManagementVectorLengthBytes & 0xF
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::PRTC1,
|
registerWrites.push_back({ ERAYRegister::PRTC1,
|
||||||
(clusterConfig.TransmissionStartSequenceDurationBits & 0xF) |
|
(clusterConfig.TransmissionStartSequenceDurationBits & 0xF) |
|
||||||
((clusterConfig.CASRxLowMax & 0x3F) << 4) |
|
((clusterConfig.CASRxLowMax & 0x1F) << 4) |
|
||||||
|
(0x1 << 10) | // Most significant bit of CASRxLowMax. Hardwired to 1 and cannot be modified
|
||||||
((clusterConfig.StrobePointPosition & 0x3) << 12) |
|
((clusterConfig.StrobePointPosition & 0x3) << 12) |
|
||||||
((clusterConfig.Speed & 0x3) << 14) |
|
((clusterConfig.Speed & 0x3) << 14) |
|
||||||
((clusterConfig.WakeupRxWindowBits & 0x1ff) << 16) |
|
((clusterConfig.WakeupRxWindowBits & 0x1FF) << 16) |
|
||||||
((controllerConfig.WakeupPattern) << 26)
|
((controllerConfig.WakeupPattern & 0x3F) << 26)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::PRTC2,
|
registerWrites.push_back({ ERAYRegister::PRTC2,
|
||||||
(clusterConfig.WakeupRxIdleBits) |
|
(clusterConfig.WakeupRxIdleBits & 0x3F) |
|
||||||
((clusterConfig.WakeupRxLowBits) << 8) |
|
((clusterConfig.WakeupRxLowBits & 0x3F) << 8) |
|
||||||
((clusterConfig.WakeupTxIdleBits) << 16) |
|
((clusterConfig.WakeupTxIdleBits) << 16) |
|
||||||
((clusterConfig.WakeupTxActiveBits) << 24)
|
((clusterConfig.WakeupTxActiveBits & 0x3F) << 24)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::MHDC,
|
registerWrites.push_back({ ERAYRegister::MHDC,
|
||||||
(clusterConfig.PayloadLengthOfStaticSlotInWords) |
|
(clusterConfig.PayloadLengthOfStaticSlotInWords & 0x7F) |
|
||||||
((controllerConfig.LatestTxMinislot) << 16)
|
((controllerConfig.LatestTxMinislot & 0x1FFF) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC1,
|
registerWrites.push_back({ ERAYRegister::GTUC1,
|
||||||
controllerConfig.MicroPerCycle
|
controllerConfig.MicroPerCycle & 0xFFFFF
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC2,
|
registerWrites.push_back({ ERAYRegister::GTUC2,
|
||||||
(clusterConfig.SyncFrameIDCountMax << 16) |
|
(clusterConfig.SyncFrameIDCountMax << 16) |
|
||||||
clusterConfig.MacroticksPerCycle
|
(clusterConfig.MacroticksPerCycle & 0x3FFF)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC3,
|
registerWrites.push_back({ ERAYRegister::GTUC3,
|
||||||
(controllerConfig.MicroInitialOffsetA) |
|
(controllerConfig.MicroInitialOffsetA) |
|
||||||
((controllerConfig.MicroInitialOffsetB) << 8) |
|
((controllerConfig.MicroInitialOffsetB) << 8) |
|
||||||
((controllerConfig.MacroInitialOffsetA) << 16) |
|
((controllerConfig.MacroInitialOffsetA & 0x7F) << 16) |
|
||||||
((controllerConfig.MacroInitialOffsetB) << 24)
|
((controllerConfig.MacroInitialOffsetB & 0x7F) << 24)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC4,
|
registerWrites.push_back({ ERAYRegister::GTUC4,
|
||||||
((clusterConfig.MacroticksPerCycle - clusterConfig.NetworkIdleTimeMacroticks - 1) & 0xFFFF) |
|
((clusterConfig.MacroticksPerCycle - clusterConfig.NetworkIdleTimeMacroticks - 1) & 0x3FFF) |
|
||||||
((clusterConfig.OffsetCorrectionStartMacroticks - 1) << 16)
|
(((clusterConfig.OffsetCorrectionStartMacroticks - 1) & 0x3FFF) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC5,
|
registerWrites.push_back({ ERAYRegister::GTUC5,
|
||||||
controllerConfig.DelayCompensationAMicroticks |
|
controllerConfig.DelayCompensationAMicroticks |
|
||||||
(controllerConfig.DelayCompensationBMicroticks << 8) |
|
(controllerConfig.DelayCompensationBMicroticks << 8) |
|
||||||
(controllerConfig.ClusterDriftDamping << 16) |
|
((controllerConfig.ClusterDriftDamping & 0x1F) << 16) |
|
||||||
(controllerConfig.DecodingCorrectionMicroticks << 24)
|
(controllerConfig.DecodingCorrectionMicroticks << 24)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC6,
|
registerWrites.push_back({ ERAYRegister::GTUC6,
|
||||||
controllerConfig.AcceptStartupRangeMicroticks |
|
(controllerConfig.AcceptStartupRangeMicroticks & 0x7FF) |
|
||||||
(controllerConfig.RateCorrectionOutMicroticks << 16)
|
((controllerConfig.RateCorrectionOutMicroticks & 0x7FF) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC7,
|
registerWrites.push_back({ ERAYRegister::GTUC7,
|
||||||
(clusterConfig.StaticSlotMacroticks) |
|
(clusterConfig.StaticSlotMacroticks & 0x3FF) |
|
||||||
(clusterConfig.NumberOfStaticSlots << 16)
|
((clusterConfig.NumberOfStaticSlots & 0x3FF) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC8,
|
registerWrites.push_back({ ERAYRegister::GTUC8,
|
||||||
clusterConfig.MinislotDurationMacroticks |
|
(clusterConfig.MinislotDurationMacroticks & 0x3F) |
|
||||||
(clusterConfig.NumberOfMinislots << 16)
|
((clusterConfig.NumberOfMinislots & 0x1FFF) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC9,
|
registerWrites.push_back({ ERAYRegister::GTUC9,
|
||||||
clusterConfig.ActionPointOffset |
|
(clusterConfig.ActionPointOffset & 0x3F) |
|
||||||
(clusterConfig.MinislotActionPointOffsetMacroticks << 8) |
|
((clusterConfig.MinislotActionPointOffsetMacroticks & 0x1F) << 8) |
|
||||||
(clusterConfig.DynamicSlotIdlePhaseMinislots << 16)
|
((clusterConfig.DynamicSlotIdlePhaseMinislots & 0x03) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC10,
|
registerWrites.push_back({ ERAYRegister::GTUC10,
|
||||||
controllerConfig.OffsetCorrectionOutMicroticks |
|
(controllerConfig.OffsetCorrectionOutMicroticks & 0x3FFF) |
|
||||||
(controllerConfig.RateCorrectionOutMicroticks << 16)
|
((controllerConfig.RateCorrectionOutMicroticks & 0x7FF) << 16)
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::GTUC11,
|
registerWrites.push_back({ ERAYRegister::GTUC11,
|
||||||
controllerConfig.ExternOffsetCorrectionControl |
|
(controllerConfig.ExternOffsetCorrectionControl & 0x3) |
|
||||||
(controllerConfig.ExternRateCorrectionControl << 8) |
|
((controllerConfig.ExternRateCorrectionControl & 0x3) << 8) |
|
||||||
(controllerConfig.ExternOffsetCorrectionMicroticks << 16) |
|
((controllerConfig.ExternOffsetCorrectionMicroticks & 0x7) << 16) |
|
||||||
(controllerConfig.ExternRateCorrectionMicroticks << 24)
|
((controllerConfig.ExternRateCorrectionMicroticks & 0x7) << 24)
|
||||||
});
|
});
|
||||||
|
|
||||||
std::vector<std::shared_ptr<MessageBuffer>> staticTx;
|
std::vector<std::shared_ptr<MessageBuffer>> staticTx;
|
||||||
@@ -210,7 +201,7 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
|||||||
second->isStartup = controllerConfig.KeySlotUsedForStartup;
|
second->isStartup = controllerConfig.KeySlotUsedForStartup;
|
||||||
second->isSync = controllerConfig.KeySlotUsedForSync;
|
second->isSync = controllerConfig.KeySlotUsedForSync;
|
||||||
second->isTransmit = true;
|
second->isTransmit = true;
|
||||||
second->channelB =true;
|
second->channelB = true;
|
||||||
second->frameID = controllerConfig.SecondKeySlotID;
|
second->frameID = controllerConfig.SecondKeySlotID;
|
||||||
second->frameLengthBytes = clusterConfig.PayloadLengthOfStaticSlotInWords * 2;
|
second->frameLengthBytes = clusterConfig.PayloadLengthOfStaticSlotInWords * 2;
|
||||||
second->baseCycle = 0;
|
second->baseCycle = 0;
|
||||||
@@ -266,7 +257,7 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
|||||||
totalBuffers = 128;
|
totalBuffers = 128;
|
||||||
|
|
||||||
registerWrites.push_back({ ERAYRegister::MRC,
|
registerWrites.push_back({ ERAYRegister::MRC,
|
||||||
(uint8_t(staticTx.size())) | // FDB[7:0] message buffers exclusively for the static segment
|
(static_cast<uint8_t>(staticTx.size())) | // FDB[7:0] message buffers exclusively for the static segment
|
||||||
// FFB[7:0] set to 0x80, No message buffer assigned to the FIFO
|
// FFB[7:0] set to 0x80, No message buffer assigned to the FIFO
|
||||||
(0x80 << 8) |
|
(0x80 << 8) |
|
||||||
(uint8_t(totalBuffers - 1) << 16) |
|
(uint8_t(totalBuffers - 1) << 16) |
|
||||||
@@ -287,12 +278,12 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
|||||||
buf.frameID = static_cast<uint16_t>(i | (1 << 10));
|
buf.frameID = static_cast<uint16_t>(i | (1 << 10));
|
||||||
|
|
||||||
uint32_t hs1 = (
|
uint32_t hs1 = (
|
||||||
(buf.frameID) |
|
(buf.frameID) | // FID
|
||||||
(CalculateCycleFilter(buf.baseCycle, buf.cycleRepetition) << 16) |
|
(CalculateCycleFilter(buf.baseCycle, buf.cycleRepetition) << 16) | // CYA
|
||||||
((buf.channelA & 0x1) << 24) |
|
((buf.channelA & 0x1) << 24) | // CHA
|
||||||
((buf.channelB & 0x1) << 25) |
|
((buf.channelB & 0x1) << 25) | // CHB
|
||||||
((buf.isTransmit & 0x1) << 26) | // CFG
|
((buf.isTransmit & 0x1) << 26) | // CFG
|
||||||
((buf.isNMFrame & 0x1) << 27) | // PPIT
|
((buf.isNetworkManagementFrame & 0x1) << 27) | // PPIT
|
||||||
((!buf.continuousMode & 0x1) << 28) | // TXM
|
((!buf.continuousMode & 0x1) << 28) | // TXM
|
||||||
((0 & 0x1) << 29) // MBI, disabled for now but we might want confirmations in the future
|
((0 & 0x1) << 29) // MBI, disabled for now but we might want confirmations in the future
|
||||||
);
|
);
|
||||||
@@ -610,7 +601,8 @@ uint16_t FlexRay::Controller::CalculateCycleFilter(uint8_t baseCycle, uint8_t cy
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, uint32_t> FlexRay::Controller::readRegister(ERAYRegister reg, std::chrono::milliseconds timeout) const {
|
std::pair<bool, uint32_t> FlexRay::Controller::readRegister(ERAYRegister reg, std::chrono::milliseconds timeout) const {
|
||||||
static const std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>(icsneo::Network::NetID::FlexRayControl);
|
static const std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>();
|
||||||
|
filter->includeInternalInAny = true;
|
||||||
if(timeout.count() <= 20)
|
if(timeout.count() <= 20)
|
||||||
return {false, 0}; // Out of time!
|
return {false, 0}; // Out of time!
|
||||||
|
|
||||||
|
|||||||
@@ -25,26 +25,6 @@ void FlexRay::Extension::onGoOffline() {
|
|||||||
controller->halt();
|
controller->halt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlexRay::Extension::handleMessage(const std::shared_ptr<Message>& message) {
|
|
||||||
switch(message->type) {
|
|
||||||
case Message::Type::FlexRayControl: {
|
|
||||||
auto msg = std::dynamic_pointer_cast<FlexRayControlMessage>(message);
|
|
||||||
if(!msg || !msg->decoded)
|
|
||||||
return;
|
|
||||||
switch(msg->opcode) {
|
|
||||||
case FlexRay::Opcode::ReadCCStatus:
|
|
||||||
if(msg->controller >= controllers.size())
|
|
||||||
return; // TODO error
|
|
||||||
controllers[msg->controller]->_setStatus(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FlexRay::Extension::transmitHook(const std::shared_ptr<Frame>& frame, bool& success) {
|
bool FlexRay::Extension::transmitHook(const std::shared_ptr<Frame>& frame, bool& success) {
|
||||||
if(!frame || frame->network.getType() != Network::Type::FlexRay)
|
if(!frame || frame->network.getType() != Network::Type::FlexRay)
|
||||||
return true; // Don't hook non-FlexRay messages
|
return true; // Don't hook non-FlexRay messages
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
std::optional<uint16_t> IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settings, std::optional<size_t> knownSize) {
|
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 = std::min(knownSize.value_or(0), settings.size());
|
size_t words = settings.size();
|
||||||
if(words % 2 == 1)
|
if(words % 2 == 1)
|
||||||
return std::nullopt; // Somehow settings is not word aligned
|
return std::nullopt; // Somehow settings is not word aligned
|
||||||
words /= 2;
|
words /= 2;
|
||||||
@@ -159,15 +159,12 @@ bool IDeviceSettings::ValidateLINBaudrate(int64_t baudrate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
bool IDeviceSettings::refresh() {
|
||||||
if(disabled) {
|
if(disabled) {
|
||||||
report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error);
|
report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(disableGSChecksumming)
|
|
||||||
ignoreChecksum = true;
|
|
||||||
|
|
||||||
std::vector<uint8_t> rxSettings;
|
std::vector<uint8_t> rxSettings;
|
||||||
bool ret = com->getSettingsSync(rxSettings);
|
bool ret = com->getSettingsSync(rxSettings);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
@@ -175,24 +172,14 @@ bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr size_t GsSize = 3 * sizeof(uint16_t);
|
constexpr size_t GsSize = 3 * sizeof(uint16_t); // <version> <length> <checksum>
|
||||||
if(rxSettings.size() < GsSize) { // We need to at least have the header of GLOBAL_SETTINGS
|
if(rxSettings.size() < GsSize) { // We need to at least have the header of GLOBAL_SETTINGS
|
||||||
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The length of the settings structure sent to us
|
|
||||||
// This is the length the firmware thinks the current version of the structure is
|
|
||||||
const size_t rxLen = rxSettings.size() - GsSize;
|
|
||||||
|
|
||||||
const uint16_t gsVersion = rxSettings[0] | (rxSettings[1] << 8);
|
const uint16_t gsVersion = rxSettings[0] | (rxSettings[1] << 8);
|
||||||
|
|
||||||
// The length of the settings last saved
|
|
||||||
// If the firmware is updated, it will have either extended (with zeros) or truncated
|
|
||||||
// the structure, but this value will continue to be set to the last saved value
|
|
||||||
const uint16_t gsLen = rxSettings[2] | (rxSettings[3] << 8);
|
|
||||||
|
|
||||||
const uint16_t gsChecksum = rxSettings[4] | (rxSettings[5] << 8);
|
|
||||||
rxSettings.erase(rxSettings.begin(), rxSettings.begin() + GsSize);
|
rxSettings.erase(rxSettings.begin(), rxSettings.begin() + GsSize);
|
||||||
|
|
||||||
if(gsVersion != GS_VERSION) {
|
if(gsVersion != GS_VERSION) {
|
||||||
@@ -200,19 +187,6 @@ bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rxLen < gsLen) {
|
|
||||||
// We got less data, i.e. the firmware thinks the strucure is smaller than what
|
|
||||||
// was last saved. Usually this is due to a firmware downgrade. We'll ignore the
|
|
||||||
// checksum for now, because it will definitely be wrong.
|
|
||||||
ignoreChecksum = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We check the checksum against the data last saved
|
|
||||||
if(!ignoreChecksum && gsChecksum != CalculateGSChecksum(rxSettings, gsLen)) {
|
|
||||||
report(APIEvent::Type::SettingsChecksumError, APIEvent::Severity::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
settings = std::move(rxSettings);
|
settings = std::move(rxSettings);
|
||||||
settingsInDeviceRAM = settings;
|
settingsInDeviceRAM = settings;
|
||||||
settingsLoaded = true;
|
settingsLoaded = true;
|
||||||
@@ -261,7 +235,7 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
|
|
||||||
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
std::shared_ptr<Main51Message> msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(1000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000)));
|
||||||
|
|
||||||
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
|
||||||
@@ -272,7 +246,7 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh(true); // Refresh ignoring checksum
|
refresh();
|
||||||
// The device might modify the settings once they are applied, however in this case it does not update the checksum
|
// The device might modify the settings once they are applied, however in this case it does not update the checksum
|
||||||
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
|
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
|
||||||
gsChecksum = CalculateGSChecksum(settings);
|
gsChecksum = CalculateGSChecksum(settings);
|
||||||
@@ -287,7 +261,7 @@ bool IDeviceSettings::apply(bool temporary) {
|
|||||||
|
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(1000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000)));
|
||||||
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()) {
|
||||||
@@ -342,7 +316,7 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
// This short wait helps on FIRE devices, otherwise the checksum might be wrong!
|
// This short wait helps on FIRE devices, otherwise the checksum might be wrong!
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
||||||
|
|
||||||
refresh(true); // Refresh ignoring checksum
|
refresh();
|
||||||
// The device might modify the settings once they are applied, however in this case it does not update the checksum
|
// The device might modify the settings once they are applied, however in this case it does not update the checksum
|
||||||
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
|
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
|
||||||
std::vector<uint8_t> bytestream;
|
std::vector<uint8_t> bytestream;
|
||||||
@@ -364,7 +338,7 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
|||||||
|
|
||||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &bytestream]() {
|
||||||
return com->sendCommand(Command::SetSettings, bytestream);
|
return com->sendCommand(Command::SetSettings, bytestream);
|
||||||
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(1000)));
|
}, std::make_shared<Main51MessageFilter>(Command::SetSettings), std::chrono::milliseconds(2000)));
|
||||||
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()) {
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#include <icsneo/disk/diskdetails.h>
|
||||||
|
#include <icsneo/device/idevicesettings.h>
|
||||||
|
|
||||||
|
using namespace icsneo;
|
||||||
|
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
|
||||||
|
struct DISK_STATUS {
|
||||||
|
uint16_t status;
|
||||||
|
uint64_t sectors;
|
||||||
|
uint32_t bytesPerSector;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DISK_DETAILS {
|
||||||
|
DISK_SETTINGS settings;
|
||||||
|
uint16_t options;
|
||||||
|
DISK_STATUS status[12];
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
static constexpr uint8_t DISK_FORMAT_FAT32 = 0x01u;
|
||||||
|
static constexpr uint8_t DISK_STATUS_PRESENT = 0x01u;
|
||||||
|
static constexpr uint8_t DISK_STATUS_INITIALIZED = 0x02u;
|
||||||
|
static constexpr uint16_t DISK_DETAILS_FULL_FORMAT = 0x01u;
|
||||||
|
|
||||||
|
std::vector<uint8_t> DiskDetails::Encode(const DiskDetails& config) {
|
||||||
|
std::vector<uint8_t> result(sizeof(DISK_DETAILS), 0);
|
||||||
|
DISK_DETAILS* details = reinterpret_cast<DISK_DETAILS*>(result.data());
|
||||||
|
details->settings.disk_layout = static_cast<uint8_t>(config.layout);
|
||||||
|
details->settings.disk_format = DISK_FORMAT_FAT32; // Always FAT32
|
||||||
|
details->options = config.fullFormat ? DISK_DETAILS_FULL_FORMAT : 0;
|
||||||
|
uint32_t& enables = details->settings.disk_enables;
|
||||||
|
enables = 0u;
|
||||||
|
for(size_t i = 0; i < config.disks.size(); i++) {
|
||||||
|
auto& disk = config.disks[i];
|
||||||
|
details->status[i].sectors = disk.sectors;
|
||||||
|
details->status[i].bytesPerSector = disk.bytesPerSector;
|
||||||
|
|
||||||
|
uint16_t& status = details->status[i].status;
|
||||||
|
status = 0u;
|
||||||
|
if(disk.initialized) {
|
||||||
|
status |= DISK_STATUS_INITIALIZED;
|
||||||
|
}
|
||||||
|
if(disk.present) {
|
||||||
|
status |= DISK_STATUS_PRESENT;
|
||||||
|
}
|
||||||
|
if(disk.formatted) {
|
||||||
|
enables |= (1u << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DiskDetails> DiskDetails::Decode(const std::vector<uint8_t>& bytes, size_t diskCount, device_eventhandler_t report) {
|
||||||
|
if(bytes.size() < sizeof(DISK_DETAILS)) {
|
||||||
|
report(APIEvent::Type::BufferInsufficient, APIEvent::Severity::Error);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = std::make_shared<DiskDetails>();
|
||||||
|
const DISK_DETAILS* details = reinterpret_cast<const DISK_DETAILS*>(bytes.data());
|
||||||
|
result->layout = static_cast<DiskLayout>(details->settings.disk_layout);
|
||||||
|
result->fullFormat = details->options & DISK_DETAILS_FULL_FORMAT;
|
||||||
|
|
||||||
|
result->disks.reserve(diskCount);
|
||||||
|
|
||||||
|
for(size_t i = 0; i < diskCount; i++) {
|
||||||
|
auto& disk = details->status[i];
|
||||||
|
result->disks.emplace_back();
|
||||||
|
auto& info = result->disks.back();
|
||||||
|
info.present = static_cast<bool>(disk.status & DISK_STATUS_PRESENT);
|
||||||
|
info.initialized = static_cast<bool>(disk.status & DISK_STATUS_INITIALIZED);
|
||||||
|
info.formatted = static_cast<bool>(details->settings.disk_enables & (1u << i));
|
||||||
|
info.sectors = disk.sectors;
|
||||||
|
info.bytesPerSector = disk.bytesPerSector;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ std::optional<uint64_t> ExtExtractorDiskReadDriver::readLogicalDiskAligned(Commu
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<uint64_t> ExtExtractorDiskReadDriver::attemptReadLogicalDiskAligned(Communication& com, device_eventhandler_t report,
|
std::optional<uint64_t> ExtExtractorDiskReadDriver::attemptReadLogicalDiskAligned(Communication& com, device_eventhandler_t,
|
||||||
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, MemoryType) {
|
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, MemoryType) {
|
||||||
static std::shared_ptr<MessageFilter> NeoMemorySDRead = std::make_shared<MessageFilter>(Network::NetID::NeoMemorySDRead);
|
static std::shared_ptr<MessageFilter> NeoMemorySDRead = std::make_shared<MessageFilter>(Network::NetID::NeoMemorySDRead);
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ std::optional<uint64_t> NeoMemoryDiskDriver::readLogicalDiskAligned(Communicatio
|
|||||||
return SectorSize;
|
return SectorSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<uint64_t> NeoMemoryDiskDriver::writeLogicalDiskAligned(Communication& com, device_eventhandler_t report,
|
std::optional<uint64_t> NeoMemoryDiskDriver::writeLogicalDiskAligned(Communication& com, device_eventhandler_t,
|
||||||
uint64_t pos, const uint8_t* from, uint64_t amount, std::chrono::milliseconds timeout, MemoryType memType) {
|
uint64_t pos, const uint8_t* from, uint64_t amount, std::chrono::milliseconds timeout, MemoryType memType) {
|
||||||
|
|
||||||
static std::shared_ptr<MessageFilter> NeoMemoryDone = std::make_shared<MessageFilter>(Network::NetID::NeoMemoryWriteDone);
|
static std::shared_ptr<MessageFilter> NeoMemoryDone = std::make_shared<MessageFilter>(Network::NetID::NeoMemoryWriteDone);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
using namespace icsneo::Disk;
|
using namespace icsneo::Disk;
|
||||||
|
|
||||||
std::optional<uint64_t> PlasionDiskReadDriver::readLogicalDiskAligned(Communication& com, device_eventhandler_t report,
|
std::optional<uint64_t> PlasionDiskReadDriver::readLogicalDiskAligned(Communication& com, device_eventhandler_t,
|
||||||
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, MemoryType) {
|
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, MemoryType) {
|
||||||
static std::shared_ptr<MessageFilter> NeoMemorySDRead = std::make_shared<MessageFilter>(Network::NetID::NeoMemorySDRead);
|
static std::shared_ptr<MessageFilter> NeoMemorySDRead = std::make_shared<MessageFilter>(Network::NetID::NeoMemorySDRead);
|
||||||
|
|
||||||
|
|||||||
@@ -25,19 +25,4 @@ void VSAExtendedMessage::appendPacket(std::shared_ptr<Packet> packet) const
|
|||||||
if(packet->network.getNetID() == Network::NetID::Invalid) {
|
if(packet->network.getNetID() == Network::NetID::Invalid) {
|
||||||
packet->network = network;
|
packet->network = network;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void VSAExtendedMessage::truncatePacket(std::shared_ptr<Packet> packet)
|
|
||||||
{
|
|
||||||
static constexpr auto EthernetLengthOffset = 26u;
|
|
||||||
switch(packet->network.getType()) {
|
|
||||||
case Network::Type::Ethernet:
|
|
||||||
{
|
|
||||||
const auto& packetLength = *reinterpret_cast<uint16_t*>(packet->data.data() + EthernetLengthOffset);
|
|
||||||
const size_t ethernetFrameSize = packetLength - (sizeof(uint16_t) * 2);
|
|
||||||
const size_t bytestreamExpectedSize = sizeof(HardwareEthernetPacket) + ethernetFrameSize;
|
|
||||||
packet->data.resize(bytestreamExpectedSize);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -9,7 +9,7 @@ VSA02::VSA02(uint8_t* const recordBytes)
|
|||||||
constantIndex = *reinterpret_cast<uint16_t*>(recordBytes + 2);
|
constantIndex = *reinterpret_cast<uint16_t*>(recordBytes + 2);
|
||||||
flags = *reinterpret_cast<Flags*>(recordBytes + 4);
|
flags = *reinterpret_cast<Flags*>(recordBytes + 4);
|
||||||
pieceCount = recordBytes[5];
|
pieceCount = recordBytes[5];
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6);
|
||||||
samples.insert(samples.end(), recordBytes + 14, recordBytes + 30);
|
samples.insert(samples.end(), recordBytes + 14, recordBytes + 30);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ VSA03::VSA03(uint8_t* const recordBytes)
|
|||||||
setType(VSA::Type::AA03);
|
setType(VSA::Type::AA03);
|
||||||
eventType = static_cast<EventType>(*reinterpret_cast<uint16_t*>(recordBytes + 2));
|
eventType = static_cast<EventType>(*reinterpret_cast<uint16_t*>(recordBytes + 2));
|
||||||
eventData = *reinterpret_cast<uint16_t*>(recordBytes + 4);
|
eventData = *reinterpret_cast<uint16_t*>(recordBytes + 4);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 14);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 14);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ VSA04::VSA04(uint8_t* const recordBytes)
|
|||||||
setType(VSA::Type::AA04);
|
setType(VSA::Type::AA04);
|
||||||
flags = *reinterpret_cast<Flags*>(recordBytes + 2);
|
flags = *reinterpret_cast<Flags*>(recordBytes + 2);
|
||||||
partitionIndex = *reinterpret_cast<uint16_t*>(recordBytes + 4);
|
partitionIndex = *reinterpret_cast<uint16_t*>(recordBytes + 4);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 14);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 14);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ VSA05::VSA05(uint8_t* const recordBytes)
|
|||||||
setType(VSA::Type::AA05);
|
setType(VSA::Type::AA05);
|
||||||
errorType = static_cast<ErrorType>(*reinterpret_cast<uint16_t*>(recordBytes + 2));
|
errorType = static_cast<ErrorType>(*reinterpret_cast<uint16_t*>(recordBytes + 2));
|
||||||
errorNetwork = *reinterpret_cast<uint16_t*>(recordBytes + 4);
|
errorNetwork = *reinterpret_cast<uint16_t*>(recordBytes + 4);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 6);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 14);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ VSA06::VSA06(uint8_t* const recordBytes)
|
|||||||
savedSectors.insert(savedSectors.end(), reinterpret_cast<uint32_t*>(recordBytes + 2), reinterpret_cast<uint32_t*>(recordBytes + 18));
|
savedSectors.insert(savedSectors.end(), reinterpret_cast<uint32_t*>(recordBytes + 2), reinterpret_cast<uint32_t*>(recordBytes + 18));
|
||||||
error = *reinterpret_cast<uint16_t*>(recordBytes + 18);
|
error = *reinterpret_cast<uint16_t*>(recordBytes + 18);
|
||||||
savedSectorsHigh = *reinterpret_cast<uint16_t*>(recordBytes + 20);
|
savedSectorsHigh = *reinterpret_cast<uint16_t*>(recordBytes + 20);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ VSA07::VSA07(uint8_t* const recordBytes)
|
|||||||
lastSector = *reinterpret_cast<uint32_t*>(recordBytes + 2);
|
lastSector = *reinterpret_cast<uint32_t*>(recordBytes + 2);
|
||||||
currentSector = *reinterpret_cast<uint32_t*>(recordBytes + 6);
|
currentSector = *reinterpret_cast<uint32_t*>(recordBytes + 6);
|
||||||
reserved.insert(reserved.end(), recordBytes + 10, recordBytes + 22);
|
reserved.insert(reserved.end(), recordBytes + 10, recordBytes + 22);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -7,8 +7,8 @@ VSA08::VSA08(uint8_t* const recordBytes)
|
|||||||
{
|
{
|
||||||
setType(VSA::Type::AA08);
|
setType(VSA::Type::AA08);
|
||||||
troubleSramCount.insert(troubleSramCount.end(), recordBytes + 2, recordBytes + 6);
|
troubleSramCount.insert(troubleSramCount.end(), recordBytes + 2, recordBytes + 6);
|
||||||
troubleSectors.insert(troubleSectors.end(), reinterpret_cast<uint32_t*>(recordBytes + 6), reinterpret_cast<uint32_t*>(recordBytes + 20));
|
troubleSectors.insert(troubleSectors.end(), reinterpret_cast<uint32_t*>(recordBytes + 6), reinterpret_cast<uint32_t*>(recordBytes + 22));
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ VSA09::VSA09(uint8_t* const recordBytes)
|
|||||||
reserved0.insert(reserved0.end(), recordBytes + 12, recordBytes + 18);
|
reserved0.insert(reserved0.end(), recordBytes + 12, recordBytes + 18);
|
||||||
hardwareID = static_cast<HardwareID>(recordBytes[18]);
|
hardwareID = static_cast<HardwareID>(recordBytes[18]);
|
||||||
reserved1.insert(reserved1.end(), recordBytes + 19, recordBytes + 22);
|
reserved1.insert(reserved1.end(), recordBytes + 19, recordBytes + 22);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 22);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -11,7 +11,7 @@ VSA0B::VSA0B(uint8_t* const recordBytes)
|
|||||||
{
|
{
|
||||||
setType(VSA::Type::AA0B);
|
setType(VSA::Type::AA0B);
|
||||||
captureBitfield = reinterpret_cast<uint16_t*>(recordBytes)[1];
|
captureBitfield = reinterpret_cast<uint16_t*>(recordBytes)[1];
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 20) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 20);
|
||||||
reserved = recordBytes[28];
|
reserved = recordBytes[28];
|
||||||
checksum = reinterpret_cast<uint16_t*>(recordBytes)[15];
|
checksum = reinterpret_cast<uint16_t*>(recordBytes)[15];
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
@@ -30,8 +30,8 @@ void VSA0B::doChecksum(uint8_t* recordBytes)
|
|||||||
bool VSA0B::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
bool VSA0B::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
||||||
{
|
{
|
||||||
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ VSA0C::VSA0C(uint8_t* const recordBytes)
|
|||||||
audioPreamble = recordBytes[4];
|
audioPreamble = recordBytes[4];
|
||||||
audioHeader = recordBytes[5];
|
audioHeader = recordBytes[5];
|
||||||
pcmData.insert(pcmData.end(), recordBytes + 6, recordBytes + 20);
|
pcmData.insert(pcmData.end(), recordBytes + 6, recordBytes + 20);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 20) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 20);
|
||||||
vNetBitfield = *reinterpret_cast<VSA0C::VNet*>(recordBytes + 28);
|
vNetBitfield = *reinterpret_cast<VSA0C::VNet*>(recordBytes + 28);
|
||||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||||
doChecksum(recordBytes);
|
doChecksum(recordBytes);
|
||||||
|
|||||||
+2
-2
@@ -76,8 +76,8 @@ void VSA0DFirst::reorderPayload(std::vector<uint8_t>& secondPayload)
|
|||||||
bool VSA0DFirst::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
bool VSA0DFirst::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
||||||
{
|
{
|
||||||
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+2
-2
@@ -66,8 +66,8 @@ void VSA0EFirst::reservePacketData(std::shared_ptr<Packet>& packet) const
|
|||||||
bool VSA0EFirst::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
bool VSA0EFirst::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
||||||
{
|
{
|
||||||
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+2
-2
@@ -78,8 +78,8 @@ void VSA0FFirst::reservePacketData(std::shared_ptr<Packet>& packet) const
|
|||||||
bool VSA0FFirst::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
bool VSA0FFirst::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
||||||
{
|
{
|
||||||
if(filter->captureBitfield != captureBitfield ||
|
if(filter->captureBitfield != captureBitfield ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ VSA6A::VSA6A(uint8_t* const recordBytes)
|
|||||||
sequenceNum = *reinterpret_cast<uint32_t*>(recordBytes + 34);
|
sequenceNum = *reinterpret_cast<uint32_t*>(recordBytes + 34);
|
||||||
totalSectors = *reinterpret_cast<uint32_t*>(recordBytes + 38);
|
totalSectors = *reinterpret_cast<uint32_t*>(recordBytes + 38);
|
||||||
reserved = *reinterpret_cast<uint32_t*>(recordBytes + 42);
|
reserved = *reinterpret_cast<uint32_t*>(recordBytes + 42);
|
||||||
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 46) & UINT63_MAX;
|
timestamp = *reinterpret_cast<uint64_t*>(recordBytes + 46);
|
||||||
timestampSum = *reinterpret_cast<uint16_t*>(recordBytes + 54);
|
timestampSum = *reinterpret_cast<uint16_t*>(recordBytes + 54);
|
||||||
data.insert(data.end(), recordBytes + 56, recordBytes + 508);
|
data.insert(data.end(), recordBytes + 56, recordBytes + 508);
|
||||||
checksum = *reinterpret_cast<uint32_t*>(recordBytes + 508);
|
checksum = *reinterpret_cast<uint32_t*>(recordBytes + 508);
|
||||||
|
|||||||
@@ -430,7 +430,6 @@ bool VSAParser::extractMessagePackets(std::vector<std::shared_ptr<Packet>>& pack
|
|||||||
extendedMessageRecord->appendPacket(packet);
|
extendedMessageRecord->appendPacket(packet);
|
||||||
if(extendedMessageRecord->getRecordCount() == static_cast<uint32_t>(extendedMessageRecord->getIndex() + 1)) { // Last record in sequence
|
if(extendedMessageRecord->getRecordCount() == static_cast<uint32_t>(extendedMessageRecord->getIndex() + 1)) { // Last record in sequence
|
||||||
if(!settings.messageFilter || extendedMessageRecord->filter(settings.messageFilter)) {
|
if(!settings.messageFilter || extendedMessageRecord->filter(settings.messageFilter)) {
|
||||||
VSAExtendedMessage::truncatePacket(packet);
|
|
||||||
packets.push_back(packet);
|
packets.push_back(packet);
|
||||||
}
|
}
|
||||||
activeExtendedMessage = false;
|
activeExtendedMessage = false;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Dependencies
|
|||||||
The minimum requirements to build libicsneo are:
|
The minimum requirements to build libicsneo are:
|
||||||
- CMake version 3.12 or newer
|
- CMake version 3.12 or newer
|
||||||
- A C++17 compiler
|
- A C++17 compiler
|
||||||
- libusb and libpcap on Linux and macOS
|
- libpcap on Linux and macOS
|
||||||
|
|
||||||
|
|
||||||
Building library & examples
|
Building library & examples
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
===================
|
||||||
|
CAN Getting Started
|
||||||
|
===================
|
||||||
|
|
||||||
|
Prerequisites
|
||||||
|
=============
|
||||||
|
|
||||||
|
- Python 3.8 or higher
|
||||||
|
- icsneopy library installed
|
||||||
|
- CAN hardware device connected
|
||||||
|
|
||||||
|
:download:`Download complete example <../../examples/python/can/can_complete_example.py>`
|
||||||
|
|
||||||
|
Basic Setup
|
||||||
|
===========
|
||||||
|
|
||||||
|
1. Import the library and discover devices:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 11-19
|
||||||
|
|
||||||
|
2. Configure and open the device:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 22-37
|
||||||
|
|
||||||
|
Transmitting CAN Frames
|
||||||
|
========================
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 40-53
|
||||||
|
|
||||||
|
Receiving CAN Frames
|
||||||
|
=====================
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 56-72
|
||||||
|
|
||||||
|
Cleanup and Resource Management
|
||||||
|
===============================
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 75-79
|
||||||
|
|
||||||
|
Complete Example with Error Handling
|
||||||
|
====================================
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 82-125
|
||||||
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
=========================
|
||||||
|
Ethernet Getting Started
|
||||||
|
=========================
|
||||||
|
|
||||||
|
This guide provides basic instructions for working with Ethernet devices using the icsneopy library.
|
||||||
|
|
||||||
|
Prerequisites
|
||||||
|
=============
|
||||||
|
|
||||||
|
- Python 3.8 or higher
|
||||||
|
- icsneopy library installed
|
||||||
|
- Intrepid Control Systems Device
|
||||||
|
|
||||||
|
:download:`Download complete example <../../examples/python/ethernet/ethernet_complete_example.py>`
|
||||||
|
|
||||||
|
Opening the Device
|
||||||
|
==================
|
||||||
|
|
||||||
|
To begin working with an Ethernet device, you must first discover, open, and bring it online:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 11-37
|
||||||
|
|
||||||
|
Transmitting Ethernet Frames
|
||||||
|
=============================
|
||||||
|
|
||||||
|
Transmit Ethernet frames using the EthernetMessage class:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 61-78
|
||||||
|
|
||||||
|
Monitoring Ethernet Status
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Monitor Ethernet link status changes using message callbacks:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 39-40
|
||||||
|
|
||||||
|
DoIP Ethernet Activation Control
|
||||||
|
================================
|
||||||
|
|
||||||
|
Diagnostics over Internet Protocol (DoIP) can be controlled through digital I/O pins:
|
||||||
|
|
||||||
|
:download:`Download DoIP example <../../examples/python/doip/doip_activation_control.py>`
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/doip/doip_activation_control.py
|
||||||
|
:language: python
|
||||||
|
:lines: 28-44
|
||||||
|
|
||||||
|
Network Configuration Reference
|
||||||
|
===============================
|
||||||
|
|
||||||
|
Standard Ethernet network identifiers:
|
||||||
|
|
||||||
|
- ``icsneopy.Network.NetID.ETHERNET_01`` - Standard Ethernet Port 1
|
||||||
|
|
||||||
|
Automotive Ethernet network identifiers:
|
||||||
|
|
||||||
|
- ``icsneopy.Network.NetID.AE_01`` - Automotive Ethernet Port 1
|
||||||
|
|
||||||
|
Complete Example with Resource Management
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_complete_example.py
|
||||||
|
:language: python
|
||||||
|
:lines: 86-127
|
||||||
+39
-126
@@ -3,161 +3,74 @@ Python Examples
|
|||||||
===============
|
===============
|
||||||
|
|
||||||
Transmit CAN frames on DW CAN 01
|
Transmit CAN frames on DW CAN 01
|
||||||
============================
|
=================================
|
||||||
|
|
||||||
.. code-block:: python
|
:download:`Download example <../../examples/python/can/can_transmit_basic.py>`
|
||||||
|
|
||||||
import icsneopy
|
.. literalinclude:: ../../examples/python/can/can_transmit_basic.py
|
||||||
|
:language: python
|
||||||
devices: list[icsneopy.Device] = icsneopy.find_all_devices()
|
|
||||||
|
|
||||||
# grab the first/only device found
|
|
||||||
device: icsneopy.Device = devices[0]
|
|
||||||
|
|
||||||
message = icsneopy.CANMessage()
|
|
||||||
message.network = icsneopy.Network(icsneopy.Network.NetID.DWCAN_01)
|
|
||||||
message.arbid = 0x56
|
|
||||||
message.data = (0x11, 0x22, 0x33)
|
|
||||||
|
|
||||||
device.open()
|
|
||||||
|
|
||||||
device.go_online()
|
|
||||||
|
|
||||||
device.transmit(message)
|
|
||||||
|
|
||||||
Receive CAN frames on DW CAN 01
|
Receive CAN frames on DW CAN 01
|
||||||
===========================
|
================================
|
||||||
|
|
||||||
.. code-block:: python
|
:download:`Download example <../../examples/python/can/can_receive_basic.py>`
|
||||||
|
|
||||||
import icsneopy
|
.. literalinclude:: ../../examples/python/can/can_receive_basic.py
|
||||||
import time
|
:language: python
|
||||||
|
|
||||||
devices: list[icsneopy.Device] = icsneopy.find_all_devices()
|
Complete CAN Example
|
||||||
|
====================
|
||||||
|
|
||||||
# grab the first/only device found
|
:download:`Download example <../../examples/python/can/can_complete_example.py>`
|
||||||
device: icsneopy.Device = devices[0]
|
|
||||||
|
|
||||||
def on_message(message: icsneopy.CANMessage):
|
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||||
print(message.arbid, message.data)
|
:language: python
|
||||||
message_filter = icsneopy.MessageFilter(icsneopy.Network.NetID.DWCAN_01)
|
|
||||||
callback = icsneopy.MessageCallback(on_message, message_filter)
|
|
||||||
|
|
||||||
device.add_message_callback(callback)
|
|
||||||
|
|
||||||
device.open()
|
Transmit Ethernet frames on Ethernet 01
|
||||||
device.go_online()
|
========================================
|
||||||
|
|
||||||
# rx for 10s
|
:download:`Download example <../../examples/python/ethernet/ethernet_transmit_basic.py>`
|
||||||
time.sleep(10)
|
|
||||||
|
|
||||||
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_transmit_basic.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
Monitor Ethernet Status
|
Monitor Ethernet Status
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
.. code-block:: python
|
:download:`Download example <../../examples/python/ethernet/ethernet_monitor_status.py>`
|
||||||
|
|
||||||
import icsneopy
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_monitor_status.py
|
||||||
import time
|
:language: python
|
||||||
|
|
||||||
def main():
|
TC10 Power Management
|
||||||
devices = icsneopy.find_all_devices()
|
=====================
|
||||||
if len(devices) == 0:
|
|
||||||
print("error: no devices found")
|
|
||||||
return False
|
|
||||||
|
|
||||||
device = devices[0]
|
:download:`Download example <../../examples/python/tc10/tc10.py>`
|
||||||
print(f"info: monitoring Ethernet status on {device}")
|
|
||||||
|
|
||||||
def on_message(message):
|
.. literalinclude:: ../../examples/python/tc10/tc10.py
|
||||||
print(f"info: network: {message.network}, state: {message.state}, speed: {message.speed}, duplex: {message.duplex}, mode: {message.mode}")
|
:language: python
|
||||||
|
|
||||||
filter = icsneopy.MessageFilter(icsneopy.Message.Type.EthernetStatus)
|
|
||||||
callback = icsneopy.MessageCallback(on_message, filter)
|
|
||||||
device.add_message_callback(callback)
|
|
||||||
|
|
||||||
if not device.open():
|
|
||||||
print("error: unable to open device")
|
|
||||||
return False
|
|
||||||
|
|
||||||
if not device.go_online():
|
|
||||||
print("error: unable to go online")
|
|
||||||
return False
|
|
||||||
|
|
||||||
while True:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
TC10
|
|
||||||
====
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import icsneopy
|
|
||||||
import time
|
|
||||||
|
|
||||||
devices: list[icsneopy.Device] = icsneopy.find_all_devices()
|
|
||||||
|
|
||||||
device: icsneopy.Device = devices[0]
|
|
||||||
|
|
||||||
print(f"using {device} for TC10")
|
|
||||||
|
|
||||||
device.open()
|
|
||||||
|
|
||||||
netid = icsneopy.Network.NetID.AE_01
|
|
||||||
|
|
||||||
if device.supports_tc10():
|
|
||||||
# initial
|
|
||||||
status = device.get_tc10_status(netid)
|
|
||||||
print(f"initial status: wake: {status.wakeStatus}, sleep: {status.sleepStatus}")
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
# sleep
|
|
||||||
device.request_tc10_sleep(netid)
|
|
||||||
print("waiting 1s for sleep to occur")
|
|
||||||
time.sleep(1)
|
|
||||||
status = device.get_tc10_status(netid)
|
|
||||||
print(f"post sleep status: wake: {status.wakeStatus}, sleep: {status.sleepStatus}")
|
|
||||||
|
|
||||||
# wake
|
|
||||||
device.request_tc10_wake(netid)
|
|
||||||
print("waiting 1s for wake to occur")
|
|
||||||
time.sleep(1)
|
|
||||||
status = device.get_tc10_status(netid)
|
|
||||||
print(f"post wake status: wake: {status.wakeStatus}, sleep: {status.sleepStatus}")
|
|
||||||
else:
|
|
||||||
print(f"{device} does not support TC10")
|
|
||||||
|
|
||||||
DoIP Ethernet Activation
|
DoIP Ethernet Activation
|
||||||
========================
|
========================
|
||||||
|
|
||||||
.. code-block:: python
|
:download:`Download example <../../examples/python/doip/doip_activation_control.py>`
|
||||||
|
|
||||||
import icsneopy
|
.. literalinclude:: ../../examples/python/doip/doip_activation_control.py
|
||||||
import time
|
:language: python
|
||||||
|
|
||||||
devs = icsneopy.find_all_devices()
|
Complete Ethernet Example
|
||||||
|
=========================
|
||||||
|
|
||||||
dev = devs[0]
|
:download:`Download example <../../examples/python/ethernet/ethernet_complete_example.py>`
|
||||||
|
|
||||||
dev.open()
|
.. literalinclude:: ../../examples/python/ethernet/ethernet_complete_example.py
|
||||||
|
:language: python
|
||||||
|
|
||||||
# the device must be online for digital I/O
|
Device Firmware/Chip Versions
|
||||||
dev.go_online()
|
=============================
|
||||||
|
|
||||||
print(f"initial state: {dev.get_digital_io(icsneopy.IO.EthernetActivation, 1)}")
|
:download:`Download example <../../examples/python/device/chip_versions.py>`
|
||||||
|
|
||||||
dev.set_digital_io(icsneopy.IO.EthernetActivation, 1, True)
|
.. literalinclude:: ../../examples/python/device/chip_versions.py
|
||||||
|
:language: python
|
||||||
print(f"after setting to true: {dev.get_digital_io(icsneopy.IO.EthernetActivation, 1)}")
|
|
||||||
|
|
||||||
# allow for observing the change
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
dev.set_digital_io(icsneopy.IO.EthernetActivation, 1, False)
|
|
||||||
|
|
||||||
print(f"after setting to false: {dev.get_digital_io(icsneopy.IO.EthernetActivation, 1)}")
|
|
||||||
|
|
||||||
# allow for observing the change
|
|
||||||
time.sleep(2)
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ icsneopy
|
|||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
can_getting_started
|
||||||
|
ethernet_getting_started
|
||||||
examples
|
examples
|
||||||
api
|
api
|
||||||
radepsilon
|
radepsilon
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ option(LIBICSNEO_BUILD_CPP_COREMINI_EXAMPLE "Build the Coremini example." ON)
|
|||||||
option(LIBICSNEO_BUILD_CPP_MDIO_EXAMPLE "Build the MDIO example." ON)
|
option(LIBICSNEO_BUILD_CPP_MDIO_EXAMPLE "Build the MDIO example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_VSA_EXAMPLE "Build the VSA example." ON)
|
option(LIBICSNEO_BUILD_CPP_VSA_EXAMPLE "Build the VSA example." ON)
|
||||||
option(LIBICSNEO_BUILD_CPP_APP_ERROR_EXAMPLE "Build the app error example." ON)
|
option(LIBICSNEO_BUILD_CPP_APP_ERROR_EXAMPLE "Build the app error 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_MUTEX_EXAMPLE "Build the NetworkMutex example." ON)
|
||||||
|
|
||||||
|
add_compile_options(${LIBICSNEO_COMPILER_WARNINGS})
|
||||||
|
|
||||||
if(LIBICSNEO_BUILD_C_INTERACTIVE_EXAMPLE)
|
if(LIBICSNEO_BUILD_C_INTERACTIVE_EXAMPLE)
|
||||||
add_subdirectory(c/interactive)
|
add_subdirectory(c/interactive)
|
||||||
@@ -58,3 +63,15 @@ endif()
|
|||||||
if(LIBICSNEO_BUILD_CPP_APP_ERROR_EXAMPLE)
|
if(LIBICSNEO_BUILD_CPP_APP_ERROR_EXAMPLE)
|
||||||
add_subdirectory(cpp/apperror)
|
add_subdirectory(cpp/apperror)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_FLEXRAY_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/flexray)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_SPI_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/spi)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBICSNEO_BUILD_CPP_MUTEX_EXAMPLE)
|
||||||
|
add_subdirectory(cpp/mutex)
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Although the example program will build without successfully completing the step
|
|||||||
|
|
||||||
First, we are going to build the icsneoc library into a .so file that we can later use in order to access the library functions.
|
First, we are going to build the icsneoc library into a .so file that we can later use in order to access the library functions.
|
||||||
|
|
||||||
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev`
|
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libpcap0.8-dev`
|
||||||
2. Change directories to `libicsneo-examples/third-party/libicsneo` and create a build directory by running `mkdir -p build`
|
2. Change directories to `libicsneo-examples/third-party/libicsneo` and create a build directory by running `mkdir -p build`
|
||||||
3. Enter the build directory with `cd build`
|
3. Enter the build directory with `cd build`
|
||||||
4. Run `cmake ..` to generate your Makefile.
|
4. Run `cmake ..` to generate your Makefile.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Although the example program will build without successfully completing the step
|
|||||||
|
|
||||||
First, we are going to build the icsneoc library into a .so file that we can later use in order to access the library functions.
|
First, we are going to build the icsneoc library into a .so file that we can later use in order to access the library functions.
|
||||||
|
|
||||||
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev`
|
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libpcap0.8-dev`
|
||||||
2. Change directories to `libicsneo-examples/third-party/libicsneo` and create a build directory by running `mkdir -p build`
|
2. Change directories to `libicsneo-examples/third-party/libicsneo` and create a build directory by running `mkdir -p build`
|
||||||
3. Enter the build directory with `cd build`
|
3. Enter the build directory with `cd build`
|
||||||
4. Run `cmake ..` to generate your Makefile.
|
4. Run `cmake ..` to generate your Makefile.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Although the example program will build without successfully completing the step
|
|||||||
|
|
||||||
First, we are going to build the icsneoc library into a .so file that we can later use in order to access the library functions.
|
First, we are going to build the icsneoc library into a .so file that we can later use in order to access the library functions.
|
||||||
|
|
||||||
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev`
|
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libpcap0.8-dev`
|
||||||
2. Change directories to `libicsneo-examples/third-party/libicsneo` and create a build directory by running `mkdir -p build`
|
2. Change directories to `libicsneo-examples/third-party/libicsneo` and create a build directory by running `mkdir -p build`
|
||||||
3. Enter the build directory with `cd build`
|
3. Enter the build directory with `cd build`
|
||||||
4. Run `cmake ..` to generate your Makefile.
|
4. Run `cmake ..` to generate your Makefile.
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
add_executable(libicsneocpp-flexray-example src/FlexRayExample.cpp)
|
||||||
|
target_link_libraries(libicsneocpp-flexray-example icsneocpp)
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
#include "icsneo/icsneocpp.h"
|
||||||
|
#include "icsneo/device/extensions/flexray/cluster.h"
|
||||||
|
|
||||||
|
/* Modifiable Configuration Variables*/
|
||||||
|
|
||||||
|
static size_t NumMessages = 300;
|
||||||
|
static size_t FramePayloadSize = 134;
|
||||||
|
static uint16_t SlotOne = 1;
|
||||||
|
static uint16_t SlotTwo = 3;
|
||||||
|
static bool SuppressRxTxDebugMessages = true;
|
||||||
|
|
||||||
|
static const icsneo::FlexRay::Controller::Configuration DefaultControllerConfig {
|
||||||
|
160, // uint16_t AcceptStartupRangeMicroticks INIT(0); // pdAcceptedStartupRange
|
||||||
|
true, // bool AllowHaltDueToClock INIT(false); // pAllowHaltDueToClock
|
||||||
|
|
||||||
|
15, // uint8_t AllowPassiveToActiveCyclePairs INIT(0); // pAllowPassiveToActive
|
||||||
|
|
||||||
|
2, // uint8_t ClusterDriftDamping INIT(0); // pClusterDriftDamping
|
||||||
|
|
||||||
|
true, // bool ChannelA INIT(false); // pChannels
|
||||||
|
true, // bool ChannelB INIT(false); // pChannels
|
||||||
|
|
||||||
|
56, // uint8_t DecodingCorrectionMicroticks INIT(0); // pDecodingCorrection
|
||||||
|
28, // uint8_t DelayCompensationAMicroticks INIT(0); // pDelayCompensation[A]
|
||||||
|
28, // uint8_t DelayCompensationBMicroticks INIT(0); // pDelayCompensation[B]
|
||||||
|
0, // uint8_t ExternOffsetCorrectionControl INIT(0); // pExternOffsetControl
|
||||||
|
0, // uint8_t ExternRateCorrectionControl INIT(0); // pExternRateControl
|
||||||
|
0, // uint8_t ExternOffsetCorrectionMicroticks INIT(0); // pExternOffsetCorrection
|
||||||
|
0, // uint8_t ExternRateCorrectionMicroticks INIT(0); // pExternRateCorrection
|
||||||
|
|
||||||
|
0, // uint16_t KeySlotID INIT(0);
|
||||||
|
|
||||||
|
false, // bool KeySlotOnlyEnabled INIT(false); // pSingleSlotEnabled (TSM)
|
||||||
|
true, // bool KeySlotUsedForStartup INIT(false); // pKeySlotUsedForStartup (TXST)
|
||||||
|
true, // bool KeySlotUsedForSync INIT(false); // pKeySlotUsedForSync (TXSY)
|
||||||
|
|
||||||
|
226, // uint16_t LatestTxMinislot INIT(0); // pLatestTx
|
||||||
|
401202, // uint32_t ListenTimeout INIT(0); // pdListenTimeout
|
||||||
|
|
||||||
|
7, // uint8_t MacroInitialOffsetA INIT(0); // pMacroInitialOffset[A], Valid 2..72
|
||||||
|
7, // uint8_t MacroInitialOffsetB INIT(0); // pMacroInitialOffset[B], Valid 2..72
|
||||||
|
|
||||||
|
36, // uint8_t MicroInitialOffsetA INIT(0); // pMicroInitialOffset[A], Valid 0..240
|
||||||
|
36, // uint8_t MicroInitialOffsetB INIT(0); // pMicroInitialOffset[B], Valid 0..240
|
||||||
|
|
||||||
|
200000, // uint32_t MicroPerCycle INIT(0); // pMicroPerCycle
|
||||||
|
|
||||||
|
false, // bool MTSOnA INIT(false);
|
||||||
|
false, // bool MTSOnB INIT(false);
|
||||||
|
|
||||||
|
189, // uint16_t OffsetCorrectionOutMicroticks INIT(0); // pOffsetCorrectionOut
|
||||||
|
601, // uint16_t RateCorrectionOutMicroticks INIT(0); // pdMaxDrift and pRateCorrectionOut
|
||||||
|
|
||||||
|
0, // uint16_t SecondKeySlotID INIT(0);
|
||||||
|
false, // bool TwoKeySlotMode INIT(false);
|
||||||
|
|
||||||
|
55, // uint8_t WakeupPattern INIT(0);
|
||||||
|
false, // bool WakeupOnChannelB INIT(false); // pWakeupChannel
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Cluster = icsneo::FlexRay::Cluster;
|
||||||
|
|
||||||
|
static const Cluster::Configuration DefaultClusterConfig {
|
||||||
|
Cluster::SpeedType::FLEXRAY_BAUDRATE_10M, // neoflexray_speed_t Speed INIT(FLEXRAY_BAUDRATE_10M /* = 0 */); // gdSampleClockPeriod, pSamplesPerMicrotick, Baud Rate Prescaler
|
||||||
|
Cluster::SPPType::FLEXRAY_SPP_5, // neoflexray_spp_t StrobePointPosition INIT(FLEXRAY_SPP_5 /* = 0 */);
|
||||||
|
|
||||||
|
4, // uint8_t ActionPointOffset INIT(0); // gdActionPointOffset
|
||||||
|
64, // uint8_t CASRxLowMax INIT(0); // gdCASRxLowMax
|
||||||
|
8, // uint8_t ColdStartAttempts INIT(0); // gColdStartAttempts
|
||||||
|
5000, // uint16_t CycleDurationMicroSec INIT(0); // gdCycle
|
||||||
|
1, // uint8_t DynamicSlotIdlePhaseMinislots INIT(0); // gdDynamicSlotIdlePhase, In Minislot increments [0..2]
|
||||||
|
4, // uint8_t ListenNoiseMacroticks INIT(0); // gListenNoise
|
||||||
|
5000, // uint16_t MacroticksPerCycle INIT(0); // gMacroPerCycle
|
||||||
|
1, // uint8_t MacrotickDurationMicroSec INIT(0); // gdMacroTick
|
||||||
|
2, // uint8_t MaxWithoutClockCorrectionFatal INIT(0); // gMaxWithoutClockCorrectionFatal
|
||||||
|
2, // uint8_t MaxWithoutClockCorrectionPassive INIT(0); // gMaxWithoutClockCorrectionPassive
|
||||||
|
4, // uint8_t MinislotActionPointOffsetMacroticks INIT(0); // gdMinislotActionPointOffset
|
||||||
|
10, // uint32_t MinislotDurationMacroticks INIT(0); // gdMinislot
|
||||||
|
40, // uint32_t NetworkIdleTimeMacroticks INIT(0); // gdNIT
|
||||||
|
1, // uint8_t NetworkManagementVectorLengthBytes INIT(0); // gNetworkManagementVectorLength
|
||||||
|
0, // uint32_t NumberOfMinislots INIT(0); // gNumberOfMinislots
|
||||||
|
32, // uint16_t NumberOfStaticSlots INIT(0); // gdNumberOfStaticSlots
|
||||||
|
4991, // uint32_t OffsetCorrectionStartMacroticks INIT(0); // gOffsetCorrectionStart
|
||||||
|
67, // uint8_t PayloadLengthOfStaticSlotInWords INIT(0); // gPayloadLengthStatic
|
||||||
|
|
||||||
|
155, // uint16_t StaticSlotMacroticks INIT(0); // gdStaticSlot
|
||||||
|
0, // uint32_t SymbolWindowMacroticks INIT(0); // gdSymbolWindow
|
||||||
|
0, // uint32_t SymbolWindowActionPointOffsetMacroticks INIT(0);
|
||||||
|
15, // uint16_t SyncFrameIDCountMax INIT(0); // gSyncNodeMax
|
||||||
|
|
||||||
|
11, // uint8_t TransmissionStartSequenceDurationBits INIT(0); // gdTSSTransmitter
|
||||||
|
40, // uint8_t WakeupRxIdleBits INIT(0); // gdWakeupSymbolRxIdle
|
||||||
|
40, // uint8_t WakeupRxLowBits INIT(0); // gdWakeupSymbolRxLow
|
||||||
|
301, // uint16_t WakeupRxWindowBits INIT(0); // gdWakeupSymbolRxWindow
|
||||||
|
60, // uint8_t WakeupTxActiveBits INIT(0); // gdWakeupSymbolTxLow (active = low here)
|
||||||
|
180, // uint8_t WakeupTxIdleBits INIT(0); // gdWakeupSymbolTxIdle
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::condition_variable cv;
|
||||||
|
static std::mutex msgRcvdMutex;
|
||||||
|
|
||||||
|
void configureFlexRayDevice(std::shared_ptr<icsneo::Device> device) {
|
||||||
|
auto controllers = device->getFlexRayControllers();
|
||||||
|
for (uint16_t i = 0; i < controllers.size(); i++) {
|
||||||
|
auto controller = controllers[i];
|
||||||
|
icsneo::FlexRay::Cluster::Configuration clusterConfig = DefaultClusterConfig;
|
||||||
|
icsneo::FlexRay::Controller::Configuration controllerConfig = DefaultControllerConfig;
|
||||||
|
controller->setAllowColdstart(true);
|
||||||
|
controllerConfig.KeySlotID = (i == 0) ? SlotOne : SlotTwo;
|
||||||
|
controller->setConfiguration(clusterConfig, controllerConfig);
|
||||||
|
controller->setStartWhenGoingOnline(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<icsneo::FlexRayMessage>> makeDummyFlexRayMessages(size_t msgCount, size_t msgLen) {
|
||||||
|
std::vector<std::shared_ptr<icsneo::FlexRayMessage>> messages;
|
||||||
|
messages.reserve(msgCount);
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 engine(rd());
|
||||||
|
std::uniform_int_distribution<unsigned short> dist(0, 255);
|
||||||
|
for (size_t i = 0; i < msgCount; i++) {
|
||||||
|
auto msg = std::make_shared<icsneo::FlexRayMessage>();
|
||||||
|
msg->network = icsneo::Network::NetID::FLEXRAY_01;
|
||||||
|
msg->cycleRepetition = 1;
|
||||||
|
msg->channel = icsneo::FlexRay::Channel::AB;
|
||||||
|
msg->data.reserve(msgLen);
|
||||||
|
for (size_t j = 0; j < msgLen; j++) {
|
||||||
|
msg->data.push_back(static_cast<uint8_t>(dist(engine)));
|
||||||
|
}
|
||||||
|
msg->slotid = (i % 2 == 0) ? SlotOne : SlotTwo;
|
||||||
|
messages.push_back(msg);
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
auto devices = icsneo::FindAllDevices();
|
||||||
|
std::shared_ptr<icsneo::Device> flexrayDevice = nullptr;
|
||||||
|
for (auto&& device : devices) {
|
||||||
|
if (device->getExtension("FlexRay")) {
|
||||||
|
flexrayDevice = device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flexrayDevice) {
|
||||||
|
std::cout << "Found device " << flexrayDevice->getProductName() << " " << flexrayDevice->getSerial() << " which supports FlexRay." << std::endl;
|
||||||
|
auto&& controllers = flexrayDevice->getFlexRayControllers();
|
||||||
|
if (controllers.size() > 0) {
|
||||||
|
std::vector<std::shared_ptr<icsneo::FlexRayMessage>> messages;
|
||||||
|
size_t currentMessage = 0;
|
||||||
|
auto filter = std::make_shared<icsneo::MessageFilter>(icsneo::Network::NetID::FLEXRAY_01);
|
||||||
|
auto rxCallback = [&messages, ¤tMessage](std::shared_ptr<icsneo::Message> message) -> void {
|
||||||
|
std::unique_lock lk(msgRcvdMutex);
|
||||||
|
auto frmsg = std::static_pointer_cast<icsneo::FlexRayMessage>(message);
|
||||||
|
if (currentMessage < messages.size() && frmsg->data.size() > 1 && frmsg->data == messages[currentMessage]->data) {
|
||||||
|
if (!SuppressRxTxDebugMessages) {
|
||||||
|
std::cout << "Message Number " << currentMessage + 1 << " received." << std::endl;
|
||||||
|
}
|
||||||
|
currentMessage++;
|
||||||
|
lk.unlock();
|
||||||
|
cv.notify_all();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto cb = std::make_shared<icsneo::MessageCallback>(rxCallback, filter);
|
||||||
|
auto cbId = flexrayDevice->addMessageCallback(cb);
|
||||||
|
messages = makeDummyFlexRayMessages(NumMessages, FramePayloadSize);
|
||||||
|
configureFlexRayDevice(flexrayDevice);
|
||||||
|
if (!flexrayDevice->open()) {
|
||||||
|
std::cerr << "Device open failed." << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!flexrayDevice->goOnline()) {
|
||||||
|
std::cerr << "Device go online failed." << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
std::cout << "Transmitting " << NumMessages << " FlexRay frames." << std::endl;
|
||||||
|
for (auto msg : messages) {
|
||||||
|
std::unique_lock lk(msgRcvdMutex);
|
||||||
|
if (!flexrayDevice->transmit(msg)) {
|
||||||
|
std::cerr << "Failed to transmit message." << std::endl;
|
||||||
|
return -1;
|
||||||
|
} else if (!SuppressRxTxDebugMessages) {
|
||||||
|
std::cout << "Message Number " << currentMessage + 1 << " transmitted." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cv.wait(lk);
|
||||||
|
lk.unlock();
|
||||||
|
}
|
||||||
|
std::cout << "All transmitted frames received." << std::endl;
|
||||||
|
flexrayDevice->removeMessageCallback(cbId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "Unable to find a device which supports FlexRay." << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Finished." << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ If you haven't done this, `third-party/libicsneo` will be empty and you won't be
|
|||||||
|
|
||||||
### Ubuntu 18.04 LTS
|
### Ubuntu 18.04 LTS
|
||||||
|
|
||||||
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev`
|
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libpcap0.8-dev`
|
||||||
2. Change directories to your `libicsneo-examples/libicsneocpp-example` folder and create a build directory by running `mkdir -p build`
|
2. Change directories to your `libicsneo-examples/libicsneocpp-example` folder and create a build directory by running `mkdir -p build`
|
||||||
3. Enter the build directory with `cd build`
|
3. Enter the build directory with `cd build`
|
||||||
4. Run `cmake ..` to generate your Makefile.
|
4. Run `cmake ..` to generate your Makefile.
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ void printMessage(const std::shared_ptr<icsneo::Message>& message) {
|
|||||||
std::cout << std::dec << '(' << canMessage->timestamp << " ns since 1/1/2007)\n";
|
std::cout << std::dec << '(' << canMessage->timestamp << " ns since 1/1/2007)\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case icsneo::Network::Type::Ethernet: {
|
case icsneo::Network::Type::Ethernet:
|
||||||
|
case icsneo::Network::Type::AutomotiveEthernet: {
|
||||||
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
|
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
|
||||||
|
|
||||||
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec
|
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ int main() {
|
|||||||
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LATITUDE);
|
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LATITUDE);
|
||||||
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LONGITUDE);
|
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_LONGITUDE);
|
||||||
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_ACCURACY);
|
msg->appendSignalArg(icsneo::LiveDataValueType::GPS_ACCURACY);
|
||||||
|
msg->appendSignalArg(icsneo::LiveDataValueType::DAQ_ENABLE);
|
||||||
|
msg->appendSignalArg(icsneo::LiveDataValueType::MANUAL_TRIGGER);
|
||||||
msg->cmd = icsneo::LiveDataCommand::SUBSCRIBE;
|
msg->cmd = icsneo::LiveDataCommand::SUBSCRIBE;
|
||||||
msg->handle = icsneo::LiveDataUtil::getNewHandle();
|
msg->handle = icsneo::LiveDataUtil::getNewHandle();
|
||||||
msg->updatePeriod = std::chrono::milliseconds(100);
|
msg->updatePeriod = std::chrono::milliseconds(100);
|
||||||
@@ -77,6 +79,26 @@ int main() {
|
|||||||
}));
|
}));
|
||||||
// Run handler for three seconds to observe the signal data
|
// Run handler for three seconds to observe the signal data
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
double val = 0;
|
||||||
|
for (unsigned int i = 0; i < 10; ++i) {
|
||||||
|
// Set the values of signals we're watching so we can see them change live
|
||||||
|
auto setValMsg = std::make_shared<icsneo::LiveDataSetValueMessage>();
|
||||||
|
setValMsg->cmd = icsneo::LiveDataCommand::SET_VALUE;
|
||||||
|
setValMsg->handle = msg->handle;
|
||||||
|
// Convert the value format
|
||||||
|
icsneo::LiveDataValue ldValueDAQEnable;
|
||||||
|
icsneo::LiveDataValue ldValueManTrig;
|
||||||
|
if (!icsneo::LiveDataUtil::liveDataDoubleToValue(val / 3, ldValueDAQEnable) ||
|
||||||
|
!icsneo::LiveDataUtil::liveDataDoubleToValue(val, ldValueManTrig)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setValMsg->appendSetValue(icsneo::LiveDataValueType::DAQ_ENABLE, ldValueDAQEnable);
|
||||||
|
setValMsg->appendSetValue(icsneo::LiveDataValueType::MANUAL_TRIGGER, ldValueManTrig);
|
||||||
|
device->setValueLiveData(setValMsg);
|
||||||
|
++val;
|
||||||
|
// Run handler for three seconds to observe the signal data
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
}
|
||||||
// Unsubscribe from the GPS signals and run handler for one more second
|
// Unsubscribe from the GPS signals and run handler for one more second
|
||||||
// Unsubscription only requires a valid in-use handle, in this case from our previous subscription
|
// Unsubscription only requires a valid in-use handle, in this case from our previous subscription
|
||||||
ret = device->unsubscribeLiveData(msg->handle);
|
ret = device->unsubscribeLiveData(msg->handle);
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
add_executable(libicsneocpp-mutex-example src/MutexExample.cpp)
|
||||||
|
target_link_libraries(libicsneocpp-mutex-example icsneocpp)
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
#include <numeric>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include "icsneo/icsneocpp.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4996) // STL time functions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static std::vector<std::shared_ptr<icsneo::Device>> findDevices(icsneo::DeviceType type)
|
||||||
|
{
|
||||||
|
std::vector<std::shared_ptr<icsneo::Device>> ret;
|
||||||
|
for(auto&& dev : icsneo::FindAllDevices()) {
|
||||||
|
if(dev->getType() == type) {
|
||||||
|
ret.push_back(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<icsneo::Network> supported_nets;
|
||||||
|
static std::unordered_map<icsneo::Network::NetID, icsneo::NetworkMutexEvent> network_mutex_states;
|
||||||
|
constexpr uint32_t MUTEX_PRIORITY = 12345678;
|
||||||
|
constexpr uint32_t MUTEX_TTL_MS = 2500;
|
||||||
|
|
||||||
|
static void on_mutex_event(std::shared_ptr<icsneo::Message> msg) {
|
||||||
|
if(msg->type == icsneo::Message::Type::NetworkMutex) {
|
||||||
|
auto nmm = std::static_pointer_cast<icsneo::NetworkMutexMessage>(msg);
|
||||||
|
if(nmm->event.has_value() && nmm->networks.size())
|
||||||
|
{
|
||||||
|
auto network = *nmm->networks.begin();
|
||||||
|
if(std::find_if(supported_nets.begin(), supported_nets.end(), [network](const icsneo::Network& net){ return net.getNetID() == network; }) != supported_nets.end())
|
||||||
|
{
|
||||||
|
std::cout << icsneo::Network::GetNetIDString(static_cast<icsneo::Network::NetID>(network)) << ": Mutex " << icsneo::NetworkMutexMessage::GetNetworkMutexEventString(nmm->event.value()) << std::endl;
|
||||||
|
network_mutex_states[network] = *nmm->event;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void do_mutexed_operation(std::shared_ptr<icsneo::Device> device, icsneo::Network::NetID network, std::function<void()>&& operation)
|
||||||
|
{
|
||||||
|
// Demonstrate taking a mutex on a single / group of networks
|
||||||
|
auto lt = device->lockNetworks({network}, MUTEX_PRIORITY, MUTEX_TTL_MS, icsneo::NetworkMutexType::TxExclusive, on_mutex_event);
|
||||||
|
if(lt.has_value()) {
|
||||||
|
while(network_mutex_states.find(network) == network_mutex_states.end() ||
|
||||||
|
network_mutex_states[network] != icsneo::NetworkMutexEvent::Acquired)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
operation();
|
||||||
|
|
||||||
|
device->unlockNetworks({network});
|
||||||
|
while(network_mutex_states.find(network) != network_mutex_states.end() &&
|
||||||
|
network_mutex_states[network] == icsneo::NetworkMutexEvent::Acquired)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
}
|
||||||
|
device->removeMessageCallback(*lt);
|
||||||
|
} else {
|
||||||
|
std::cout << "Failed to acquire mutex for " << icsneo::Network::GetNetIDString(network) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// Print version
|
||||||
|
std::cout << "libicsneo version " << icsneo::GetVersion() << std::endl;
|
||||||
|
|
||||||
|
std::cout << "\nFinding devices... " << std::flush;
|
||||||
|
auto devices = findDevices(icsneo::DeviceType::FIRE3);
|
||||||
|
// You now hold the shared_ptrs for these devices, you are considered to "own" these devices from a memory perspective
|
||||||
|
std::cout << "OK, " << devices.size() << " device" << (devices.size() == 1 ? "" : "s") << " found" << std::endl;
|
||||||
|
|
||||||
|
// List off the devices
|
||||||
|
for(auto& device : devices)
|
||||||
|
std::cout << '\t' << device->describe() << " @ Handle " << device->getNeoDevice().handle << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
for(auto& device : devices) {
|
||||||
|
std::cout << "Connecting to " << device->describe() << "... ";
|
||||||
|
bool ret = device->open();
|
||||||
|
if(!ret) { // Failed to open
|
||||||
|
std::cout << "FAIL" << std::endl;
|
||||||
|
std::cout << icsneo::GetLastError() << std::endl << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::cout << "OK" << std::endl;
|
||||||
|
|
||||||
|
supported_nets = device->getSupportedTXNetworks();
|
||||||
|
|
||||||
|
device->goOnline();
|
||||||
|
|
||||||
|
// Demonstrate lock and unlock all networks
|
||||||
|
std::cout << "Requesting global exclusive network mutex" << std::endl;
|
||||||
|
auto lt = device->lockAllNetworks(MUTEX_PRIORITY, MUTEX_TTL_MS, icsneo::NetworkMutexType::TxExclusive, on_mutex_event);
|
||||||
|
if(lt.has_value()) {
|
||||||
|
// wait until we have the mutex on all networks
|
||||||
|
auto all_nets = device->getSupportedTXNetworks();
|
||||||
|
for(auto net = all_nets.begin(); net != all_nets.end();) {
|
||||||
|
auto state = network_mutex_states.find(net->getNetID());
|
||||||
|
if(state != network_mutex_states.end() && state->second == icsneo::NetworkMutexEvent::Acquired) {
|
||||||
|
net = all_nets.erase(net);
|
||||||
|
} else {
|
||||||
|
++net;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "Acquired mutex for all supported networks on " << device->describe() << std::endl;
|
||||||
|
|
||||||
|
// request release
|
||||||
|
if(device->unlockAllNetworks()) {
|
||||||
|
std::cout << "Requested release of all networks" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "Failed to request release of all networks" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait until we have released the mutex on all networks
|
||||||
|
all_nets = device->getSupportedTXNetworks();
|
||||||
|
for(auto net = all_nets.begin(); net != all_nets.end();) {
|
||||||
|
auto state = network_mutex_states.find(net->getNetID());
|
||||||
|
if(state == network_mutex_states.end() || state->second == icsneo::NetworkMutexEvent::Released) {
|
||||||
|
net = all_nets.erase(net);
|
||||||
|
} else {
|
||||||
|
++net;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "released mutex on all supported networks" << std::endl;
|
||||||
|
|
||||||
|
device->removeMessageCallback(*lt);
|
||||||
|
} else {
|
||||||
|
std::cout << "Failed to acquire global mutex" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Doing mutexed operation on DWCAN 01" << std::endl;
|
||||||
|
do_mutexed_operation(device, icsneo::Network::NetID::DWCAN_01, [&](){
|
||||||
|
auto tx_message = std::make_shared<icsneo::CANMessage>();
|
||||||
|
tx_message->arbid = 0x12;
|
||||||
|
tx_message->isCANFD = true;
|
||||||
|
tx_message->baudrateSwitch = true;
|
||||||
|
tx_message->data.resize(64);
|
||||||
|
tx_message->network = icsneo::Network::NetID::DWCAN_01;
|
||||||
|
constexpr auto txInterval = std::chrono::microseconds(500);
|
||||||
|
auto nextRefresh = std::chrono::steady_clock::now() + std::chrono::milliseconds(MUTEX_TTL_MS / 2);
|
||||||
|
auto nextTx = std::chrono::steady_clock::now() + txInterval;
|
||||||
|
size_t numTx = 0;
|
||||||
|
while(numTx < 5000) {
|
||||||
|
if(std::chrono::steady_clock::now() < nextTx) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nextTx = std::chrono::steady_clock::now() + txInterval;
|
||||||
|
std::iota(tx_message->data.begin(), tx_message->data.end(), (uint8_t)(numTx & 0xFF));
|
||||||
|
if(device->transmit(tx_message)) {
|
||||||
|
++numTx;
|
||||||
|
}
|
||||||
|
// check the mutex periodically - every 200 messages for demonstrative purposes
|
||||||
|
if(std::chrono::steady_clock::now() > nextRefresh) {
|
||||||
|
auto status = device->getNetworkMutexStatus(icsneo::Network::NetID::DWCAN_01);
|
||||||
|
if(!status) {
|
||||||
|
std::cout << "failed to poll status of network mutex for DWCAN 01" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "DWCAN 01 mutex TTL: " << *status->ttlMs << " ms" << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << "refreshing mutex on DWCAN 01, current tx count: " << numTx << std::endl;
|
||||||
|
(void)device->lockNetworks({icsneo::Network::NetID::DWCAN_01}, MUTEX_PRIORITY, MUTEX_TTL_MS, icsneo::NetworkMutexType::TxExclusive, nullptr);
|
||||||
|
nextRefresh = std::chrono::steady_clock::now() + std::chrono::milliseconds(MUTEX_TTL_MS / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
std::cout << "Completed mutexed operation on DWCAN 01" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "Doing mutexed operation on Ethernet 03" << std::endl;
|
||||||
|
do_mutexed_operation(device, icsneo::Network::NetID::ETHERNET_03, [&](){
|
||||||
|
auto tx_message = std::make_shared<icsneo::EthernetMessage>();
|
||||||
|
tx_message->data.resize(512);
|
||||||
|
// set mac addresses and ethertype
|
||||||
|
std::iota(tx_message->data.begin(), tx_message->data.begin() + 14, static_cast<uint8_t>(0x01));
|
||||||
|
tx_message->network = icsneo::Network::NetID::ETHERNET_03;
|
||||||
|
constexpr auto txInterval = std::chrono::microseconds(250);
|
||||||
|
auto nextRefresh = std::chrono::steady_clock::now() + std::chrono::milliseconds(MUTEX_TTL_MS / 2);
|
||||||
|
auto nextTx = std::chrono::steady_clock::now() + txInterval;
|
||||||
|
size_t numTx = 0;
|
||||||
|
while(numTx < 50000) {
|
||||||
|
if(std::chrono::steady_clock::now() < nextTx) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nextTx = std::chrono::steady_clock::now() + txInterval;
|
||||||
|
// keep the mac addresses and ethertype constant
|
||||||
|
std::iota(tx_message->data.begin() + 14, tx_message->data.end(), (uint8_t)(numTx & 0xFF));
|
||||||
|
if(device->transmit(tx_message)) {
|
||||||
|
++numTx;
|
||||||
|
}
|
||||||
|
if(std::chrono::steady_clock::now() > nextRefresh) {
|
||||||
|
auto status = device->getNetworkMutexStatus(icsneo::Network::NetID::ETHERNET_03);
|
||||||
|
if(!status) {
|
||||||
|
std::cout << "failed to poll status of network mutex for Ethernet 03" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "Ethernet 03 mutex TTL: " << *status->ttlMs << " ms" << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << "refreshing mutex on Ethernet 03, current tx count: " << numTx << std::endl;
|
||||||
|
(void)device->lockNetworks({icsneo::Network::NetID::ETHERNET_03}, MUTEX_PRIORITY, MUTEX_TTL_MS, icsneo::NetworkMutexType::TxExclusive, nullptr);
|
||||||
|
nextRefresh = std::chrono::steady_clock::now() + std::chrono::milliseconds(MUTEX_TTL_MS / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
std::cout << "Completed mutexed operation on Ethernet 03" << std::endl;
|
||||||
|
|
||||||
|
device->close();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ If you haven't done this, `third-party/libicsneo` will be empty and you won't be
|
|||||||
|
|
||||||
### Ubuntu 18.04 LTS
|
### Ubuntu 18.04 LTS
|
||||||
|
|
||||||
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev`
|
1. Install dependencies with `sudo apt update` then `sudo apt install build-essential cmake libpcap0.8-dev`
|
||||||
2. Change directories to your `libicsneo-examples/libicsneocpp-example` folder and create a build directory by running `mkdir -p build`
|
2. Change directories to your `libicsneo-examples/libicsneocpp-example` folder and create a build directory by running `mkdir -p build`
|
||||||
3. Enter the build directory with `cd build`
|
3. Enter the build directory with `cd build`
|
||||||
4. Run `cmake ..` to generate your Makefile.
|
4. Run `cmake ..` to generate your Makefile.
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ int main() {
|
|||||||
std::cout << std::dec << '(' << canMessage->timestamp << " ns since 1/1/2007)\n";
|
std::cout << std::dec << '(' << canMessage->timestamp << " ns since 1/1/2007)\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case icsneo::Network::Type::Ethernet: {
|
case icsneo::Network::Type::Ethernet:
|
||||||
|
case icsneo::Network::Type::AutomotiveEthernet: {
|
||||||
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
|
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
|
||||||
|
|
||||||
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec
|
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
add_executable(libicsneocpp-spi src/spi.cpp)
|
||||||
|
target_link_libraries(libicsneocpp-spi icsneocpp)
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
/**
|
||||||
|
* libicsneo SPI message example
|
||||||
|
*
|
||||||
|
* Read a register on NetID::SPI_01 and display the result to stdout
|
||||||
|
*
|
||||||
|
* Usage: libicsneo-spi [deviceSerial] [address] [numWords]
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* deviceSerial: 6 character string for device serial
|
||||||
|
* address: 16 bit register address
|
||||||
|
* numWords: number of words to read
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
#include <string_view>
|
||||||
|
#include <utility>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#include "icsneo/icsneocpp.h"
|
||||||
|
#include "icsneo/communication/message/spimessage.h"
|
||||||
|
|
||||||
|
static const std::string usage = "Usage: libicsneo-spi [deviceSerial] [address] [numWords]\n\n"
|
||||||
|
"Arguments:\n"
|
||||||
|
"deviceSerial: 6 character string for device serial\n"
|
||||||
|
"address: hex number representing 16 bit register number\n"
|
||||||
|
"numWords: number of words to read\n";
|
||||||
|
|
||||||
|
static std::tuple<std::string_view, uint16_t, uint16_t> parseArgs(std::vector<std::string_view>& args, bool& fail) {
|
||||||
|
|
||||||
|
if(args.size() != 4) {
|
||||||
|
std::cerr << "Invalid argument count" << std::endl;
|
||||||
|
std::cerr << usage;
|
||||||
|
fail = true;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view serial = args[1];
|
||||||
|
if(serial.size() != 6) {
|
||||||
|
std::cerr << "Invalid serial length" << std::endl;
|
||||||
|
std::cerr << usage;
|
||||||
|
fail = true;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
char* endPtr;
|
||||||
|
uint16_t address = static_cast<uint16_t>(std::strtoul(args[2].data(), &endPtr, 16));
|
||||||
|
if(endPtr != (args[2].data() + args[2].size())) {
|
||||||
|
std::cerr << "Failed to convert address to hex" << std::endl;
|
||||||
|
std::cerr << usage;
|
||||||
|
fail = true;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t numWords = static_cast<uint16_t>(std::strtoul(args[3].data(), &endPtr, 16));
|
||||||
|
if(endPtr != (args[3].data() + args[3].size())) {
|
||||||
|
std::cerr << "Failed to convert numWords to decimal integer" << std::endl;
|
||||||
|
std::cerr << usage;
|
||||||
|
fail = true;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
fail = false;
|
||||||
|
return {serial, address, numWords};
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char** argv) {
|
||||||
|
std::vector<std::string_view> args(argv, argv + argc);
|
||||||
|
bool fail;
|
||||||
|
auto tup = parseArgs(args, fail);
|
||||||
|
if(fail) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
auto serial = std::get<0>(tup);
|
||||||
|
auto address = std::get<1>(tup);
|
||||||
|
auto numWords = std::get<2>(tup);
|
||||||
|
|
||||||
|
std::shared_ptr<icsneo::Device> device = nullptr;
|
||||||
|
for(const auto& dev : icsneo::FindAllDevices()) {
|
||||||
|
if(dev->getSerial() == serial) {
|
||||||
|
device = dev;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!device) {
|
||||||
|
std::cerr << "Failed to find device" << std::endl;
|
||||||
|
std::cerr << usage;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!device->open()) {
|
||||||
|
std::cerr << "Failed to open device" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!device->goOnline()) {
|
||||||
|
std::cerr << "Failed to go online" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Reading register " << std::setfill('0') << std::setw(4) << std::right << std::hex << address << std::endl;
|
||||||
|
|
||||||
|
// Make message
|
||||||
|
std::shared_ptr<icsneo::SPIMessage> msg = std::make_shared<icsneo::SPIMessage>();
|
||||||
|
msg->network = icsneo::Network::NetID::SPI_01;
|
||||||
|
msg->direction = icsneo::SPIMessage::Direction::Read;
|
||||||
|
msg->address = address;
|
||||||
|
msg->payload.resize(numWords, 0); // Resize payload to desired length
|
||||||
|
|
||||||
|
// Add callback
|
||||||
|
bool receivedMessage = false;
|
||||||
|
auto handle = device->addMessageCallback(std::make_shared<icsneo::MessageCallback>([&](std::shared_ptr<icsneo::Message> msg) {
|
||||||
|
if(receivedMessage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(msg->type == icsneo::Message::Type::Frame) {
|
||||||
|
auto frame = std::dynamic_pointer_cast<icsneo::Frame>(msg);
|
||||||
|
if(!frame) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(frame->network == icsneo::Network::NetID::SPI_01) {
|
||||||
|
auto spiMsg = std::dynamic_pointer_cast<icsneo::SPIMessage>(frame);
|
||||||
|
if(spiMsg->address == address) {
|
||||||
|
std::cout << "Received " << spiMsg->payload.size() << " words" << std::endl;
|
||||||
|
for(uint32_t word : spiMsg->payload) {
|
||||||
|
std::cout << std::setfill('0') << std::setw(8) << std::right << std::hex << word << ' ';
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
receivedMessage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
device->transmit(msg);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||||
|
|
||||||
|
if(!receivedMessage) {
|
||||||
|
std::cout << "Did not receive response from device." << std::endl;
|
||||||
|
}
|
||||||
|
device->removeMessageCallback(handle);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -172,7 +172,7 @@ int main(int argc, char* argv[]) {
|
|||||||
const auto frame = std::static_pointer_cast<icsneo::Frame>(msg);
|
const auto frame = std::static_pointer_cast<icsneo::Frame>(msg);
|
||||||
if(frame->network.getType() == icsneo::Network::Type::CAN) {
|
if(frame->network.getType() == icsneo::Network::Type::CAN) {
|
||||||
++canFrameCount;
|
++canFrameCount;
|
||||||
} else if(frame->network.getType() == icsneo::Network::Type::Ethernet) {
|
} else if(frame->network.getType() == icsneo::Network::Type::AutomotiveEthernet || frame->network.getType() == icsneo::Network::Type::Ethernet) {
|
||||||
++ethFrameCount;
|
++ethFrameCount;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -239,6 +239,9 @@ int main(int argc, char* argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Waiting for 5 seconds..." << std::endl;
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
|
|
||||||
std::cout << "info: " << currentMessage << " transmitted frames found" << std::endl;
|
std::cout << "info: " << currentMessage << " transmitted frames found" << std::endl;
|
||||||
resetScriptStatus(rxDevice, txDevice, rxInitialCoreminiStatus, txInitialCoreminiStatus);
|
resetScriptStatus(rxDevice, txDevice, rxInitialCoreminiStatus, txInitialCoreminiStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
"""
|
||||||
|
Complete CAN example using icsneopy library.
|
||||||
|
|
||||||
|
Demonstrates device setup and CAN frame transmission/reception.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import icsneopy
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def setup_device():
|
||||||
|
"""Initialize CAN device."""
|
||||||
|
devices = icsneopy.find_all_devices()
|
||||||
|
if not devices:
|
||||||
|
raise RuntimeError("No devices found")
|
||||||
|
|
||||||
|
device = devices[0]
|
||||||
|
print(f"Using device: {device}")
|
||||||
|
return device
|
||||||
|
|
||||||
|
|
||||||
|
def open_device(device):
|
||||||
|
"""Open device connection."""
|
||||||
|
try:
|
||||||
|
if not device.open():
|
||||||
|
raise RuntimeError("Failed to open device")
|
||||||
|
|
||||||
|
if not device.go_online():
|
||||||
|
device.close()
|
||||||
|
raise RuntimeError("Failed to go online")
|
||||||
|
|
||||||
|
print("Device initialized successfully")
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Device setup failed: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def transmit_can_frame(device, arbid, data):
|
||||||
|
"""Transmit a CAN frame."""
|
||||||
|
frame = icsneopy.CANMessage()
|
||||||
|
frame.network = icsneopy.Network(icsneopy.Network.NetID.DWCAN_01)
|
||||||
|
frame.arbid = arbid
|
||||||
|
frame.data = data
|
||||||
|
|
||||||
|
success = device.transmit(frame)
|
||||||
|
if success:
|
||||||
|
print(f"Frame transmitted: ID=0x{arbid:03X}, Data={list(data)}")
|
||||||
|
else:
|
||||||
|
print(f"Failed to transmit frame ID=0x{arbid:03X}")
|
||||||
|
|
||||||
|
return success
|
||||||
|
|
||||||
|
|
||||||
|
def setup_can_reception(device):
|
||||||
|
"""Configure CAN frame reception with callback."""
|
||||||
|
frame_count = 0
|
||||||
|
|
||||||
|
def frame_handler(frame):
|
||||||
|
nonlocal frame_count
|
||||||
|
frame_count += 1
|
||||||
|
print(f"[RX {frame_count}] ID: 0x{frame.arbid:03X}, "
|
||||||
|
f"Data: {[hex(b) for b in frame.data]}, "
|
||||||
|
f"Length: {len(frame.data)}")
|
||||||
|
|
||||||
|
frame_filter = icsneopy.MessageFilter(icsneopy.Network.NetID.DWCAN_01)
|
||||||
|
callback = icsneopy.MessageCallback(frame_handler, frame_filter)
|
||||||
|
device.add_message_callback(callback)
|
||||||
|
|
||||||
|
print("CAN frame reception configured")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_device(device):
|
||||||
|
"""Close device connection."""
|
||||||
|
if device:
|
||||||
|
device.close()
|
||||||
|
print("Device connection closed")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Complete CAN example with proper error handling."""
|
||||||
|
device = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Setup device
|
||||||
|
device = setup_device()
|
||||||
|
|
||||||
|
# Open device
|
||||||
|
if not open_device(device):
|
||||||
|
raise RuntimeError("Failed to initialize device")
|
||||||
|
|
||||||
|
# Setup frame reception
|
||||||
|
setup_can_reception(device)
|
||||||
|
|
||||||
|
# Transmit test frames
|
||||||
|
test_frames = [
|
||||||
|
(0x123, (0x01, 0x02, 0x03, 0x04)),
|
||||||
|
(0x456, (0x05, 0x06, 0x07, 0x08)),
|
||||||
|
(0x789, (0x09, 0x0A, 0x0B, 0x0C))
|
||||||
|
]
|
||||||
|
|
||||||
|
for arbid, data in test_frames:
|
||||||
|
transmit_result = transmit_can_frame(device, arbid, data)
|
||||||
|
if not transmit_result:
|
||||||
|
print(f"Warning: Failed to transmit frame ID=0x{arbid:03X}")
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
# Listen for responses
|
||||||
|
print("Listening for CAN frames for 5 seconds...")
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
finally:
|
||||||
|
cleanup_device(device)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
"""
|
||||||
|
Basic CAN frame reception example using icsneopy library.
|
||||||
|
|
||||||
|
Demonstrates how to receive CAN frames on DW CAN 01 using callback handlers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import icsneopy
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def receive_can_frames():
|
||||||
|
"""Receive CAN frames with callback handling."""
|
||||||
|
devices = icsneopy.find_all_devices()
|
||||||
|
if not devices:
|
||||||
|
raise RuntimeError("No devices found")
|
||||||
|
|
||||||
|
device = devices[0]
|
||||||
|
frame_count = 0
|
||||||
|
|
||||||
|
def on_frame(frame):
|
||||||
|
nonlocal frame_count
|
||||||
|
frame_count += 1
|
||||||
|
print(f"[RX {frame_count}] ID: 0x{frame.arbid:03X}, "
|
||||||
|
f"Data: {[hex(b) for b in frame.data]}")
|
||||||
|
|
||||||
|
frame_filter = icsneopy.MessageFilter(icsneopy.Network.NetID.DWCAN_01)
|
||||||
|
callback = icsneopy.MessageCallback(on_frame, frame_filter)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not device.open():
|
||||||
|
raise RuntimeError("Failed to open device")
|
||||||
|
|
||||||
|
if not device.go_online():
|
||||||
|
raise RuntimeError("Failed to go online")
|
||||||
|
|
||||||
|
device.add_message_callback(callback)
|
||||||
|
print("Listening for CAN frames for 10 seconds...")
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
print(f"Total frames received: {frame_count}")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
device.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
receive_can_frames()
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
Basic CAN frame transmission example using icsneopy library.
|
||||||
|
|
||||||
|
Demonstrates how to transmit CAN frames on DW CAN 01.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import icsneopy
|
||||||
|
|
||||||
|
|
||||||
|
def transmit_can_frame():
|
||||||
|
"""Transmit a CAN frame."""
|
||||||
|
devices = icsneopy.find_all_devices()
|
||||||
|
if not devices:
|
||||||
|
raise RuntimeError("No devices found")
|
||||||
|
|
||||||
|
device = devices[0]
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not device.open():
|
||||||
|
raise RuntimeError("Failed to open device")
|
||||||
|
|
||||||
|
if not device.go_online():
|
||||||
|
raise RuntimeError("Failed to go online")
|
||||||
|
|
||||||
|
frame = icsneopy.CANMessage()
|
||||||
|
frame.network = icsneopy.Network(icsneopy.Network.NetID.DWCAN_01)
|
||||||
|
frame.arbid = 0x123
|
||||||
|
frame.data = (0x01, 0x02, 0x03, 0x04)
|
||||||
|
|
||||||
|
success = device.transmit(frame)
|
||||||
|
if success:
|
||||||
|
print(f"Frame transmitted: ID=0x{frame.arbid:03X}")
|
||||||
|
else:
|
||||||
|
print("Failed to transmit frame")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
device.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
transmit_can_frame()
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user