mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-09-22 08:58:38 +02:00
Compare commits
22
Commits
1.1.0
..
5d672d48d4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d672d48d4 | ||
|
|
495632ddb7 | ||
|
|
3668b86f37 | ||
|
|
0bd733bc5d | ||
|
|
99a2ca4f0d | ||
|
|
ec350b522a | ||
|
|
895cd0792c | ||
|
|
a5ec9a2d20 | ||
|
|
b9d3dde8d5 | ||
|
|
11643e2281 | ||
|
|
f22d666f94 | ||
|
|
58b22da09b | ||
|
|
88d32128c9 | ||
|
|
6d82289864 | ||
|
|
674e905340 | ||
|
|
8b7e2556a0 | ||
|
|
fbdab1e998 | ||
|
|
f53bc2e920 | ||
|
|
a9e1f24f67 | ||
|
|
b10e29b8f5 | ||
|
|
3c0c0dd44c | ||
|
|
cf2cf3e28b |
@@ -2,25 +2,3 @@
|
||||
SUBSYSTEM=="usb", 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"
|
||||
|
||||
# neoVI ION/PLASMA PIDs are not in the latest ftdi_sio driver so lets make a
|
||||
# rule to add it when we see a new unclaimed device.
|
||||
# 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"
|
||||
|
||||
+8
-1
@@ -204,6 +204,7 @@ set(SRC_FILES
|
||||
communication/packet/flexraypacket.cpp
|
||||
communication/packet/canpacket.cpp
|
||||
communication/packet/a2bpacket.cpp
|
||||
communication/packet/spipacket.cpp
|
||||
communication/packet/ethernetpacket.cpp
|
||||
communication/packet/versionpacket.cpp
|
||||
communication/packet/iso9141packet.cpp
|
||||
@@ -333,6 +334,11 @@ if(LIBICSNEO_ENABLE_RAW_ETHERNET)
|
||||
endif()
|
||||
if(LIBICSNEO_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()
|
||||
if(LIBICSNEO_ENABLE_DXX)
|
||||
target_compile_definitions(icsneocpp PRIVATE ICSNEO_ENABLE_DXX)
|
||||
@@ -355,8 +361,9 @@ if(LIBICSNEO_ENABLE_DXX)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(libredxx
|
||||
GIT_REPOSITORY https://github.com/Zeranoe/libredxx.git
|
||||
GIT_TAG 2b7932fe7f2fc006ef269c7a72595f3940178a10
|
||||
GIT_TAG e1fe2bd6ba6079b17037379d78f3f18024b389d7
|
||||
)
|
||||
set(LIBREDXX_DISABLE_INSTALL ON)
|
||||
FetchContent_MakeAvailable(libredxx)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -31,13 +31,18 @@ pybind11_add_module(icsneopy
|
||||
icsneopy/communication/message/mdiomessage.cpp
|
||||
icsneopy/communication/message/gptpstatusmessage.cpp
|
||||
icsneopy/communication/message/ethernetstatusmessage.cpp
|
||||
icsneopy/communication/message/spimessage.cpp
|
||||
icsneopy/communication/message/macsecmessage.cpp
|
||||
icsneopy/communication/message/scriptstatusmessage.cpp
|
||||
icsneopy/communication/message/ethphymessage.cpp
|
||||
icsneopy/communication/message/callback/messagecallback.cpp
|
||||
icsneopy/communication/message/filter/messagefilter.cpp
|
||||
icsneopy/communication/message/flexray/flexraymessage.cpp
|
||||
icsneopy/flexray/flexray.cpp
|
||||
icsneopy/disk/diskdriver.cpp
|
||||
icsneopy/device/chipid.cpp
|
||||
icsneopy/device/versionreport.cpp
|
||||
icsneopy/device/device.cpp
|
||||
icsneopy/device/extensions/deviceextension.cpp
|
||||
icsneopy/device/idevicesettings.cpp
|
||||
icsneopy/icsneocpp.cpp
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#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("Invalid", ChipID::Invalid);
|
||||
}
|
||||
|
||||
} // namespace icsneo
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <pybind11/chrono.h>
|
||||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/extensions/deviceextension.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -20,6 +21,8 @@ void init_device(pybind11::module_& m) {
|
||||
.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_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_messages", [](Device& device) { return device.getMessages(); }, pybind11::call_guard<pybind11::gil_scoped_release>())
|
||||
.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("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("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);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ void init_devicetype(pybind11::module_& m) {
|
||||
.value("RADMoon3", DeviceType::Enum::RADMoon3)
|
||||
.value("RADComet", DeviceType::Enum::RADComet)
|
||||
.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("RADComet3", DeviceType::Enum::RADComet3)
|
||||
.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_mode", &IDeviceSettings::setPhyMode, 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
|
||||
|
||||
@@ -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_gptpstatusmessage(pybind11::module_&);
|
||||
void init_mdiomessage(pybind11::module_&);
|
||||
void init_spimessage(pybind11::module_&);
|
||||
void init_ethernetstatusmessage(pybind11::module_&);
|
||||
void init_macsecmessage(pybind11::module_&);
|
||||
void init_scriptstatusmessage(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_messagefilter(pybind11::module_&);
|
||||
void init_messagecallback(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_ethphymessage(pybind11::module_&);
|
||||
|
||||
PYBIND11_MODULE(icsneopy, m) {
|
||||
pybind11::options options;
|
||||
@@ -54,11 +59,16 @@ PYBIND11_MODULE(icsneopy, m) {
|
||||
init_ethernetstatusmessage(m);
|
||||
init_macsecmessage(m);
|
||||
init_scriptstatusmessage(m);
|
||||
init_spimessage(m);
|
||||
init_messagefilter(m);
|
||||
init_messagecallback(m);
|
||||
init_diskdriver(m);
|
||||
init_flexray(m);
|
||||
init_ethphymessage(m);
|
||||
init_chipid(m);
|
||||
init_versionreport(m);
|
||||
init_device(m);
|
||||
init_flexraymessage(m);
|
||||
init_deviceextension(m);
|
||||
init_idevicesettings(m);
|
||||
|
||||
m.def("find_all_devices", &FindAllDevices);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
||||
#include "icsneo/communication/packet/livedatapacket.h"
|
||||
#include "icsneo/communication/packet/hardwareinfopacket.h"
|
||||
#include "icsneo/communication/packet/spipacket.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -58,7 +59,7 @@ uint64_t Decoder::GetUInt64FromLEBytes(const uint8_t* bytes) {
|
||||
bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet) {
|
||||
switch(packet->network.getType()) {
|
||||
case Network::Type::Ethernet: {
|
||||
result = HardwareEthernetPacket::DecodeToMessage(packet->data, report);
|
||||
result = HardwareEthernetPacket::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
|
||||
@@ -184,6 +185,19 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||
msg.timestamp *= timestampResolution;
|
||||
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: {
|
||||
result = HardwareMDIOPacket::DecodeToMessage(packet->data);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
// A limit of zero indicates no limit
|
||||
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
|
||||
// wait until we have enough data, or the timeout occurs
|
||||
waitForRx(limit, timeout);
|
||||
|
||||
size_t actuallyRead = std::min(readBuffer.size(), limit);
|
||||
size_t actuallyRead = readBuffer.size();
|
||||
bytes.resize(actuallyRead);
|
||||
|
||||
readBuffer.read(bytes.data(), 0, actuallyRead);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "icsneo/communication/packet/a2bpacket.h"
|
||||
#include "icsneo/communication/packet/linpacket.h"
|
||||
#include "icsneo/communication/packet/mdiopacket.h"
|
||||
#include "icsneo/communication/packet/spipacket.h"
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
@@ -133,6 +134,17 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
||||
}
|
||||
break;
|
||||
} // 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:
|
||||
report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error);
|
||||
return false;
|
||||
|
||||
@@ -8,7 +8,7 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
|
||||
msg->Clause45Enable = clause45;
|
||||
msg->Enabled = enabled;
|
||||
msg->WriteEnable = writeEnable;
|
||||
msg->version = 1u;
|
||||
msg->Version = 1u;
|
||||
if( (FiveBits < phyAddrOrPort) ||
|
||||
(clause45 && (FiveBits < pageOrDevice)) ||
|
||||
(!clause45 && (FiveBits < regAddr)) )
|
||||
@@ -18,17 +18,17 @@ bool EthPhyMessage::appendPhyMessage(bool writeEnable, bool clause45, uint8_t ph
|
||||
|
||||
if(clause45)
|
||||
{
|
||||
msg->clause45.port = phyAddrOrPort;
|
||||
msg->clause45.device = pageOrDevice;
|
||||
msg->clause45.regAddr = regAddr;
|
||||
msg->clause45.regVal = regVal;
|
||||
msg->Clause45.port = phyAddrOrPort;
|
||||
msg->Clause45.device = pageOrDevice;
|
||||
msg->Clause45.regAddr = regAddr;
|
||||
msg->Clause45.regVal = regVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg->clause22.phyAddr = phyAddrOrPort;
|
||||
msg->clause22.page = pageOrDevice;
|
||||
msg->clause22.regAddr = regAddr;
|
||||
msg->clause22.regVal = regVal;
|
||||
msg->Clause22.phyAddr = phyAddrOrPort;
|
||||
msg->Clause22.page = pageOrDevice;
|
||||
msg->Clause22.regAddr = regAddr;
|
||||
msg->Clause22.regVal = regVal;
|
||||
}
|
||||
return appendPhyMessage(msg);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
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> ret(args.size() + 4);
|
||||
std::vector<uint8_t> ret;
|
||||
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 >> 8));
|
||||
ret.push_back(uint8_t(op));
|
||||
|
||||
@@ -9,7 +9,7 @@ using namespace icsneo;
|
||||
MultiChannelCommunication::MultiChannelCommunication(device_eventhandler_t err, std::unique_ptr<Driver> com,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer, std::unique_ptr<Encoder> e,
|
||||
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);
|
||||
vnetQueues.resize(numVnets);
|
||||
}
|
||||
@@ -24,6 +24,7 @@ void MultiChannelCommunication::spawnThreads() {
|
||||
|
||||
void MultiChannelCommunication::joinThreads() {
|
||||
closing = true;
|
||||
ringBufCV.notify_all();
|
||||
if(hidReadThread.joinable())
|
||||
hidReadThread.join();
|
||||
for(auto& thread : vnetThreads) {
|
||||
@@ -148,9 +149,13 @@ void MultiChannelCommunication::hidReadTask() {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!currentQueue->enqueue(std::move(payloadBytes)) && gotPacket)
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::FailedToRead, APIEvent::Severity::Error));
|
||||
payloadBytes.clear();
|
||||
{
|
||||
std::unique_lock lk(ringBufMutex);
|
||||
if(!packetRB.write(std::move(payloadBytes)) && gotPacket)
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::FailedToRead, APIEvent::Severity::Error));
|
||||
payloadBytes.clear();
|
||||
}
|
||||
ringBufCV.notify_all();
|
||||
gotPacket = true;
|
||||
state = PreprocessState::SearchForCommand;
|
||||
break;
|
||||
@@ -160,7 +165,6 @@ void MultiChannelCommunication::hidReadTask() {
|
||||
}
|
||||
|
||||
void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
|
||||
moodycamel::BlockingReaderWriterQueue< std::vector<uint8_t> >& queue = vnetQueues[vnetIndex];
|
||||
std::vector<uint8_t> payloadBytes;
|
||||
std::unique_ptr<Packetizer> packetizerLifetime;
|
||||
Packetizer* vnetPacketizer;
|
||||
@@ -174,14 +178,19 @@ void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
|
||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||
|
||||
while(!closing) {
|
||||
if(queue.wait_dequeue_timed(payloadBytes, std::chrono::milliseconds(250))) {
|
||||
if(closing)
|
||||
break;
|
||||
|
||||
auto& ringBuffer = driver->getReadBuffer();
|
||||
ringBuffer.write(payloadBytes);
|
||||
|
||||
handleInput(*vnetPacketizer);
|
||||
std::unique_lock lk(ringBufMutex);
|
||||
ringBufCV.wait(lk);
|
||||
if(closing) {
|
||||
break;
|
||||
}
|
||||
if(vnetPacketizer->input(packetRB)) {
|
||||
for(const auto& packet : vnetPacketizer->output()) {
|
||||
std::shared_ptr<Message> msg;
|
||||
if(!decoder->decode(msg, packet))
|
||||
continue;
|
||||
|
||||
dispatchMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
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 uint16_t* rawWords = (const uint16_t*)bytestream.data();
|
||||
// Make sure we have enough to read the packet length first
|
||||
@@ -18,9 +18,6 @@ std::shared_ptr<EthernetMessage> HardwareEthernetPacket::DecodeToMessage(const s
|
||||
const size_t bytestreamActualSize = bytestream.size();
|
||||
if(bytestreamActualSize < bytestreamExpectedSize)
|
||||
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>();
|
||||
EthernetMessage& message = *messagePtr;
|
||||
message.transmitted = packet->eid.TXMSG;
|
||||
|
||||
@@ -34,11 +34,12 @@ std::shared_ptr<EthPhyMessage> HardwareEthernetPhyRegisterPacket::DecodeToMessag
|
||||
phyMessage->Enabled = (pEntry->Enabled != 0u);
|
||||
phyMessage->WriteEnable = (pEntry->WriteEnable != 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)
|
||||
phyMessage->clause45 = pEntry->clause45;
|
||||
phyMessage->Clause45 = pEntry->clause45;
|
||||
else
|
||||
phyMessage->clause22 = pEntry->clause22;
|
||||
phyMessage->Clause22 = pEntry->clause22;
|
||||
msg->messages.push_back(phyMessage);
|
||||
}
|
||||
}
|
||||
@@ -69,34 +70,35 @@ bool HardwareEthernetPhyRegisterPacket::EncodeFromMessage(const EthPhyMessage& m
|
||||
PhyRegisterPacket_t tempPacket;
|
||||
tempPacket.Enabled = phyMessage->Enabled ? 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( (FiveBits < phyMessage->clause45.port) ||
|
||||
(FiveBits < phyMessage->clause45.device) )
|
||||
if( (FiveBits < phyMessage->Clause45.port) ||
|
||||
(FiveBits < phyMessage->Clause45.device) )
|
||||
{
|
||||
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
tempPacket.Clause45Enable = 0x1u;
|
||||
tempPacket.clause45.port = phyMessage->clause45.port;
|
||||
tempPacket.clause45.device = phyMessage->clause45.device;
|
||||
tempPacket.clause45.regAddr = phyMessage->clause45.regAddr;
|
||||
tempPacket.clause45.regVal = phyMessage->clause45.regVal;
|
||||
tempPacket.clause45.port = phyMessage->Clause45.port;
|
||||
tempPacket.clause45.device = phyMessage->Clause45.device;
|
||||
tempPacket.clause45.regAddr = phyMessage->Clause45.regAddr;
|
||||
tempPacket.clause45.regVal = phyMessage->Clause45.regVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( (FiveBits < phyMessage->clause22.phyAddr) ||
|
||||
(FiveBits < phyMessage->clause22.regAddr) )
|
||||
if( (FiveBits < phyMessage->Clause22.phyAddr) ||
|
||||
(FiveBits < phyMessage->Clause22.regAddr) )
|
||||
{
|
||||
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
tempPacket.Clause45Enable = 0x0u;
|
||||
tempPacket.clause22.phyAddr = phyMessage->clause22.phyAddr;
|
||||
tempPacket.clause22.page = phyMessage->clause22.page;
|
||||
tempPacket.clause22.regAddr = phyMessage->clause22.regAddr;
|
||||
tempPacket.clause22.regVal = phyMessage->clause22.regVal;
|
||||
tempPacket.clause22.phyAddr = phyMessage->Clause22.phyAddr;
|
||||
tempPacket.clause22.page = phyMessage->Clause22.page;
|
||||
tempPacket.clause22.regAddr = phyMessage->Clause22.regAddr;
|
||||
tempPacket.clause22.regVal = phyMessage->Clause22.regVal;
|
||||
}
|
||||
uint8_t* pktPtr = reinterpret_cast<uint8_t*>(&tempPacket);
|
||||
bytestream.insert(bytestream.end(), pktPtr, pktPtr + sizeof(PhyRegisterPacket_t));
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace icsneo
|
||||
report(APIEvent::Type::I2CMessageExceedsMaxLength, APIEvent::Severity::Error);
|
||||
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
|
||||
//alternatively, you're expecting to read without providing a dataBytes payload
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
case WiVI::Command::GetAll: {
|
||||
if(bytestream.size() < sizeof(WiVI::CommandPacket::GetAll))
|
||||
if(bytestream.size() < sizeof(WiVI::CommandPacket::GetAllHeader))
|
||||
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->info.emplace();
|
||||
msg->info->sleepRequest = getAll.sleepRequest;
|
||||
msg->info->connectionTimeoutMinutes = getAll.connectionTimeoutMinutes;
|
||||
|
||||
// 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 {};
|
||||
|
||||
const WiVI::CaptureInfo* const captureInfos = (const WiVI::CaptureInfo*)(bytestream.data() + sizeof(WiVI::CommandPacket::GetAllHeader));
|
||||
msg->info->captures.resize(getAll.numCaptureInfos);
|
||||
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;
|
||||
}
|
||||
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
|
||||
return {};
|
||||
}
|
||||
@@ -78,9 +100,9 @@ std::vector<uint8_t> WiVI::CommandPacket::SetSignal::Encode(WiVI::SignalType typ
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> WiVI::CommandPacket::GetAll::Encode() {
|
||||
std::vector<uint8_t> ret(sizeof(WiVI::CommandPacket::GetAll));
|
||||
auto& frame = *reinterpret_cast<WiVI::CommandPacket::GetAll*>(ret.data());
|
||||
std::vector<uint8_t> WiVI::CommandPacket::GetAllHeader::Encode() {
|
||||
std::vector<uint8_t> ret(sizeof(WiVI::CommandPacket::GetAllHeader));
|
||||
auto& frame = *reinterpret_cast<WiVI::CommandPacket::GetAllHeader*>(ret.data());
|
||||
|
||||
frame.header.cmd = WiVI::Command::GetAll;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+197
-4
@@ -207,6 +207,71 @@ bool Device::refreshComponentVersions() {
|
||||
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.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) {
|
||||
if(!com) {
|
||||
report(APIEvent::Type::Unknown, APIEvent::Severity::Error);
|
||||
@@ -1178,7 +1243,7 @@ void Device::wiviThreadBody() {
|
||||
|
||||
// Use the command GetAll to get a WiVI::Info structure from the device
|
||||
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));
|
||||
|
||||
if(!generic || generic->type != Message::Type::WiVICommandResponse) {
|
||||
@@ -1290,6 +1355,22 @@ void Device::wiviThreadBody() {
|
||||
for(auto& cb : sleepRequestedCallbacks)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1464,6 +1545,110 @@ bool Device::allowSleep(bool remoteWakeup) {
|
||||
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()
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(scriptStatusMutex);
|
||||
@@ -1846,7 +2031,7 @@ std::optional<EthPhyMessage> Device::sendEthPhyMsg(const EthPhyMessage& message,
|
||||
HardwareEthernetPhyRegisterPacket::EncodeFromMessage(message, bytes, report);
|
||||
std::shared_ptr<Message> response = com->waitForMessageSync(
|
||||
[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) {
|
||||
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||
@@ -3315,10 +3500,18 @@ std::optional<uint64_t> Device::vsaReadLogicalDisk(uint64_t pos, uint8_t* into,
|
||||
return readLogicalDisk(pos, into, amount);
|
||||
}
|
||||
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 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) {
|
||||
|
||||
+12
-13
@@ -35,15 +35,6 @@ static void makeIfSerialMatches(const FoundDevice& dev, std::vector<std::shared_
|
||||
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>
|
||||
static void makeIfSerialRangeMatches(const FoundDevice& dev, std::vector<std::shared_ptr<Device>>& into) {
|
||||
// Relies on the subclass to have
|
||||
@@ -139,7 +130,7 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIFIRE_H_
|
||||
makeIfPIDMatches<NeoVIFIRE>(dev, newFoundDevices);
|
||||
makeIfSerialRangeMatches<NeoVIFIRE>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIFIRE2_H_
|
||||
@@ -154,16 +145,20 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
||||
makeIfSerialMatches<NeoVIFIRE3FlexRay>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIFIRE3T1SLIN_H_
|
||||
makeIfSerialMatches<NeoVIFIRE3T1SLIN>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIRED2_H_
|
||||
makeIfSerialMatches<NeoVIRED2>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIION_H_
|
||||
makeIfPIDMatches<NeoVIION>(dev, newFoundDevices);
|
||||
makeIfSerialMatches<NeoVIION>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIPLASMA_H_
|
||||
makeIfPIDMatches<NeoVIPLASMA>(dev, newFoundDevices);
|
||||
makeIfSerialMatches<NeoVIPLASMA>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __RADA2B_H_
|
||||
@@ -247,7 +242,7 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
||||
#endif
|
||||
|
||||
#ifdef __VALUECAN3_H_
|
||||
makeIfPIDMatches<ValueCAN3>(dev, newFoundDevices);
|
||||
makeIfSerialRangeMatches<ValueCAN3>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __VALUECAN4_1_H_
|
||||
@@ -325,6 +320,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
||||
NeoVIFIRE3FlexRay::DEVICE_TYPE,
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIFIRE3T1SLIN_H_
|
||||
NeoVIFIRE3T1SLIN::DEVICE_TYPE,
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIION_H_
|
||||
NeoVIION::DEVICE_TYPE,
|
||||
#endif
|
||||
|
||||
@@ -3,16 +3,6 @@
|
||||
|
||||
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 {
|
||||
return { clusterConfig, controllerConfig };
|
||||
}
|
||||
@@ -74,7 +64,7 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
||||
((controllerConfig.KeySlotUsedForStartup & 0x1) << 8) | // TXST
|
||||
((controllerConfig.KeySlotUsedForSync & 0x1) << 9) | // TXSY
|
||||
((clusterConfig.ColdStartAttempts & 0x1f) << 11) | // CSA
|
||||
((controllerConfig.AllowPassiveToActiveCyclePairs & 0x1f) << 16) | // PTA
|
||||
((controllerConfig.AllowPassiveToActiveCyclePairs & 0x1F) << 16) | // PTA
|
||||
((controllerConfig.WakeupOnChannelB & 0x1) << 21) | // WUCS
|
||||
((controllerConfig.KeySlotOnlyEnabled & 0x1) << 22) | // TSM
|
||||
((controllerConfig.AllowHaltDueToClock & 0x1) << 23) | // HCSE
|
||||
@@ -85,99 +75,100 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::SUCC2,
|
||||
((controllerConfig.ListenTimeout & 0x1fffff)) |
|
||||
((clusterConfig.ListenNoiseMacroticks - 1) << 24)
|
||||
((controllerConfig.ListenTimeout & 0x1FFFFF)) |
|
||||
(((clusterConfig.ListenNoiseMacroticks - 1) & 0xF) << 24)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::SUCC3,
|
||||
(clusterConfig.MaxWithoutClockCorrectionPassive & 0xF) |
|
||||
((clusterConfig.MaxWithoutClockCorrectionFatal) << 4)
|
||||
((clusterConfig.MaxWithoutClockCorrectionFatal & 0xF) << 4)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::NEMC,
|
||||
clusterConfig.NetworkManagementVectorLengthBytes
|
||||
clusterConfig.NetworkManagementVectorLengthBytes & 0xF
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::PRTC1,
|
||||
(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.Speed & 0x3) << 14) |
|
||||
((clusterConfig.WakeupRxWindowBits & 0x1ff) << 16) |
|
||||
((controllerConfig.WakeupPattern) << 26)
|
||||
((clusterConfig.WakeupRxWindowBits & 0x1FF) << 16) |
|
||||
((controllerConfig.WakeupPattern & 0x3F) << 26)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::PRTC2,
|
||||
(clusterConfig.WakeupRxIdleBits) |
|
||||
((clusterConfig.WakeupRxLowBits) << 8) |
|
||||
(clusterConfig.WakeupRxIdleBits & 0x3F) |
|
||||
((clusterConfig.WakeupRxLowBits & 0x3F) << 8) |
|
||||
((clusterConfig.WakeupTxIdleBits) << 16) |
|
||||
((clusterConfig.WakeupTxActiveBits) << 24)
|
||||
((clusterConfig.WakeupTxActiveBits & 0x3F) << 24)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::MHDC,
|
||||
(clusterConfig.PayloadLengthOfStaticSlotInWords) |
|
||||
((controllerConfig.LatestTxMinislot) << 16)
|
||||
(clusterConfig.PayloadLengthOfStaticSlotInWords & 0x7F) |
|
||||
((controllerConfig.LatestTxMinislot & 0x1FFF) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC1,
|
||||
controllerConfig.MicroPerCycle
|
||||
controllerConfig.MicroPerCycle & 0xFFFFF
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC2,
|
||||
(clusterConfig.SyncFrameIDCountMax << 16) |
|
||||
clusterConfig.MacroticksPerCycle
|
||||
(clusterConfig.MacroticksPerCycle & 0x3FFF)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC3,
|
||||
(controllerConfig.MicroInitialOffsetA) |
|
||||
((controllerConfig.MicroInitialOffsetB) << 8) |
|
||||
((controllerConfig.MacroInitialOffsetA) << 16) |
|
||||
((controllerConfig.MacroInitialOffsetB) << 24)
|
||||
((controllerConfig.MacroInitialOffsetA & 0x7F) << 16) |
|
||||
((controllerConfig.MacroInitialOffsetB & 0x7F) << 24)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC4,
|
||||
((clusterConfig.MacroticksPerCycle - clusterConfig.NetworkIdleTimeMacroticks - 1) & 0xFFFF) |
|
||||
((clusterConfig.OffsetCorrectionStartMacroticks - 1) << 16)
|
||||
((clusterConfig.MacroticksPerCycle - clusterConfig.NetworkIdleTimeMacroticks - 1) & 0x3FFF) |
|
||||
(((clusterConfig.OffsetCorrectionStartMacroticks - 1) & 0x3FFF) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC5,
|
||||
controllerConfig.DelayCompensationAMicroticks |
|
||||
(controllerConfig.DelayCompensationBMicroticks << 8) |
|
||||
(controllerConfig.ClusterDriftDamping << 16) |
|
||||
((controllerConfig.ClusterDriftDamping & 0x1F) << 16) |
|
||||
(controllerConfig.DecodingCorrectionMicroticks << 24)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC6,
|
||||
controllerConfig.AcceptStartupRangeMicroticks |
|
||||
(controllerConfig.RateCorrectionOutMicroticks << 16)
|
||||
(controllerConfig.AcceptStartupRangeMicroticks & 0x7FF) |
|
||||
((controllerConfig.RateCorrectionOutMicroticks & 0x7FF) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC7,
|
||||
(clusterConfig.StaticSlotMacroticks) |
|
||||
(clusterConfig.NumberOfStaticSlots << 16)
|
||||
(clusterConfig.StaticSlotMacroticks & 0x3FF) |
|
||||
((clusterConfig.NumberOfStaticSlots & 0x3FF) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC8,
|
||||
clusterConfig.MinislotDurationMacroticks |
|
||||
(clusterConfig.NumberOfMinislots << 16)
|
||||
(clusterConfig.MinislotDurationMacroticks & 0x3F) |
|
||||
((clusterConfig.NumberOfMinislots & 0x1FFF) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC9,
|
||||
clusterConfig.ActionPointOffset |
|
||||
(clusterConfig.MinislotActionPointOffsetMacroticks << 8) |
|
||||
(clusterConfig.DynamicSlotIdlePhaseMinislots << 16)
|
||||
(clusterConfig.ActionPointOffset & 0x3F) |
|
||||
((clusterConfig.MinislotActionPointOffsetMacroticks & 0x1F) << 8) |
|
||||
((clusterConfig.DynamicSlotIdlePhaseMinislots & 0x03) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC10,
|
||||
controllerConfig.OffsetCorrectionOutMicroticks |
|
||||
(controllerConfig.RateCorrectionOutMicroticks << 16)
|
||||
(controllerConfig.OffsetCorrectionOutMicroticks & 0x3FFF) |
|
||||
((controllerConfig.RateCorrectionOutMicroticks & 0x7FF) << 16)
|
||||
});
|
||||
|
||||
registerWrites.push_back({ ERAYRegister::GTUC11,
|
||||
controllerConfig.ExternOffsetCorrectionControl |
|
||||
(controllerConfig.ExternRateCorrectionControl << 8) |
|
||||
(controllerConfig.ExternOffsetCorrectionMicroticks << 16) |
|
||||
(controllerConfig.ExternRateCorrectionMicroticks << 24)
|
||||
(controllerConfig.ExternOffsetCorrectionControl & 0x3) |
|
||||
((controllerConfig.ExternRateCorrectionControl & 0x3) << 8) |
|
||||
((controllerConfig.ExternOffsetCorrectionMicroticks & 0x7) << 16) |
|
||||
((controllerConfig.ExternRateCorrectionMicroticks & 0x7) << 24)
|
||||
});
|
||||
|
||||
std::vector<std::shared_ptr<MessageBuffer>> staticTx;
|
||||
@@ -210,7 +201,7 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
||||
second->isStartup = controllerConfig.KeySlotUsedForStartup;
|
||||
second->isSync = controllerConfig.KeySlotUsedForSync;
|
||||
second->isTransmit = true;
|
||||
second->channelB =true;
|
||||
second->channelB = true;
|
||||
second->frameID = controllerConfig.SecondKeySlotID;
|
||||
second->frameLengthBytes = clusterConfig.PayloadLengthOfStaticSlotInWords * 2;
|
||||
second->baseCycle = 0;
|
||||
@@ -266,7 +257,7 @@ bool FlexRay::Controller::configure(std::chrono::milliseconds timeout) {
|
||||
totalBuffers = 128;
|
||||
|
||||
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
|
||||
(0x80 << 8) |
|
||||
(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));
|
||||
|
||||
uint32_t hs1 = (
|
||||
(buf.frameID) |
|
||||
(CalculateCycleFilter(buf.baseCycle, buf.cycleRepetition) << 16) |
|
||||
((buf.channelA & 0x1) << 24) |
|
||||
((buf.channelB & 0x1) << 25) |
|
||||
(buf.frameID) | // FID
|
||||
(CalculateCycleFilter(buf.baseCycle, buf.cycleRepetition) << 16) | // CYA
|
||||
((buf.channelA & 0x1) << 24) | // CHA
|
||||
((buf.channelB & 0x1) << 25) | // CHB
|
||||
((buf.isTransmit & 0x1) << 26) | // CFG
|
||||
((buf.isNMFrame & 0x1) << 27) | // PPIT
|
||||
((buf.isNetworkManagementFrame & 0x1) << 27) | // PPIT
|
||||
((!buf.continuousMode & 0x1) << 28) | // TXM
|
||||
((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 {
|
||||
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)
|
||||
return {false, 0}; // Out of time!
|
||||
|
||||
|
||||
@@ -25,26 +25,6 @@ void FlexRay::Extension::onGoOffline() {
|
||||
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) {
|
||||
if(!frame || frame->network.getType() != Network::Type::FlexRay)
|
||||
return true; // Don't hook non-FlexRay messages
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
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());
|
||||
size_t words = std::min(knownSize.value_or(0), settings.size());
|
||||
size_t words = settings.size();
|
||||
if(words % 2 == 1)
|
||||
return std::nullopt; // Somehow settings is not word aligned
|
||||
words /= 2;
|
||||
@@ -159,15 +159,12 @@ bool IDeviceSettings::ValidateLINBaudrate(int64_t baudrate) {
|
||||
}
|
||||
}
|
||||
|
||||
bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
bool IDeviceSettings::refresh() {
|
||||
if(disabled) {
|
||||
report(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(disableGSChecksumming)
|
||||
ignoreChecksum = true;
|
||||
|
||||
std::vector<uint8_t> rxSettings;
|
||||
bool ret = com->getSettingsSync(rxSettings);
|
||||
if(!ret) {
|
||||
@@ -175,24 +172,14 @@ bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
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
|
||||
report(APIEvent::Type::SettingsReadError, APIEvent::Severity::Error);
|
||||
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);
|
||||
|
||||
// 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);
|
||||
|
||||
if(gsVersion != GS_VERSION) {
|
||||
@@ -200,19 +187,6 @@ bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
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);
|
||||
settingsInDeviceRAM = settings;
|
||||
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]() {
|
||||
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
|
||||
// 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;
|
||||
}
|
||||
|
||||
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
|
||||
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
|
||||
gsChecksum = CalculateGSChecksum(settings);
|
||||
@@ -287,7 +261,7 @@ bool IDeviceSettings::apply(bool temporary) {
|
||||
|
||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &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) {
|
||||
// Attempt to get the settings from the device so we're up to date if possible
|
||||
if(refresh()) {
|
||||
@@ -342,7 +316,7 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
||||
// This short wait helps on FIRE devices, otherwise the checksum might be wrong!
|
||||
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
|
||||
// We refresh to get these updates, update the checksum, and send it back so it's all in sync
|
||||
std::vector<uint8_t> bytestream;
|
||||
@@ -364,7 +338,7 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
||||
|
||||
msg = std::dynamic_pointer_cast<Main51Message>(com->waitForMessageSync([this, &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) {
|
||||
// Attempt to get the settings from the device so we're up to date if possible
|
||||
if(refresh()) {
|
||||
|
||||
@@ -25,19 +25,4 @@ void VSAExtendedMessage::appendPacket(std::shared_ptr<Packet> packet) const
|
||||
if(packet->network.getNetID() == Network::NetID::Invalid) {
|
||||
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);
|
||||
flags = *reinterpret_cast<Flags*>(recordBytes + 4);
|
||||
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);
|
||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||
doChecksum(recordBytes);
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ VSA03::VSA03(uint8_t* const recordBytes)
|
||||
setType(VSA::Type::AA03);
|
||||
eventType = static_cast<EventType>(*reinterpret_cast<uint16_t*>(recordBytes + 2));
|
||||
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);
|
||||
doChecksum(recordBytes);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ VSA04::VSA04(uint8_t* const recordBytes)
|
||||
setType(VSA::Type::AA04);
|
||||
flags = *reinterpret_cast<Flags*>(recordBytes + 2);
|
||||
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);
|
||||
doChecksum(recordBytes);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ VSA05::VSA05(uint8_t* const recordBytes)
|
||||
setType(VSA::Type::AA05);
|
||||
errorType = static_cast<ErrorType>(*reinterpret_cast<uint16_t*>(recordBytes + 2));
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
+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));
|
||||
error = *reinterpret_cast<uint16_t*>(recordBytes + 18);
|
||||
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);
|
||||
doChecksum(recordBytes);
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ VSA07::VSA07(uint8_t* const recordBytes)
|
||||
lastSector = *reinterpret_cast<uint32_t*>(recordBytes + 2);
|
||||
currentSector = *reinterpret_cast<uint32_t*>(recordBytes + 6);
|
||||
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);
|
||||
doChecksum(recordBytes);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ VSA08::VSA08(uint8_t* const recordBytes)
|
||||
setType(VSA::Type::AA08);
|
||||
troubleSramCount.insert(troubleSramCount.end(), recordBytes + 2, recordBytes + 6);
|
||||
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);
|
||||
doChecksum(recordBytes);
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ VSA09::VSA09(uint8_t* const recordBytes)
|
||||
reserved0.insert(reserved0.end(), recordBytes + 12, recordBytes + 18);
|
||||
hardwareID = static_cast<HardwareID>(recordBytes[18]);
|
||||
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);
|
||||
doChecksum(recordBytes);
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ VSA0B::VSA0B(uint8_t* const recordBytes)
|
||||
{
|
||||
setType(VSA::Type::AA0B);
|
||||
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];
|
||||
checksum = reinterpret_cast<uint16_t*>(recordBytes)[15];
|
||||
doChecksum(recordBytes);
|
||||
@@ -30,8 +30,8 @@ void VSA0B::doChecksum(uint8_t* recordBytes)
|
||||
bool VSA0B::filter(const std::shared_ptr<VSAMessageReadFilter> filter)
|
||||
{
|
||||
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ VSA0C::VSA0C(uint8_t* const recordBytes)
|
||||
audioPreamble = recordBytes[4];
|
||||
audioHeader = recordBytes[5];
|
||||
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);
|
||||
checksum = *reinterpret_cast<uint16_t*>(recordBytes + 30);
|
||||
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)
|
||||
{
|
||||
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
if((filter->captureBitfield != captureBitfield && filter->captureBitfield != UINT16_MAX) ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(filter->captureBitfield != captureBitfield ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > timestamp ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < timestamp) {
|
||||
getICSTimestampFromTimepoint(filter->readRange.first) > getTimestamp() ||
|
||||
getICSTimestampFromTimepoint(filter->readRange.second) < getTimestamp()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ VSA6A::VSA6A(uint8_t* const recordBytes)
|
||||
sequenceNum = *reinterpret_cast<uint32_t*>(recordBytes + 34);
|
||||
totalSectors = *reinterpret_cast<uint32_t*>(recordBytes + 38);
|
||||
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);
|
||||
data.insert(data.end(), recordBytes + 56, 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);
|
||||
if(extendedMessageRecord->getRecordCount() == static_cast<uint32_t>(extendedMessageRecord->getIndex() + 1)) { // Last record in sequence
|
||||
if(!settings.messageFilter || extendedMessageRecord->filter(settings.messageFilter)) {
|
||||
VSAExtendedMessage::truncatePacket(packet);
|
||||
packets.push_back(packet);
|
||||
}
|
||||
activeExtendedMessage = false;
|
||||
|
||||
@@ -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
|
||||
+37
-91
@@ -3,128 +3,74 @@ Python Examples
|
||||
===============
|
||||
|
||||
Transmit CAN frames on DW CAN 01
|
||||
============================
|
||||
=================================
|
||||
|
||||
.. code-block:: python
|
||||
:download:`Download example <../../examples/python/can/can_transmit_basic.py>`
|
||||
|
||||
import icsneopy
|
||||
|
||||
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)
|
||||
.. literalinclude:: ../../examples/python/can/can_transmit_basic.py
|
||||
:language: python
|
||||
|
||||
Receive CAN frames on DW CAN 01
|
||||
===========================
|
||||
================================
|
||||
|
||||
.. code-block:: python
|
||||
:download:`Download example <../../examples/python/can/can_receive_basic.py>`
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
.. literalinclude:: ../../examples/python/can/can_receive_basic.py
|
||||
:language: python
|
||||
|
||||
devices: list[icsneopy.Device] = icsneopy.find_all_devices()
|
||||
Complete CAN Example
|
||||
====================
|
||||
|
||||
# grab the first/only device found
|
||||
device: icsneopy.Device = devices[0]
|
||||
:download:`Download example <../../examples/python/can/can_complete_example.py>`
|
||||
|
||||
def on_message(message: icsneopy.CANMessage):
|
||||
print(message.arbid, message.data)
|
||||
message_filter = icsneopy.MessageFilter(icsneopy.Network.NetID.DWCAN_01)
|
||||
callback = icsneopy.MessageCallback(on_message, message_filter)
|
||||
.. literalinclude:: ../../examples/python/can/can_complete_example.py
|
||||
:language: python
|
||||
|
||||
device.add_message_callback(callback)
|
||||
|
||||
device.open()
|
||||
device.go_online()
|
||||
Transmit Ethernet frames on Ethernet 01
|
||||
========================================
|
||||
|
||||
# rx for 10s
|
||||
time.sleep(10)
|
||||
:download:`Download example <../../examples/python/ethernet/ethernet_transmit_basic.py>`
|
||||
|
||||
.. literalinclude:: ../../examples/python/ethernet/ethernet_transmit_basic.py
|
||||
:language: python
|
||||
|
||||
Monitor Ethernet Status
|
||||
=======================
|
||||
|
||||
.. code-block:: python
|
||||
:download:`Download example <../../examples/python/ethernet/ethernet_monitor_status.py>`
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
.. literalinclude:: ../../examples/python/ethernet/ethernet_monitor_status.py
|
||||
:language: python
|
||||
|
||||
def main():
|
||||
devices = icsneopy.find_all_devices()
|
||||
if len(devices) == 0:
|
||||
print("error: no devices found")
|
||||
return False
|
||||
|
||||
device = devices[0]
|
||||
print(f"info: monitoring Ethernet status on {device}")
|
||||
|
||||
def on_message(message):
|
||||
print(f"info: network: {message.network}, state: {message.state}, speed: {message.speed}, duplex: {message.duplex}, mode: {message.mode}")
|
||||
|
||||
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
|
||||
====
|
||||
TC10 Power Management
|
||||
=====================
|
||||
|
||||
:download:`Download example <../../examples/python/tc10/tc10.py>`
|
||||
|
||||
.. literalinclude:: ../../examples/python/tc10/tc10.py
|
||||
:language: python
|
||||
|
||||
DoIP Ethernet Activation
|
||||
========================
|
||||
|
||||
.. code-block:: python
|
||||
:download:`Download example <../../examples/python/doip/doip_activation_control.py>`
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
.. literalinclude:: ../../examples/python/doip/doip_activation_control.py
|
||||
: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
|
||||
dev.go_online()
|
||||
Device Firmware/Chip Versions
|
||||
=============================
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
.. literalinclude:: ../../examples/python/device/chip_versions.py
|
||||
:language: python
|
||||
|
||||
@@ -5,6 +5,8 @@ icsneopy
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
can_getting_started
|
||||
ethernet_getting_started
|
||||
examples
|
||||
api
|
||||
radepsilon
|
||||
|
||||
@@ -10,6 +10,8 @@ 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_VSA_EXAMPLE "Build the VSA 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)
|
||||
|
||||
if(LIBICSNEO_BUILD_C_INTERACTIVE_EXAMPLE)
|
||||
add_subdirectory(c/interactive)
|
||||
@@ -58,3 +60,11 @@ endif()
|
||||
if(LIBICSNEO_BUILD_CPP_APP_ERROR_EXAMPLE)
|
||||
add_subdirectory(cpp/apperror)
|
||||
endif()
|
||||
|
||||
if(LIBICSNEO_BUILD_CPP_FLEXRAY_EXAMPLE)
|
||||
add_subdirectory(cpp/flexray)
|
||||
endif()
|
||||
|
||||
if(LIBICSNEO_BUILD_CPP_SPI_EXAMPLE)
|
||||
add_subdirectory(cpp/spi)
|
||||
endif()
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -239,6 +239,9 @@ int main(int argc, char* argv[]) {
|
||||
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;
|
||||
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()
|
||||
@@ -0,0 +1,30 @@
|
||||
import icsneopy
|
||||
|
||||
def chip_versions():
|
||||
devices = icsneopy.find_all_devices()
|
||||
|
||||
if len(devices) == 0:
|
||||
print("no devices found")
|
||||
return False
|
||||
|
||||
device = devices[0]
|
||||
print(f"selected {device}")
|
||||
|
||||
if not device.open():
|
||||
print("unable to open device")
|
||||
return False
|
||||
|
||||
chip_versions = device.get_chip_versions()
|
||||
if not chip_versions:
|
||||
print("no chip versions")
|
||||
return False
|
||||
|
||||
print("chip versions:")
|
||||
for i in chip_versions:
|
||||
version = f"{i.major}.{i.minor}.{i.maintenance}.{i.build}"
|
||||
print(f" id: {i.id}, name: {i.name}, version: {version}")
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
chip_versions()
|
||||
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
DoIP activation control example using icsneopy library.
|
||||
|
||||
Demonstrates DoIP (Diagnostics over Internet Protocol) Ethernet activation
|
||||
control with comprehensive error handling and state validation.
|
||||
"""
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
|
||||
|
||||
def doip_activation_demo():
|
||||
"""Demonstrate DoIP Ethernet activation control with error handling."""
|
||||
devices = icsneopy.find_all_devices()
|
||||
if not devices:
|
||||
raise RuntimeError("No devices found")
|
||||
|
||||
device = devices[0]
|
||||
print(f"Using {device} for DoIP activation control")
|
||||
|
||||
try:
|
||||
if not device.open():
|
||||
raise RuntimeError("Failed to open device")
|
||||
|
||||
if not device.go_online():
|
||||
raise RuntimeError("Failed to go online")
|
||||
|
||||
initial_state = device.get_digital_io(icsneopy.IO.EthernetActivation, 1)
|
||||
print(f"Initial DoIP activation state: {initial_state}")
|
||||
|
||||
print("Activating DoIP Ethernet...")
|
||||
device.set_digital_io(icsneopy.IO.EthernetActivation, 1, True)
|
||||
time.sleep(1)
|
||||
|
||||
active_state = device.get_digital_io(icsneopy.IO.EthernetActivation, 1)
|
||||
print(f"DoIP activated: {active_state}")
|
||||
time.sleep(2)
|
||||
|
||||
print("Deactivating DoIP Ethernet...")
|
||||
device.set_digital_io(icsneopy.IO.EthernetActivation, 1, False)
|
||||
time.sleep(1)
|
||||
|
||||
final_state = device.get_digital_io(icsneopy.IO.EthernetActivation, 1)
|
||||
print(f"DoIP deactivated: {final_state}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"DoIP control error: {e}")
|
||||
finally:
|
||||
device.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
doip_activation_demo()
|
||||
@@ -0,0 +1,127 @@
|
||||
"""
|
||||
Complete Ethernet example using icsneopy library.
|
||||
|
||||
Demonstrates device setup and Ethernet frame transmission/reception.
|
||||
"""
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
|
||||
|
||||
def setup_device():
|
||||
"""Initialize Ethernet 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 on_status_message(message):
|
||||
print(f"info: network: {message.network}, state: {message.state}, speed: {message.speed}, duplex: {message.duplex}, mode: {message.mode}")
|
||||
|
||||
|
||||
def setup_ethernet_reception(device):
|
||||
"""Configure Ethernet frame reception with callback."""
|
||||
frame_count = 0
|
||||
|
||||
def frame_handler(frame):
|
||||
nonlocal frame_count
|
||||
frame_count += 1
|
||||
print(f"[RX {frame_count}], "
|
||||
f"Data: {[hex(b) for b in frame.data]}, "
|
||||
f"Length: {len(frame.data)}")
|
||||
frame_filter = icsneopy.MessageFilter(icsneopy.Network.NetID.ETHERNET_01)
|
||||
callback = icsneopy.MessageCallback(frame_handler, frame_filter)
|
||||
device.add_message_callback(callback)
|
||||
|
||||
print("CAN frame reception configured")
|
||||
return 0
|
||||
|
||||
|
||||
def transmit_ethernet_frame(device):
|
||||
"""Transmit an Ethernet frame."""
|
||||
frame = icsneopy.EthernetMessage()
|
||||
frame.network = icsneopy.Network(icsneopy.Network.NetID.ETHERNET_01)
|
||||
frame.data = [
|
||||
0x00, 0xFC, 0x70, 0x00, 0x01, 0x02,
|
||||
0x00, 0xFC, 0x70, 0x00, 0x01, 0x01,
|
||||
0x08, 0x00,
|
||||
0x01, 0xC5, 0x01, 0xC5
|
||||
]
|
||||
|
||||
success = device.transmit(frame)
|
||||
if success:
|
||||
print("Frame transmitted successfully")
|
||||
else:
|
||||
print("Failed to transmit frame")
|
||||
|
||||
return success
|
||||
|
||||
def cleanup_device(device):
|
||||
"""Close device connection."""
|
||||
if device:
|
||||
device.close()
|
||||
print("Device connection closed")
|
||||
|
||||
def main():
|
||||
"""Complete Ethernet example"""
|
||||
device = None
|
||||
|
||||
try:
|
||||
# Initialize device
|
||||
device = setup_device()
|
||||
|
||||
# Open device
|
||||
if not open_device(device):
|
||||
raise RuntimeError("Failed to initialize device")
|
||||
|
||||
filter = icsneopy.MessageFilter(icsneopy.Message.Type.EthernetStatus)
|
||||
status_callback = icsneopy.MessageCallback(on_status_message, filter)
|
||||
device.add_message_callback(status_callback)
|
||||
|
||||
#Setup Ethernet Callback
|
||||
setup_ethernet_reception(device)
|
||||
|
||||
# Transmit an Ethernet frame
|
||||
transmit_result = transmit_ethernet_frame(device)
|
||||
if not transmit_result:
|
||||
print("Warning: Failed to transmit frame")
|
||||
|
||||
# Monitor for a period
|
||||
print("Monitoring for 10 seconds...")
|
||||
time.sleep(10)
|
||||
|
||||
print(f"Monitoring completed.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return 1
|
||||
|
||||
finally:
|
||||
cleanup_device(device)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
Ethernet status monitoring example using icsneopy library.
|
||||
|
||||
Demonstrates how to monitor Ethernet link status changes.
|
||||
"""
|
||||
|
||||
import icsneopy
|
||||
import time
|
||||
|
||||
def main():
|
||||
devices = icsneopy.find_all_devices()
|
||||
if len(devices) == 0:
|
||||
print("error: no devices found")
|
||||
return False
|
||||
|
||||
device = devices[0]
|
||||
print(f"info: monitoring Ethernet status on {device}")
|
||||
|
||||
def on_message(message):
|
||||
print(f"info: network: {message.network}, state: {message.state}, speed: {message.speed}, duplex: {message.duplex}, mode: {message.mode}")
|
||||
|
||||
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()
|
||||
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
Basic Ethernet frame transmission example using icsneopy library.
|
||||
|
||||
Demonstrates how to transmit Ethernet frames on Ethernet 01.
|
||||
"""
|
||||
|
||||
import icsneopy
|
||||
|
||||
|
||||
def transmit_ethernet_frame():
|
||||
"""Transmit an Ethernet 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.EthernetMessage()
|
||||
frame.network = icsneopy.Network(icsneopy.Network.NetID.ETHERNET_01)
|
||||
frame.data = [
|
||||
0x00, 0xFC, 0x70, 0x00, 0x01, 0x02,
|
||||
0x00, 0xFC, 0x70, 0x00, 0x01, 0x01,
|
||||
0x08, 0x00,
|
||||
0x01, 0xC5, 0x01, 0xC5
|
||||
]
|
||||
|
||||
success = device.transmit(frame)
|
||||
if success:
|
||||
print("Frame transmitted successfully")
|
||||
else:
|
||||
print("Failed to transmit frame")
|
||||
|
||||
finally:
|
||||
device.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
transmit_ethernet_frame()
|
||||
@@ -56,6 +56,7 @@ enum class ExtendedCommand : uint16_t {
|
||||
GetComponentVersions = 0x001A,
|
||||
Reboot = 0x001C,
|
||||
SetRootFSEntryFlags = 0x0027,
|
||||
TransmitCoreminiMessage = 0x0028,
|
||||
GenericBinaryInfo = 0x0030,
|
||||
LiveData = 0x0035,
|
||||
RequestTC10Wake = 0x003D,
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
bool waitForRx(size_t limit, std::chrono::milliseconds timeout);
|
||||
bool waitForRx(std::function<bool()> predicate, std::chrono::milliseconds timeout);
|
||||
bool readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout = std::chrono::milliseconds(100), size_t limit = 0);
|
||||
bool readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout = std::chrono::milliseconds(100), size_t limit = 1);
|
||||
bool write(const std::vector<uint8_t>& bytes);
|
||||
virtual bool isEthernet() const { return false; }
|
||||
bool readAvailable() { return readBuffer.size() > 0; }
|
||||
|
||||
@@ -21,10 +21,11 @@ struct PhyMessage {
|
||||
bool Enabled;
|
||||
bool WriteEnable;
|
||||
bool Clause45Enable;
|
||||
uint8_t version;
|
||||
uint8_t BusIndex;
|
||||
uint8_t Version;
|
||||
union {
|
||||
Clause22Message clause22;
|
||||
Clause45Message clause45;
|
||||
Clause22Message Clause22;
|
||||
Clause45Message Clause45;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef __SPIMESSAGE_H_
|
||||
#define __SPIMESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include <vector>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class SPIMessage : public Frame {
|
||||
public:
|
||||
enum class Direction : uint8_t {
|
||||
Read = 0,
|
||||
Write = 1
|
||||
};
|
||||
|
||||
Direction direction = Direction::Read;
|
||||
uint16_t address = static_cast<uint16_t>(0x0000u);
|
||||
uint8_t mms = static_cast<uint16_t>(0x0000u); // Memory Map Selector for ADI MAC Phy
|
||||
uint16_t stats = static_cast<uint16_t>(0x0000u);
|
||||
|
||||
std::vector<uint32_t> payload;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,7 @@ struct Info {
|
||||
uint8_t sleepRequest;
|
||||
uint16_t connectionTimeoutMinutes;
|
||||
std::vector<CaptureInfo> captures;
|
||||
uint8_t vinAvailable;
|
||||
};
|
||||
|
||||
// The response for Command::WiVICommand
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
std::optional<Command> responseTo;
|
||||
std::optional<int32_t> value;
|
||||
std::optional<Info> info;
|
||||
std::optional<std::string> vin;
|
||||
};
|
||||
|
||||
} // namespace WiVI
|
||||
|
||||
@@ -113,6 +113,10 @@ private:
|
||||
std::vector< moodycamel::BlockingReaderWriterQueue< std::vector<uint8_t> > > vnetQueues;
|
||||
void hidReadTask();
|
||||
void vnetReadTask(size_t vnetIndex);
|
||||
|
||||
RingBuffer packetRB;
|
||||
std::mutex ringBufMutex;
|
||||
std::condition_variable ringBufCV;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace icsneo {
|
||||
typedef uint16_t icscm_bitfield;
|
||||
|
||||
struct HardwareEthernetPacket {
|
||||
static std::shared_ptr<EthernetMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||
static std::shared_ptr<EthernetMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
static bool EncodeFromMessage(const EthernetMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||
|
||||
// Word 0 - Header flags (offset 0)
|
||||
@@ -57,8 +57,9 @@ struct HardwareEthernetPacket {
|
||||
struct {
|
||||
icscm_bitfield T1S_BURST_COUNT : 8;
|
||||
icscm_bitfield T1S_NODE_ID : 8;
|
||||
uint8_t RESERVED[6];
|
||||
} t1s_node;
|
||||
|
||||
uint8_t RESERVED[6];
|
||||
|
||||
// Words 4-7 - Reserved/Padding
|
||||
uint16_t stats;
|
||||
|
||||
@@ -45,7 +45,9 @@ struct PhyRegisterPacket_t {
|
||||
uint16_t Enabled : 1;
|
||||
uint16_t WriteEnable : 1;
|
||||
uint16_t Clause45Enable : 1;
|
||||
uint16_t reserved : 9;
|
||||
uint16_t status : 3;
|
||||
uint16_t reserved : 2;
|
||||
uint16_t BusIndex : 4;
|
||||
uint16_t version : 4;
|
||||
};
|
||||
uint16_t flags;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef __SPIPACKET_H__
|
||||
#define __SPIPACKET_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include "icsneo/communication/message/spimessage.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
typedef uint16_t icscm_bitfield;
|
||||
|
||||
#pragma pack(push, 2)
|
||||
struct HardwareSPIPacket {
|
||||
|
||||
static std::shared_ptr<Message> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
static bool EncodeFromMessage(const SPIMessage& message, std::vector<uint8_t>& bytestream, const device_eventhandler_t& report);
|
||||
|
||||
struct {
|
||||
uint16_t frameLength;
|
||||
} header;
|
||||
uint8_t offset[12];
|
||||
uint16_t stats;
|
||||
struct {
|
||||
uint64_t TS : 60;
|
||||
uint64_t : 3; // Reserved for future status bits
|
||||
uint64_t IsExtended : 1;
|
||||
} timestamp;
|
||||
uint16_t networkID;
|
||||
uint16_t length;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -56,6 +56,7 @@ enum class Command : uint16_t {
|
||||
GetSignal = 0x0013,
|
||||
Result = 0x0014,
|
||||
GetPhysicalSignal = 0x0015,
|
||||
GetVIN = 0x0016,
|
||||
};
|
||||
|
||||
enum class SignalType : uint16_t { // enumCoreMiniValueMiscValueType
|
||||
@@ -66,6 +67,7 @@ enum class SignalType : uint16_t { // enumCoreMiniValueMiscValueType
|
||||
ConnectionTimeout = 0x006e,
|
||||
TimeSinceLastMessageMs = 0x006f,
|
||||
UploadsPending = 0x0077,
|
||||
VINEnabled = 0x007D,
|
||||
};
|
||||
|
||||
struct Upload {
|
||||
@@ -125,7 +127,7 @@ struct CommandPacket {
|
||||
CoreMiniFixedPointValue value;
|
||||
};
|
||||
|
||||
struct GetAll {
|
||||
struct GetAllHeader {
|
||||
static std::vector<uint8_t> Encode();
|
||||
|
||||
Header header;
|
||||
@@ -133,7 +135,6 @@ struct CommandPacket {
|
||||
uint8_t sleepRequest;
|
||||
uint16_t connectionTimeoutMinutes;
|
||||
uint16_t numCaptureInfos;
|
||||
CaptureInfo captureInfos[0];
|
||||
};
|
||||
|
||||
struct ClearUploads {
|
||||
@@ -142,6 +143,13 @@ struct CommandPacket {
|
||||
Header header;
|
||||
uint8_t bitmask[0];
|
||||
};
|
||||
|
||||
struct GetVIN {
|
||||
static std::vector<uint8_t> Encode();
|
||||
|
||||
Header header;
|
||||
char VIN[17];
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace WiVI
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#ifndef __BOOTLOADER_PIPELINE_H_
|
||||
#define __BOOTLOADER_PIPELINE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/device/chipid.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
#include <utility>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
enum class BootloaderCommunication {
|
||||
RAD,
|
||||
RED,
|
||||
REDCore,
|
||||
RADGalaxy2Peripheral,
|
||||
RADMultiChip,
|
||||
Application,
|
||||
Invalid
|
||||
};
|
||||
|
||||
struct BootloaderPhase {
|
||||
enum class Type {
|
||||
Flash,
|
||||
Finalize,
|
||||
Reconnect,
|
||||
EnterBootloader,
|
||||
Wait
|
||||
};
|
||||
|
||||
virtual Type getType() const = 0;
|
||||
virtual ~BootloaderPhase() = default;
|
||||
};
|
||||
|
||||
struct ReconnectPhase : public BootloaderPhase {
|
||||
Type getType() const override {
|
||||
return Type::Reconnect;
|
||||
}
|
||||
|
||||
ReconnectPhase() = default;
|
||||
};
|
||||
|
||||
struct FinalizePhase : public BootloaderPhase {
|
||||
Type getType() const override {
|
||||
return Type::Finalize;
|
||||
}
|
||||
|
||||
ChipID chip;
|
||||
BootloaderCommunication comm;
|
||||
|
||||
FinalizePhase(ChipID chip, BootloaderCommunication comm) : chip(chip), comm(comm) {}
|
||||
};
|
||||
|
||||
struct WaitPhase : public BootloaderPhase {
|
||||
Type getType() const override {
|
||||
return Type::Wait;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds timeout;
|
||||
|
||||
WaitPhase(std::chrono::milliseconds timeout) : timeout(timeout) {}
|
||||
};
|
||||
|
||||
struct EnterBootloaderPhase : public BootloaderPhase {
|
||||
Type getType() const override {
|
||||
return Type::EnterBootloader;
|
||||
}
|
||||
};
|
||||
|
||||
struct FlashPhase : public BootloaderPhase {
|
||||
Type getType() const override {
|
||||
return Type::Flash;
|
||||
}
|
||||
|
||||
ChipID chip;
|
||||
BootloaderCommunication comm;
|
||||
bool authenticate = true;
|
||||
bool encrypt = true;
|
||||
bool checkOutOfDate = true;
|
||||
|
||||
FlashPhase(ChipID chip, BootloaderCommunication comm, bool authenticate = true, bool encrypt = true, bool checkOutOfDate = true)
|
||||
: chip(chip), comm(comm), authenticate(authenticate), encrypt(encrypt), checkOutOfDate(checkOutOfDate) {}
|
||||
};
|
||||
|
||||
enum class BootloaderSetting {
|
||||
UpdateAll
|
||||
};
|
||||
|
||||
struct BootloaderPipeline {
|
||||
std::vector<std::shared_ptr<BootloaderPhase>> phases;
|
||||
std::unordered_map<BootloaderSetting, std::variant<int, bool>> settings;
|
||||
|
||||
template<typename Phase, typename... Args>
|
||||
BootloaderPipeline& add(Args... args) {
|
||||
phases.emplace_back(std::make_shared<Phase>(std::forward<Args>(args)...));
|
||||
return *this;
|
||||
}
|
||||
|
||||
BootloaderPipeline& addSetting(BootloaderSetting type, const std::variant<int, bool>& setting) {
|
||||
settings.insert({type, setting});
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return !phases.empty();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,139 @@
|
||||
#ifndef __CHIP_ID_H_
|
||||
#define __CHIP_ID_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
enum class ChipID : uint8_t {
|
||||
neoVIFIRE_MCHIP = 0,
|
||||
neoVIFIRE_LCHIP = 1,
|
||||
neoVIFIRE_UCHIP = 2,
|
||||
neoVIFIRE_JCHIP = 3,
|
||||
ValueCAN3_MCHIP = 4,
|
||||
neoVIECU_MPIC = 6,
|
||||
neoVIIEVB_MPIC = 7,
|
||||
neoVIPENDANT_MPIC = 8,
|
||||
neoVIFIRE_VNET_MCHIP = 9,
|
||||
neoVIFIRE_VNET_LCHIP = 10,
|
||||
neoVIPLASMA_Core = 11,
|
||||
neoVIPLASMA_HID = 12,
|
||||
neoVIANALOG_MPIC = 13,
|
||||
neoVIPLASMA_ANALOG_Core = 14,
|
||||
neoVIPLASMA_FlexRay_Core = 15,
|
||||
neoVIPLASMA_Core_1_12 = 16,
|
||||
neoVIFIRE_Slave_VNET_MCHIP = 17,
|
||||
neoVIFIRE_Slave_VNET_LCHIP = 18,
|
||||
neoVIION_Core = 19,
|
||||
neoVIION_HID = 20,
|
||||
neoVIION_Core_Loader = 21,
|
||||
neoVIION_HID_Loader = 22,
|
||||
neoVIION_FPGA_BIT = 23,
|
||||
neoVIFIRE_VNET_EP_MCHIP = 24,
|
||||
neoVIFIRE_VNET_EP_LCHIP = 25,
|
||||
neoVIAnalogOut_MCHIP = 26,
|
||||
neoVIMOST25_MCHIP = 27,
|
||||
neoVIMOST50_MCHIP = 28,
|
||||
neoVIMOST150_MCHIP = 29,
|
||||
ValueCAN4_4_MCHIP = 30,
|
||||
ValueCAN4_4_SCHIP = 31,
|
||||
cmProbe_ZYNQ = 33,
|
||||
EEVB_STM32 = 34,
|
||||
neoVIFIRE_Slave_VNET_EP_MCHIP = 35,
|
||||
neoVIFIRE_Slave_VNET_EP_LCHIP = 36,
|
||||
RADStar_MCHIP = 37,
|
||||
ValueCANrf_MCHIP = 38,
|
||||
neoVIFIRE2_MCHIP = 39,
|
||||
neoVIFIRE2_CCHIP = 40,
|
||||
neoVIFIRE2_Core = 41,
|
||||
neoVIFIRE2_BLECHIP = 42,
|
||||
neoVIFIRE2_ZYNQ = 43, // FIRE2 MVNET Z - Zynq
|
||||
neoVIFIRE2_SECURITYCHIP = 44,
|
||||
RADGalaxy_ZYNQ = 45,
|
||||
neoVIFIRE2_VNET_MCHIP = 46,
|
||||
neoVIFIRE2_Slave_VNET_A_MCHIP = 47,
|
||||
neoVIFIRE2_Slave_VNET_A_CCHIP = 48,
|
||||
neoVIFIRE2_VNET_CCHIP = 49,
|
||||
neoVIFIRE2_VNET_Core = 50,
|
||||
RADStar2_ZYNQ = 51,
|
||||
VividCAN_MCHIP = 52,
|
||||
neoOBD2SIM_MCHIP = 53,
|
||||
neoVIFIRE2_VNETZ_MCHIP = 54,
|
||||
neoVIFIRE2_VNETZ_ZYNQ = 55,
|
||||
neoVIFIRE2_Slave_VNETZ_A_MCHIP = 56,
|
||||
neoVIFIRE2_Slave_VNETZ_A_ZYNQ = 57,
|
||||
VividCAN_EXT_FLASH = 58,
|
||||
VividCAN_NRF52 = 59,
|
||||
cmProbe_ZYNQ_Unused = 60, // Double defined
|
||||
neoOBD2PRO_MCHIP = 61,
|
||||
ValueCAN4_1_MCHIP = 62,
|
||||
ValueCAN4_2_MCHIP = 63,
|
||||
ValueCAN4_4_2EL_Core = 64,
|
||||
neoOBD2PRO_SCHIP = 65,
|
||||
ValueCAN4_2EL_MCHIP = 67,
|
||||
neoECUAVBTSN_MCHIP = 68,
|
||||
neoOBD2PRO_Core = 69,
|
||||
RADSupermoon_ZYNQ = 70,
|
||||
RADMoon2_ZYNQ = 71,
|
||||
VividCANPRO_MCHIP = 72,
|
||||
VividCANPRO_EXT_FLASH = 73,
|
||||
RADPluto_MCHIP = 74,
|
||||
RADMars_ZYNQ = 75,
|
||||
neoECU12_MCHIP = 76,
|
||||
RADIOCANHUB_MCHIP = 77,
|
||||
FlexRay_VNETZ_ZCHIP = 78,
|
||||
neoOBD2_LCBADGE_MCHIP = 79,
|
||||
neoOBD2_LCBADGE_SCHIP = 80,
|
||||
RADMoonDuo_MCHIP = 81,
|
||||
neoVIFIRE3_ZCHIP = 82,
|
||||
FlexRay_VNETZ_FCHIP = 83,
|
||||
RADJupiter_MCHIP = 84,
|
||||
ValueCAN4Industrial_MCHIP = 85,
|
||||
EtherBADGE_MCHIP = 86,
|
||||
RADMars_3_ZYNQ = 87,
|
||||
RADGigastar_USBZ_ZYNQ = 88,
|
||||
RADGigastar_ZYNQ = 89,
|
||||
RAD4G_MCHIP = 90,
|
||||
neoVIFIRE3_SCHIP = 91,
|
||||
RADEpsilon_MCHIP = 92,
|
||||
RADA2B_ZCHIP = 93,
|
||||
neoOBD2Dev_MCHIP = 94,
|
||||
neoOBD2Dev_SCHIP = 95,
|
||||
neoOBD2SIMDoIP_MCHIP = 96,
|
||||
SFPModule_MCHIP = 97,
|
||||
RADEpsilonT_MCHIP = 98,
|
||||
RADEpsilonExpress_MCHIP = 99,
|
||||
RADProxima_MCHIP = 100,
|
||||
NewDevice57_ZCHIP = 101,
|
||||
RAD_GALAXY_2_ZMPCHIP_ID = 102,
|
||||
NewDevice59_MCHIP = 103,
|
||||
RADMoon2_Z7010_ZYNQ = 104,
|
||||
neoVIFIRE2_CORE_SG4 = 105,
|
||||
RADBMS_MCHIP = 106,
|
||||
RADMoon2_ZL_MCHIP = 107,
|
||||
RADGigastar_USBZ_Z7010_ZYNQ = 108,
|
||||
neoVIFIRE3_LINUX = 109,
|
||||
RADGigastar_USBZ_Z7007S_ZYNQ = 110,
|
||||
VEM_01_8DW_ZCHIP = 111,
|
||||
RADGalaxy_FFG_Zynq = 112,
|
||||
RADMoon3_MCHIP = 113,
|
||||
RADComet_ZYNQ = 114,
|
||||
VEM_02_FR_ZCHIP = 115,
|
||||
RADA2B_REVB_ZCHIP = 116,
|
||||
RADGigastar_FFG_ZYNQ = 117,
|
||||
VEM_02_FR_FCHIP = 118,
|
||||
Connect_ZCHIP = 121,
|
||||
RADGALAXY2_SYSMON_CHIP = 123,
|
||||
RADCOMET3_ZCHIP = 125,
|
||||
Connect_LINUX = 126,
|
||||
RADGigastar2_ZYNQ = 131,
|
||||
Invalid = 255
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
#ifndef __CHIP_INFO_H_
|
||||
#define __CHIP_INFO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/device/chipid.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
enum class FirmwareType {
|
||||
IEF,
|
||||
Zip
|
||||
};
|
||||
|
||||
struct ChipInfo {
|
||||
/**
|
||||
* The default enabled field is for devices which can't deduce the specific ChipID of a device
|
||||
* until entering the bootloader.
|
||||
*
|
||||
* If defaultEnabled is set to true, the bootloader and version retrieval functions assume that
|
||||
* the chip is enabled, so it will perform version deduction based on the default enabled chip. If
|
||||
* defaultEnabled is set to false, then this chip info may or may not apply to this device
|
||||
*
|
||||
* Example: RADA2B RevA and RevB chips
|
||||
*
|
||||
* Sometimes we can't deduce whether we have a RevA or RevB chip before entering the bootloader if the
|
||||
* device does not support component versions. These chips track the same version, so we assume that the
|
||||
* chip is RevA (RevA defaultEnabled=true, RevB defaultEnabled=false) and check during the bootloader
|
||||
* if this chip is RevA or RevB.
|
||||
*/
|
||||
ChipID id;
|
||||
bool defaultEnabled = false;
|
||||
const char* name = nullptr; // Chip user displayable name
|
||||
const char* iefName = nullptr; // IEF name for a single segment chip (example RADA2B ZCHIP)
|
||||
size_t versionIndex = 0; // Main and Secondary version index
|
||||
FirmwareType fwType; // Firmwaare storagae type
|
||||
std::vector<const char*> iefSegments; // IEF names for a multi segment chip (example RADGalaxy2 ZCHIP)
|
||||
|
||||
ChipInfo() = default;
|
||||
|
||||
ChipInfo(ChipID id, bool defaultEnabled, const char* name, const char* iefName, size_t versionIndex, FirmwareType fwType)
|
||||
: id(id), defaultEnabled(defaultEnabled), name(name), iefName(iefName), versionIndex(versionIndex), fwType(fwType) {}
|
||||
|
||||
ChipInfo(ChipID id, bool defaultEnabled, const char* name, const char* iefName, const std::vector<const char*>& iefSegments, size_t versionIndex, FirmwareType fwType)
|
||||
: id(id), defaultEnabled(defaultEnabled), name(name), iefName(iefName), versionIndex(versionIndex), fwType(fwType), iefSegments(iefSegments) {}
|
||||
|
||||
bool isMultiIEF() const {
|
||||
return !iefSegments.empty();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,9 @@
|
||||
#include "icsneo/device/deviceversion.h"
|
||||
#include "icsneo/device/founddevice.h"
|
||||
#include "icsneo/device/coremini.h"
|
||||
#include "icsneo/device/bootloaderpipeline.h"
|
||||
#include "icsneo/device/chipinfo.h"
|
||||
#include "icsneo/device/versionreport.h"
|
||||
#include "icsneo/disk/diskreaddriver.h"
|
||||
#include "icsneo/disk/diskwritedriver.h"
|
||||
#include "icsneo/disk/nulldiskdriver.h"
|
||||
@@ -86,6 +89,77 @@ class Device {
|
||||
public:
|
||||
virtual ~Device();
|
||||
|
||||
enum class ProductID : uint8_t {
|
||||
neoVIRED = 0,
|
||||
neoVIFIRE = 1,
|
||||
ValueCAN3 = 2,
|
||||
VividCANPro = 3, // Previously neoVI Yellow
|
||||
neoECU = 4,
|
||||
IEVB = 5,
|
||||
Pendant = 6,
|
||||
neoAnalog = 7,
|
||||
neoECU12 = 8,
|
||||
neoVIPLASMA = 10,
|
||||
neoVIION = 11,
|
||||
ValueCAN4_2EL_4 = 12,
|
||||
cmProbe = 14,
|
||||
EEVB = 15,
|
||||
RADStar = 16,
|
||||
ValueCANrf = 17,
|
||||
neoVIFIRE2 = 18,
|
||||
RADGalaxy = 19,
|
||||
RADStar2 = 20,
|
||||
VividCAN = 21,
|
||||
neoOBD2Sim = 22,
|
||||
neoOBD2Pro = 23,
|
||||
ValueCAN4_1_2 = 24,
|
||||
neoECUAVBTSN = 25,
|
||||
RADSupermoon = 26,
|
||||
RADMoon2 = 27,
|
||||
RADPluto = 28,
|
||||
RADMars = 29,
|
||||
RADIOCANHUB = 30,
|
||||
neoOBD2LCBadge = 31,
|
||||
RADMoonDuo = 32,
|
||||
neoVIFIRE3 = 33,
|
||||
RADJupiter = 34,
|
||||
ValueCAN4Industrial = 35,
|
||||
RADGigastar = 36,
|
||||
VividCANProUnused = 37, // The VividCAN Pro was double allocated
|
||||
EtherBADGE = 38,
|
||||
RADEpsilon = 39,
|
||||
RADA2B = 40,
|
||||
SFPModule = 41,
|
||||
RADGalaxy2 = 47,
|
||||
RADMoon3 = 49,
|
||||
RADComet = 50,
|
||||
Connect = 51,
|
||||
RADComet3 = 54,
|
||||
RADMoonT1S = 56,
|
||||
RADGigastar2 = 57
|
||||
};
|
||||
|
||||
virtual ProductID getProductID() const = 0;
|
||||
|
||||
/**
|
||||
* Returns information for all potential chips, note some chips
|
||||
* might not apply to a specific device depending on different
|
||||
* hardware versions
|
||||
*/
|
||||
virtual const std::vector<ChipInfo>& getChipInfo() const {
|
||||
static std::vector<ChipInfo> placeHolder;
|
||||
return placeHolder; // TODO: Make pure virtual maybe?
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns bootloader instructions
|
||||
*/
|
||||
virtual BootloaderPipeline getBootloader() {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool hasBootloader() { return !!getBootloader(); }
|
||||
|
||||
static std::string SerialNumToString(uint32_t serial);
|
||||
static uint32_t SerialStringToNum(const std::string& serial);
|
||||
static bool SerialStringIsNumeric(const std::string& serial);
|
||||
@@ -568,6 +642,12 @@ public:
|
||||
NODISCARD("If the Lifetime is not held, the callback will be immediately removed")
|
||||
Lifetime addLoggingCallback(ScriptStatusCallback cb) { return addScriptStatusCallback(ScriptStatus::Logging, std::move(cb)); }
|
||||
|
||||
typedef std::function<void(void)> VINAvailableCallback;
|
||||
NODISCARD("If the Lifetime is not held, the callback will be immediately removed")
|
||||
Lifetime addVINAvailableCallback(VINAvailableCallback cb);
|
||||
std::optional<bool> isVINEnabled() const;
|
||||
std::optional<std::string> getVIN() const;
|
||||
|
||||
virtual std::vector<std::shared_ptr<FlexRay::Controller>> getFlexRayControllers() const { return {}; }
|
||||
|
||||
void addExtension(std::shared_ptr<DeviceExtension>&& extension);
|
||||
@@ -580,10 +660,13 @@ public:
|
||||
|
||||
bool refreshComponentVersions();
|
||||
/**
|
||||
* For use by extensions only. A more stable API will be provided in the future.
|
||||
* For use by extensions only.
|
||||
*/
|
||||
const std::vector<std::optional<DeviceAppVersion>>& getVersions() const { return versions; }
|
||||
const std::vector<ComponentVersion>& getComponentVersions() const { return componentVersions; }
|
||||
|
||||
virtual std::vector<VersionReport> getChipVersions(bool refreshComponents = true);
|
||||
|
||||
|
||||
/**
|
||||
* Some alternate communication protocols do not support DFU
|
||||
@@ -931,6 +1014,7 @@ private:
|
||||
std::atomic<bool> wiviSleepRequested{false};
|
||||
std::vector<NewCaptureCallback> newCaptureCallbacks;
|
||||
std::vector< std::pair<SleepRequestedCallback, bool /* notified */> > sleepRequestedCallbacks;
|
||||
std::vector<std::pair<VINAvailableCallback, bool /* notified */>> vinAvailableCallbacks;
|
||||
void wiviThreadBody();
|
||||
void stopWiVIThreadIfNecessary(std::unique_lock<std::mutex> lk);
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
RADComet3 = (0x00000027),
|
||||
RADMoonT1S = (0x00000028),
|
||||
RADGigastar2 = (0x00000029),
|
||||
FIRE3_T1S_LIN = (0x0000002A),
|
||||
FIRE3_T1S_SENT = (0x0000002B),
|
||||
RED = (0x00000040),
|
||||
ECU = (0x00000080),
|
||||
IEVB = (0x00000100),
|
||||
@@ -196,6 +198,10 @@ public:
|
||||
return "neoOBD2 SIM";
|
||||
case FIRE3_FlexRay:
|
||||
return "neoVI FIRE3 FlexRay";
|
||||
case FIRE3_T1S_LIN:
|
||||
return "neoVI FIRE3 T1S/LIN";
|
||||
case FIRE3_T1S_SENT:
|
||||
return "neoVI FIRE3 T1S/SENT";
|
||||
case RADComet3:
|
||||
return "RAD-Comet 3";
|
||||
case RADMoonT1S:
|
||||
@@ -263,6 +269,8 @@ private:
|
||||
#define ICSNEO_DEVICETYPE_RADCOMET3 ((devicetype_t)0x00000027)
|
||||
#define ICSNEO_DEVICETYPE_RADMOONT1S ((devicetype_t)0x00000028)
|
||||
#define ICSNEO_DEVICETYPE_RADGIGASTAR2 ((devicetype_t)0x00000029)
|
||||
#define ICSNEO_DEVICETYPE_FIRE3_T1S_LIN ((devicetype_t)0x0000002A)
|
||||
#define ICSNEO_DEVICETYPE_FIRE3_T1S_SENT ((devicetype_t)0x0000002B)
|
||||
#define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040)
|
||||
#define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080)
|
||||
#define ICSNEO_DEVICETYPE_IEVB ((devicetype_t)0x00000100)
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class Device;
|
||||
|
||||
class DeviceExtension {
|
||||
public:
|
||||
DeviceExtension(Device& device) : device(device) {}
|
||||
|
||||
@@ -21,14 +21,14 @@ typedef enum {
|
||||
FLEXRAY_BAUDRATE_5M = 1, // 5Mbit currently not supported in the monitor
|
||||
FLEXRAY_BAUDRATE_2M5 = 2, // 2.5Mbit currently not supported in the monitor
|
||||
FLEXRAY_BAUDRATE_2M5_ALT = 3 // Per the ERAY spec, 0b11 also means 2.5MBits
|
||||
} neoflexray_speed_t;
|
||||
} SpeedType;
|
||||
|
||||
typedef enum {
|
||||
FLEXRAY_SPP_5 = 0, // FlexRay 2.1 requires this value to be 0
|
||||
FLEXRAY_SPP_4 = 1,
|
||||
FLEXRAY_SPP_6 = 2,
|
||||
FLEXRAY_SPP_5_ALT = 3 // Per the ERAY spec, 0b11 also means sample point 5
|
||||
} neoflexray_spp_t;
|
||||
} SPPType;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -48,50 +48,39 @@ typedef struct {
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
neoflexray_speed_t Speed INIT(FLEXRAY_BAUDRATE_10M /* = 0 */); // gdSampleClockPeriod, pSamplesPerMicrotick, Baud Rate Prescaler
|
||||
neoflexray_spp_t StrobePointPosition INIT(FLEXRAY_SPP_5 /* = 0 */);
|
||||
SpeedType Speed INIT(FLEXRAY_BAUDRATE_10M /* = 0 */); // gdSampleClockPeriod, pSamplesPerMicrotick, Baud Rate Prescaler
|
||||
SPPType StrobePointPosition INIT(FLEXRAY_SPP_5 /* = 0 */);
|
||||
|
||||
uint8_t ActionPointOffset INIT(0);
|
||||
uint32_t BitTimeNS INIT(0);
|
||||
uint8_t CASRxLowMax INIT(0);
|
||||
uint8_t ColdStartAttempts INIT(0);
|
||||
uint32_t CycleCountMax INIT(0);
|
||||
double CycleDurationSec INIT(0);
|
||||
bool DetectNITError INIT(false);
|
||||
uint8_t DynamicSlotIdlePhaseMinislots INIT(0); // In Minislot increments [0..2]
|
||||
uint32_t IgnoreAfterTx INIT(0);
|
||||
uint8_t ListenNoiseMacroticks INIT(0);
|
||||
uint16_t MacroticksPerCycle INIT(0);
|
||||
double MacrotickDurationSec INIT(0);
|
||||
uint8_t MaxWithoutClockCorrectionFatal INIT(0);
|
||||
uint8_t MaxWithoutClockCorrectionPassive INIT(0);
|
||||
uint8_t MinislotActionPointOffsetMacroticks INIT(0);
|
||||
uint32_t MinislotDurationMacroticks INIT(0); // gdMinislot
|
||||
uint32_t NetworkIdleTimeMacroticks INIT(0);
|
||||
uint8_t NetworkManagementVectorLengthBytes INIT(0);
|
||||
uint32_t NumberOfMinislots INIT(0);
|
||||
uint16_t NumberOfStaticSlots INIT(0);
|
||||
uint32_t OffsetCorrectionStartMacroticks INIT(0);
|
||||
uint8_t PayloadLengthOfStaticSlotInWords INIT(0);
|
||||
uint32_t SafetyMarginMacroticks INIT(0);
|
||||
|
||||
double SampleClockPeriodSec INIT(0);
|
||||
bool UseSampleClockPeriodSec INIT(false);
|
||||
uint8_t ActionPointOffset INIT(0); // gdActionPointOffset
|
||||
uint8_t CASRxLowMax INIT(0); // gdCASRxLowMax
|
||||
uint8_t ColdStartAttempts INIT(0); // gColdStartAttempts
|
||||
uint16_t CycleDurationMicroSec INIT(0); // gdCycle
|
||||
uint8_t DynamicSlotIdlePhaseMinislots INIT(0); // gdDynamicSlotIdlePhase, In Minislot increments [0..2]
|
||||
uint8_t ListenNoiseMacroticks INIT(0); // gListenNoise
|
||||
uint16_t MacroticksPerCycle INIT(0); // gMacroPerCycle
|
||||
uint8_t MacrotickDurationMicroSec INIT(0); // gdMacroTick
|
||||
uint8_t MaxWithoutClockCorrectionFatal INIT(0); // gMaxWithoutClockCorrectionFatal
|
||||
uint8_t MaxWithoutClockCorrectionPassive INIT(0); // gMaxWithoutClockCorrectionPassive
|
||||
uint8_t MinislotActionPointOffsetMacroticks INIT(0); // gdMinislotActionPointOffset
|
||||
uint8_t MinislotDurationMacroticks INIT(0); // gdMinislot
|
||||
uint16_t NetworkIdleTimeMacroticks INIT(0); // gdNIT
|
||||
uint8_t NetworkManagementVectorLengthBytes INIT(0); // gNetworkManagementVectorLength
|
||||
uint16_t NumberOfMinislots INIT(0); // gNumberOfMinislots
|
||||
uint16_t NumberOfStaticSlots INIT(0); // gNumberOfStaticSlots
|
||||
uint16_t OffsetCorrectionStartMacroticks INIT(0); // gOffsetCorrectionStart
|
||||
uint8_t PayloadLengthOfStaticSlotInWords INIT(0); // gPayloadLengthStatic
|
||||
|
||||
uint16_t StaticSlotMacroticks INIT(0); // gdStaticSlot
|
||||
uint32_t SymbolWindowMacroticks INIT(0);
|
||||
uint32_t SymbolWindowMacroticks INIT(0); // gdSymbolWindow
|
||||
uint32_t SymbolWindowActionPointOffsetMacroticks INIT(0);
|
||||
uint16_t SyncFrameIDCountMax INIT(0); // gSyncNodeMax
|
||||
|
||||
double TransceiverStandbyDelaySec INIT(false);
|
||||
bool UseTransceiverStandbyDelaySec INIT(0);
|
||||
uint8_t SyncFrameIDCountMax INIT(0); // gSyncNodeMax
|
||||
|
||||
uint8_t TransmissionStartSequenceDurationBits INIT(0); // gdTSSTransmitter
|
||||
uint8_t WakeupRxIdleBits INIT(0);
|
||||
uint8_t WakeupRxLowBits INIT(0);
|
||||
uint8_t WakeupRxIdleBits INIT(0); // gdWakeupSymbolRxIdle
|
||||
uint8_t WakeupRxLowBits INIT(0); // gdWakeupSymbolRxLow
|
||||
uint16_t WakeupRxWindowBits INIT(0); // gdWakeupSymbolRxWindow
|
||||
uint8_t WakeupTxActiveBits INIT(0); // gdWakeupSymbolTxLow (active = low here)
|
||||
uint8_t WakeupTxIdleBits INIT(0);
|
||||
uint8_t WakeupTxIdleBits INIT(0); // gdWakeupSymbolTxIdle
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@@ -26,11 +26,8 @@ namespace FlexRay {
|
||||
class Controller {
|
||||
public:
|
||||
Controller(Device& device, uint8_t index, Network net) : device(device), index(index), network(net) {}
|
||||
void _setStatus(std::shared_ptr<FlexRayControlMessage> msg);
|
||||
|
||||
// Begin Public Interface
|
||||
std::shared_ptr<FlexRayControlMessage> getStatus() const;
|
||||
|
||||
const Network& getNetwork() const { return network; }
|
||||
|
||||
struct Configuration; // Forward declaration
|
||||
@@ -104,7 +101,6 @@ private:
|
||||
Network network;
|
||||
mutable std::mutex statusLock;
|
||||
mutable std::mutex readRegisterLock;
|
||||
std::shared_ptr<FlexRayControlMessage> status;
|
||||
bool startWhenGoingOnline = false;
|
||||
bool allowColdstart = false;
|
||||
bool wakeupBeforeStart = false;
|
||||
@@ -124,29 +120,23 @@ public:
|
||||
typedef struct {
|
||||
#endif // __cplusplus
|
||||
|
||||
uint16_t AcceptStartupRangeMicroticks INIT(0);
|
||||
bool AllowHaltDueToClock INIT(false);
|
||||
uint16_t AcceptStartupRangeMicroticks INIT(0); // pdAcceptedStartupRange
|
||||
bool AllowHaltDueToClock INIT(false); // pAllowHaltDueToClock
|
||||
|
||||
uint8_t AllowPassiveToActiveCyclePairs INIT(0);
|
||||
uint8_t AllowPassiveToActiveCyclePairs INIT(0); // pAllowPassiveToActive
|
||||
|
||||
uint8_t ClusterDriftDamping INIT(0);
|
||||
uint8_t ClusterDriftDamping INIT(0); // pClusterDriftDamping
|
||||
|
||||
bool ChannelA INIT(false);
|
||||
bool ChannelB INIT(false);
|
||||
bool ChannelA INIT(false); // pChannels
|
||||
bool ChannelB INIT(false); // pChannels
|
||||
|
||||
uint8_t DecodingCorrectionMicroticks INIT(0);
|
||||
uint8_t DelayCompensationAMicroticks INIT(0);
|
||||
uint8_t DelayCompensationBMicroticks INIT(0);
|
||||
uint8_t ExternOffsetCorrectionControl INIT(0);
|
||||
uint8_t ExternRateCorrectionControl INIT(0);
|
||||
uint8_t ExternOffsetCorrectionMicroticks INIT(0);
|
||||
uint8_t ExternRateCorrectionMicroticks INIT(0);
|
||||
|
||||
bool ExternalSync INIT(false);
|
||||
bool UseExternalSync INIT(false);
|
||||
|
||||
bool FallBackInternal INIT(false);
|
||||
bool UseFallBackInternal INIT(false);
|
||||
uint8_t DecodingCorrectionMicroticks INIT(0); // pDecodingCorrection
|
||||
uint8_t DelayCompensationAMicroticks INIT(0); // pDelayCompensation[A]
|
||||
uint8_t DelayCompensationBMicroticks INIT(0); // pDelayCompensation[B]
|
||||
uint8_t ExternOffsetCorrectionControl INIT(0); // pExternOffsetControl
|
||||
uint8_t ExternRateCorrectionControl INIT(0); // pExternRateControl
|
||||
uint8_t ExternOffsetCorrectionMicroticks INIT(0); // pExternOffsetCorrection
|
||||
uint8_t ExternRateCorrectionMicroticks INIT(0); // pExternRateCorrection
|
||||
|
||||
uint16_t KeySlotID INIT(0);
|
||||
|
||||
@@ -154,39 +144,28 @@ public:
|
||||
bool KeySlotUsedForStartup INIT(false); // pKeySlotUsedForStartup (TXST)
|
||||
bool KeySlotUsedForSync INIT(false); // pKeySlotUsedForSync (TXSY)
|
||||
|
||||
uint16_t LatestTxMinislot INIT(0);
|
||||
uint32_t ListenTimeout INIT(0);
|
||||
uint16_t LatestTxMinislot INIT(0); // pLatestTx
|
||||
uint32_t ListenTimeout INIT(0); // pdListenTimeout
|
||||
|
||||
uint8_t MacroInitialOffsetA INIT(0); // Valid 2..72
|
||||
uint8_t MacroInitialOffsetB INIT(0); // Valid 2..72
|
||||
uint8_t MacroInitialOffsetA INIT(0); // pMacroInitialOffset[A], Valid 2..72
|
||||
uint8_t MacroInitialOffsetB INIT(0); // pMacroInitialOffset[B], Valid 2..72
|
||||
|
||||
uint32_t MaximumDynamicPayloadLengthWords INIT(0);
|
||||
uint8_t MicroInitialOffsetA INIT(0); // pMicroInitialOffset[A], Valid 0..240
|
||||
uint8_t MicroInitialOffsetB INIT(0); // pMicroInitialOffset[B], Valid 0..240
|
||||
|
||||
uint8_t MicroInitialOffsetA INIT(0); // Valid 0..240
|
||||
uint8_t MicroInitialOffsetB INIT(0); // Valid 0..240
|
||||
|
||||
uint32_t MicroPerCycle INIT(0);
|
||||
|
||||
double MicrotickDurationSec INIT(0);
|
||||
bool UseMicrotickDurationSec INIT(false);
|
||||
uint32_t MicroPerCycle INIT(0); // pMicroPerCycle
|
||||
|
||||
bool MTSOnA INIT(false);
|
||||
bool MTSOnB INIT(false);
|
||||
|
||||
bool NMVectorEarlyUpdate INIT(false);
|
||||
bool UseNMVectorEarlyUpdate INIT(false);
|
||||
|
||||
uint16_t OffsetCorrectionOutMicroticks INIT(0);
|
||||
uint16_t OffsetCorrectionOutMicroticks INIT(0); // pOffsetCorrectionOut
|
||||
uint16_t RateCorrectionOutMicroticks INIT(0); // pdMaxDrift and pRateCorrectionOut
|
||||
|
||||
uint32_t SamplesPerMicrotick INIT(0);
|
||||
bool UseSamplesPerMicrotick INIT(false);
|
||||
|
||||
uint16_t SecondKeySlotID INIT(0);
|
||||
bool TwoKeySlotMode INIT(false);
|
||||
|
||||
uint8_t WakeupPattern INIT(0);
|
||||
bool WakeupOnChannelB INIT(false);
|
||||
bool WakeupOnChannelB INIT(false); // pWakeupChannel
|
||||
|
||||
#ifndef __cplusplus
|
||||
} neoflexray_controller_config_t;
|
||||
|
||||
@@ -24,7 +24,6 @@ public:
|
||||
void onGoOnline() override;
|
||||
void onGoOffline() override;
|
||||
|
||||
void handleMessage(const std::shared_ptr<Message>& message) override;
|
||||
bool transmitHook(const std::shared_ptr<Frame>& frame, bool& success) override;
|
||||
|
||||
std::shared_ptr<Controller> getController(uint8_t index) const {
|
||||
|
||||
@@ -27,15 +27,15 @@ typedef struct {
|
||||
bool isDynamic INIT(false);
|
||||
bool isSync INIT(false); // Must be set if isStartup is set!
|
||||
bool isStartup INIT(false);
|
||||
bool isNMFrame INIT(false);
|
||||
bool isNetworkManagementFrame INIT(false);
|
||||
bool isTransmit INIT(false);
|
||||
uint16_t frameID INIT(0);
|
||||
uint16_t frameID INIT(0); // Frame/Slot ID
|
||||
bool channelA INIT(false);
|
||||
bool channelB INIT(false);
|
||||
uint8_t frameLengthBytes INIT(0);
|
||||
uint8_t baseCycle INIT(0);
|
||||
uint8_t cycleRepetition INIT(0);
|
||||
bool continuousMode INIT(false);
|
||||
bool continuousMode INIT(false); // If false, mode is continuous mode
|
||||
uint16_t _dataPointer INIT(0); // For internal use
|
||||
uint16_t _id INIT(0); // For internal use
|
||||
|
||||
|
||||
@@ -669,10 +669,15 @@ typedef struct
|
||||
#define FIRE3LINUXSETTINGS_SIZE 8
|
||||
static_assert(sizeof(Fire3LinuxSettings) == FIRE3LINUXSETTINGS_SIZE, "Fire3LinuxSettings is the wrong size!");
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4201) // nameless struct/union
|
||||
#endif
|
||||
|
||||
/* Define number of CMP streams per device*/
|
||||
#define CMP_STREAMS_FIRE3 (10)
|
||||
#define CMP_STREAMS_FIRE3FR (10)
|
||||
#define CMP_STREAMS_FIRE3T1SLIN (10)
|
||||
#define CMP_STREAMS_RED2 (10)
|
||||
#define CMP_STREAMS_A2B (3)
|
||||
#define CMP_STREAMS_GIGASTAR (10)
|
||||
@@ -686,7 +691,17 @@ typedef struct
|
||||
uint8_t spare : 4;
|
||||
uint8_t streamId;
|
||||
uint8_t dstMac[6];
|
||||
uint64_t network_enables_1;
|
||||
union
|
||||
{
|
||||
uint64_t word;
|
||||
struct
|
||||
{
|
||||
uint16_t network_enables;
|
||||
uint16_t network_enables_2;
|
||||
uint16_t network_enables_3;
|
||||
uint16_t network_enables_4;
|
||||
};
|
||||
} network_enables;
|
||||
uint64_t network_enables_2;
|
||||
} CMP_NETWORK_DATA;
|
||||
|
||||
@@ -714,7 +729,7 @@ public:
|
||||
using TerminationGroup = std::vector<Network>;
|
||||
|
||||
static constexpr uint16_t GS_VERSION = 5;
|
||||
static std::optional<uint16_t> CalculateGSChecksum(const std::vector<uint8_t>& settings, std::optional<size_t> knownSize = std::nullopt);
|
||||
static std::optional<uint16_t> CalculateGSChecksum(const std::vector<uint8_t>& settings);
|
||||
static CANBaudrate GetEnumValueForBaudrate(int64_t baudrate);
|
||||
static int64_t GetBaudrateValueForEnum(CANBaudrate enumValue);
|
||||
static bool ValidateLINBaudrate(int64_t baudrate);
|
||||
@@ -723,7 +738,7 @@ public:
|
||||
virtual ~IDeviceSettings() {}
|
||||
bool ok() const { return !disabled && settingsLoaded; }
|
||||
|
||||
virtual bool refresh(bool ignoreChecksum = false); // Get from device
|
||||
virtual bool refresh(); // Get from device
|
||||
|
||||
// Send to device, if temporary device keeps settings in volatile RAM until power cycle, otherwise saved to EEPROM
|
||||
virtual bool apply(bool temporary = false);
|
||||
@@ -931,7 +946,6 @@ public:
|
||||
bool disabled = false;
|
||||
|
||||
bool readonly = false;
|
||||
bool disableGSChecksumming = false;
|
||||
|
||||
std::atomic<bool> applyingSettings{false};
|
||||
protected:
|
||||
|
||||
@@ -26,6 +26,10 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::EtherBADGE;
|
||||
}
|
||||
|
||||
protected:
|
||||
EtherBADGE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<EtherBADGESettings>(makeDriver);
|
||||
|
||||
@@ -22,6 +22,10 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoOBD2Pro;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoOBD2PRO(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize(makeDriver);
|
||||
|
||||
@@ -21,7 +21,10 @@ public:
|
||||
};
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoOBD2Sim;
|
||||
}
|
||||
private:
|
||||
NeoOBD2SIM(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize(makeDriver);
|
||||
|
||||
@@ -34,6 +34,28 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::Connect;
|
||||
}
|
||||
|
||||
const std::vector<ChipInfo>& getChipInfo() const override {
|
||||
static std::vector<ChipInfo> chips = {
|
||||
{ChipID::Connect_ZCHIP, true, "ZCHIP", "neovi_connect_zchip_ief", 0, FirmwareType::IEF},
|
||||
{ChipID::Connect_LINUX, true, "Linux Flash", "neovi_connect_lnx_flash_ief", 1, FirmwareType::IEF},
|
||||
};
|
||||
return chips;
|
||||
}
|
||||
|
||||
BootloaderPipeline getBootloader() override {
|
||||
return BootloaderPipeline()
|
||||
.add<FlashPhase>(ChipID::Connect_ZCHIP, BootloaderCommunication::Application, true, false, false)
|
||||
.add<FlashPhase>(ChipID::Connect_LINUX, BootloaderCommunication::Application, false, false, false)
|
||||
.add<FinalizePhase>(ChipID::Connect_ZCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::Connect_LINUX, BootloaderCommunication::Application)
|
||||
.add<ReconnectPhase>()
|
||||
.addSetting(BootloaderSetting::UpdateAll, true);
|
||||
}
|
||||
|
||||
protected:
|
||||
NeoVIConnect(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIConnectSettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace icsneo {
|
||||
class NeoVIFIRE : public Device {
|
||||
public:
|
||||
// USB PID is 0x0701, standard driver is DXX
|
||||
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIFIRE, DeviceType::FIRE, 0x0701);
|
||||
ICSNEO_FINDABLE_DEVICE_BY_SERIAL_RANGE(NeoVIFIRE, DeviceType::FIRE, "50000", "79999");
|
||||
|
||||
static const std::vector<Network>& GetSupportedNetworks() {
|
||||
static std::vector<Network> supportedNetworks = {
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE;
|
||||
}
|
||||
private:
|
||||
NeoVIFIRE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRESettings>(makeDriver);
|
||||
|
||||
@@ -87,6 +87,28 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE2;
|
||||
}
|
||||
|
||||
const std::vector<ChipInfo>& getChipInfo() const override {
|
||||
static std::vector<ChipInfo> chips = {
|
||||
{ChipID::neoVIFIRE2_MCHIP, true, "MCHIP", "fire2_mchip_ief", 0, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE2_ZYNQ, true, "ZCHIP", "fire2_zchip_ief", 1, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE2_Core, true, "Core", "fire2_core", 2, FirmwareType::IEF},
|
||||
};
|
||||
return chips;
|
||||
}
|
||||
|
||||
BootloaderPipeline getBootloader() override {
|
||||
return BootloaderPipeline()
|
||||
.add<EnterBootloaderPhase>()
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE2_MCHIP, BootloaderCommunication::RED)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE2_ZYNQ, BootloaderCommunication::RED, false, true)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE2_Core, BootloaderCommunication::REDCore, false, false)
|
||||
.add<ReconnectPhase>();
|
||||
}
|
||||
|
||||
protected:
|
||||
NeoVIFIRE2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE2Settings, Disk::NeoMemoryDiskDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -50,6 +50,34 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
size_t getEthernetActivationLineCount() const override { return 2; }
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE3;
|
||||
}
|
||||
|
||||
const std::vector<ChipInfo>& getChipInfo() const override {
|
||||
static std::vector<ChipInfo> chips = {
|
||||
{ChipID::neoVIFIRE3_ZCHIP, true, "ZCHIP", "fire3_zchip_ief", 0, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE3_SCHIP, true, "SCHIP", "fire3_schip_ief", 1, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE3_LINUX, true, "Linux Flash", "fire3_lnx_flash_ief", 2, FirmwareType::IEF},
|
||||
{ChipID::VEM_01_8DW_ZCHIP, true, "VEM-01-Z", "vem_01_8dw_zchip_ief", 3, FirmwareType::IEF}
|
||||
};
|
||||
return chips;
|
||||
}
|
||||
|
||||
BootloaderPipeline getBootloader() override {
|
||||
return BootloaderPipeline()
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_ZCHIP, BootloaderCommunication::Application, true, false)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_SCHIP, BootloaderCommunication::Application, false, true)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_LINUX, BootloaderCommunication::Application, false, false, false)
|
||||
.add<FlashPhase>(ChipID::VEM_01_8DW_ZCHIP, BootloaderCommunication::Application, false, false)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_ZCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_SCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_LINUX, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::VEM_01_8DW_ZCHIP, BootloaderCommunication::Application)
|
||||
.add<ReconnectPhase>()
|
||||
.addSetting(BootloaderSetting::UpdateAll, true);
|
||||
}
|
||||
protected:
|
||||
NeoVIFIRE3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE3Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
@@ -80,7 +108,7 @@ protected:
|
||||
bool supportsGPTP() const override { return true; }
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
|
||||
return 33*1024*1024;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||
|
||||
@@ -139,6 +139,10 @@ typedef struct {
|
||||
|
||||
uint64_t network_enables_2;
|
||||
uint64_t termination_enables_2;
|
||||
uint16_t iso_tester_pullup_enable;
|
||||
CMP_GLOBAL_DATA cmp_global_data;
|
||||
CMP_NETWORK_DATA cmp_stream_data[CMP_STREAMS_FIRE3];
|
||||
uint32_t networkTimeSync;
|
||||
} neovifire3_settings_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
#include "icsneo/disk/extextractordiskreaddriver.h"
|
||||
#include "icsneo/disk/neomemorydiskdriver.h"
|
||||
#include "icsneo/device/tree/neovifire3flexray/neovifire3flexraysettings.h"
|
||||
#include "icsneo/device/extensions/flexray/extension.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class NeoVIFIRE3FlexRay : public Device {
|
||||
public:
|
||||
// Serial numbers start with FF
|
||||
// Ethernet MAC allocation is 1F, standard driver is Raw
|
||||
// Ethernet MAC allocation is 0x1E, standard driver is Raw
|
||||
ICSNEO_FINDABLE_DEVICE(NeoVIFIRE3FlexRay, DeviceType::FIRE3_FlexRay, "FF");
|
||||
|
||||
static const std::vector<Network>& GetSupportedNetworks() {
|
||||
@@ -52,6 +53,36 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE3;
|
||||
}
|
||||
|
||||
const std::vector<ChipInfo>& getChipInfo() const override {
|
||||
static std::vector<ChipInfo> chips = {
|
||||
{ChipID::neoVIFIRE3_ZCHIP, true, "ZCHIP", "fire3_zchip_ief", 0, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE3_SCHIP, true, "SCHIP", "fire3_schip_ief", 1, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE3_LINUX, true, "Linux Flash", "fire3_lnx_flash_ief", 2, FirmwareType::IEF},
|
||||
{ChipID::VEM_02_FR_ZCHIP, true, "VEM-02-Z", "vem_02_fr_zchip_ief", 3, FirmwareType::IEF},
|
||||
{ChipID::VEM_02_FR_FCHIP, true, "VEM-02-F", "vem_02_fr_fchip_ief", 4, FirmwareType::IEF},
|
||||
};
|
||||
return chips;
|
||||
}
|
||||
|
||||
BootloaderPipeline getBootloader() override {
|
||||
return BootloaderPipeline()
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_ZCHIP, BootloaderCommunication::Application, true, false)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_SCHIP, BootloaderCommunication::Application, false, true)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_LINUX, BootloaderCommunication::Application, false, false, false)
|
||||
.add<FlashPhase>(ChipID::VEM_02_FR_FCHIP, BootloaderCommunication::Application, false, false)
|
||||
.add<FlashPhase>(ChipID::VEM_02_FR_ZCHIP, BootloaderCommunication::Application, false, false)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_ZCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_SCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_LINUX, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::VEM_02_FR_FCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::VEM_02_FR_ZCHIP, BootloaderCommunication::Application)
|
||||
.add<ReconnectPhase>()
|
||||
.addSetting(BootloaderSetting::UpdateAll, true);
|
||||
}
|
||||
protected:
|
||||
NeoVIFIRE3FlexRay(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE3FlexRaySettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
@@ -80,7 +111,7 @@ protected:
|
||||
bool supportsLiveData() const override { return true; }
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
|
||||
return 512*4;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||
@@ -90,6 +121,30 @@ protected:
|
||||
bool supportsEraseMemory() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void setupExtensions() override {
|
||||
std::vector<Network> flexRayControllers;
|
||||
flexRayControllers.push_back(Network::NetID::FLEXRAY_01);
|
||||
flexRayControllers.push_back(Network::NetID::FLEXRAY_01);
|
||||
addExtension(std::make_shared<FlexRay::Extension>(*this, flexRayControllers));
|
||||
|
||||
}
|
||||
|
||||
virtual std::vector<std::shared_ptr<FlexRay::Controller>> getFlexRayControllers() const override {
|
||||
auto extension = getExtension<FlexRay::Extension>();
|
||||
if(!extension)
|
||||
return Device::getFlexRayControllers();
|
||||
|
||||
std::vector<std::shared_ptr<FlexRay::Controller>> ret;
|
||||
|
||||
if(auto ctrl1 = extension->getController(0))
|
||||
ret.push_back(std::move(ctrl1));
|
||||
|
||||
if(auto ctrl2 = extension->getController(1))
|
||||
ret.push_back(std::move(ctrl2));
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -122,6 +122,10 @@ typedef struct {
|
||||
|
||||
uint16_t flex_mode;
|
||||
uint16_t flex_termination;
|
||||
uint16_t iso_tester_pullup_enable;
|
||||
CMP_GLOBAL_DATA cmp_global_data;
|
||||
CMP_NETWORK_DATA cmp_stream_data[CMP_STREAMS_FIRE3FR];
|
||||
uint32_t networkTimeSync;
|
||||
} neovifire3flexray_settings_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
#ifndef __NEOVIFIRE3T1SLIN_H_
|
||||
#define __NEOVIFIRE3T1SLIN_H_
|
||||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/disk/extextractordiskreaddriver.h"
|
||||
#include "icsneo/disk/neomemorydiskdriver.h"
|
||||
#include "icsneo/device/tree/neovifire3t1slin/neovifire3t1slinsettings.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class NeoVIFIRE3T1SLIN : public Device {
|
||||
public:
|
||||
// Serial numbers start with FT
|
||||
// Ethernet MAC allocation is 0x1E, standard driver is Raw
|
||||
ICSNEO_FINDABLE_DEVICE(NeoVIFIRE3T1SLIN, DeviceType::FIRE3_T1S_LIN, "FT");
|
||||
|
||||
static const std::vector<Network>& GetSupportedNetworks() {
|
||||
static std::vector<Network> supportedNetworks = {
|
||||
Network::NetID::DWCAN_01,
|
||||
Network::NetID::DWCAN_08,
|
||||
Network::NetID::DWCAN_02,
|
||||
Network::NetID::DWCAN_03,
|
||||
Network::NetID::DWCAN_04,
|
||||
Network::NetID::DWCAN_05,
|
||||
Network::NetID::DWCAN_06,
|
||||
Network::NetID::DWCAN_07,
|
||||
|
||||
Network::NetID::LIN_01,
|
||||
Network::NetID::LIN_02,
|
||||
Network::NetID::LIN_03,
|
||||
Network::NetID::LIN_04,
|
||||
Network::NetID::LIN_05,
|
||||
Network::NetID::LIN_06,
|
||||
Network::NetID::LIN_07,
|
||||
Network::NetID::LIN_08,
|
||||
Network::NetID::LIN_09,
|
||||
Network::NetID::LIN_10,
|
||||
|
||||
Network::NetID::ISO9141_01,
|
||||
Network::NetID::ISO9141_02,
|
||||
Network::NetID::ISO9141_03,
|
||||
Network::NetID::ISO9141_04,
|
||||
|
||||
Network::NetID::ETHERNET_01,
|
||||
Network::NetID::ETHERNET_02,
|
||||
|
||||
Network::NetID::AE_01,
|
||||
Network::NetID::AE_02,
|
||||
Network::NetID::AE_03,
|
||||
Network::NetID::AE_04,
|
||||
Network::NetID::AE_05,
|
||||
Network::NetID::AE_06,
|
||||
Network::NetID::AE_07,
|
||||
Network::NetID::AE_08,
|
||||
};
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsTC10() const override { return true; }
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE3;
|
||||
}
|
||||
protected:
|
||||
NeoVIFIRE3T1SLIN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE3T1SLINSettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
}
|
||||
|
||||
virtual void setupEncoder(Encoder& encoder) override {
|
||||
Device::setupEncoder(encoder);
|
||||
encoder.supportCANFD = true;
|
||||
}
|
||||
|
||||
void setupPacketizer(Packetizer& packetizer) override {
|
||||
Device::setupPacketizer(packetizer);
|
||||
packetizer.align16bit = true;
|
||||
}
|
||||
|
||||
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||
for(auto& netid : GetSupportedNetworks())
|
||||
rxNetworks.emplace_back(netid);
|
||||
}
|
||||
|
||||
// The supported TX networks are the same as the supported RX networks for this device
|
||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||
|
||||
bool supportsWiVI() const override { return true; }
|
||||
|
||||
bool supportsLiveData() const override { return true; }
|
||||
|
||||
bool supportsGPTP() const override { return true; }
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool supportsEraseMemory() const override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,271 @@
|
||||
#ifndef __NEOVIFIRE3T1SLINSETTINGS_H_
|
||||
#define __NEOVIFIRE3T1SLINSETTINGS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "icsneo/device/idevicesettings.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4201) // nameless struct/union
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 2)
|
||||
typedef struct {
|
||||
uint16_t perf_en;
|
||||
uint16_t network_enabled_on_boot;
|
||||
uint16_t misc_io_on_report_events;
|
||||
uint16_t pwr_man_enable;
|
||||
int16_t iso15765_separation_time_offset;
|
||||
uint16_t slaveVnetA;
|
||||
uint32_t reserved;
|
||||
uint64_t termination_enables;
|
||||
uint64_t network_enables;
|
||||
uint32_t pwr_man_timeout;
|
||||
CAN_SETTINGS can1;
|
||||
CANFD_SETTINGS canfd1;
|
||||
CAN_SETTINGS can2;
|
||||
CANFD_SETTINGS canfd2;
|
||||
CAN_SETTINGS can3;
|
||||
CANFD_SETTINGS canfd3;
|
||||
CAN_SETTINGS can4;
|
||||
CANFD_SETTINGS canfd4;
|
||||
CAN_SETTINGS can5;
|
||||
CANFD_SETTINGS canfd5;
|
||||
CAN_SETTINGS can6;
|
||||
CANFD_SETTINGS canfd6;
|
||||
CAN_SETTINGS can7;
|
||||
CANFD_SETTINGS canfd7;
|
||||
CAN_SETTINGS can8;
|
||||
CANFD_SETTINGS canfd8;
|
||||
LIN_SETTINGS lin1;
|
||||
LIN_SETTINGS lin2;
|
||||
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
|
||||
uint16_t iso_parity_1;
|
||||
uint16_t iso_msg_termination_1;
|
||||
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
|
||||
uint16_t iso_parity_2;
|
||||
uint16_t iso_msg_termination_2;
|
||||
ETHERNET_SETTINGS ethernet_1;
|
||||
TIMESYNC_ICSHARDWARE_SETTINGS timeSync;
|
||||
STextAPISettings text_api;
|
||||
struct
|
||||
{
|
||||
uint32_t disableUsbCheckOnBoot : 1;
|
||||
uint32_t enableLatencyTest : 1;
|
||||
uint32_t busMessagesToAndroid : 1;
|
||||
uint32_t reserved1 : 1;
|
||||
uint32_t enableDefaultLogger : 1;
|
||||
uint32_t enableDefaultUpload : 1;
|
||||
uint32_t reserved : 26;
|
||||
} flags;
|
||||
DISK_SETTINGS disk;
|
||||
uint16_t misc_io_report_period;
|
||||
uint16_t ain_threshold;
|
||||
uint16_t misc_io_analog_enable;
|
||||
uint16_t digitalIoThresholdTicks;
|
||||
uint16_t digitalIoThresholdEnable;
|
||||
uint16_t misc_io_initial_ddr;
|
||||
uint16_t misc_io_initial_latch;
|
||||
ETHERNET_SETTINGS2 ethernet2_1;
|
||||
ETHERNET_SETTINGS ethernet_2;
|
||||
ETHERNET_SETTINGS2 ethernet2_2;
|
||||
Fire3LinuxSettings os_settings;
|
||||
RAD_GPTP_SETTINGS gPTP;
|
||||
|
||||
/* VEM */
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s1;
|
||||
ETHERNET10T1S_SETTINGS t1s1;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s1Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s2;
|
||||
ETHERNET10T1S_SETTINGS t1s2;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s2Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s3;
|
||||
ETHERNET10T1S_SETTINGS t1s3;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s3Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s4;
|
||||
ETHERNET10T1S_SETTINGS t1s4;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s4Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s5;
|
||||
ETHERNET10T1S_SETTINGS t1s5;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s5Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s6;
|
||||
ETHERNET10T1S_SETTINGS t1s6;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s6Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s7;
|
||||
ETHERNET10T1S_SETTINGS t1s7;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s7Ext;
|
||||
// 10T1S
|
||||
ETHERNET_SETTINGS2 ethT1s8;
|
||||
ETHERNET10T1S_SETTINGS t1s8;
|
||||
ETHERNET10T1S_SETTINGS_EXT t1s8Ext;
|
||||
|
||||
LIN_SETTINGS lin3;
|
||||
LIN_SETTINGS lin4;
|
||||
LIN_SETTINGS lin5;
|
||||
LIN_SETTINGS lin6;
|
||||
LIN_SETTINGS lin7;
|
||||
LIN_SETTINGS lin8;
|
||||
LIN_SETTINGS lin9;
|
||||
LIN_SETTINGS lin10;
|
||||
|
||||
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_3;
|
||||
uint16_t iso_parity_3;
|
||||
uint16_t iso_msg_termination_3;
|
||||
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_4;
|
||||
uint16_t iso_parity_4;
|
||||
uint16_t iso_msg_termination_4;
|
||||
|
||||
uint16_t iso_tester_pullup_enable;
|
||||
|
||||
uint64_t network_enables_5;
|
||||
|
||||
CMP_GLOBAL_DATA cmp_global_data;
|
||||
CMP_NETWORK_DATA cmp_stream_data[CMP_STREAMS_FIRE3T1SLIN];
|
||||
uint32_t networkTimeSync;
|
||||
} neovifire3t1slin_settings_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t backupPowerGood;
|
||||
uint8_t backupPowerEnabled;
|
||||
uint8_t usbHostPowerEnabled;
|
||||
uint8_t ethernetActivationLineEnabled;
|
||||
EthernetNetworkStatus ethernetStatus;
|
||||
} neovifire3t1slin_status_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class NeoVIFIRE3T1SLINSettings : public IDeviceSettings {
|
||||
public:
|
||||
NeoVIFIRE3T1SLINSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire3t1slin_settings_t)) {}
|
||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
switch(net.getNetID()) {
|
||||
case Network::NetID::DWCAN_01:
|
||||
return &(cfg->can1);
|
||||
case Network::NetID::DWCAN_08:
|
||||
return &(cfg->can2);
|
||||
case Network::NetID::DWCAN_02:
|
||||
return &(cfg->can3);
|
||||
case Network::NetID::DWCAN_03:
|
||||
return &(cfg->can4);
|
||||
case Network::NetID::DWCAN_04:
|
||||
return &(cfg->can5);
|
||||
case Network::NetID::DWCAN_05:
|
||||
return &(cfg->can6);
|
||||
case Network::NetID::DWCAN_06:
|
||||
return &(cfg->can7);
|
||||
case Network::NetID::DWCAN_07:
|
||||
return &(cfg->can8);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
switch(net.getNetID()) {
|
||||
case Network::NetID::DWCAN_01:
|
||||
return &(cfg->canfd1);
|
||||
case Network::NetID::DWCAN_08:
|
||||
return &(cfg->canfd2);
|
||||
case Network::NetID::DWCAN_02:
|
||||
return &(cfg->canfd3);
|
||||
case Network::NetID::DWCAN_03:
|
||||
return &(cfg->canfd4);
|
||||
case Network::NetID::DWCAN_04:
|
||||
return &(cfg->canfd5);
|
||||
case Network::NetID::DWCAN_05:
|
||||
return &(cfg->canfd6);
|
||||
case Network::NetID::DWCAN_06:
|
||||
return &(cfg->canfd7);
|
||||
case Network::NetID::DWCAN_07:
|
||||
return &(cfg->canfd8);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
virtual std::vector<TerminationGroup> getTerminationGroups() const override {
|
||||
return {
|
||||
{
|
||||
Network(Network::NetID::DWCAN_01),
|
||||
Network(Network::NetID::DWCAN_03),
|
||||
Network(Network::NetID::DWCAN_05),
|
||||
Network(Network::NetID::DWCAN_07)
|
||||
},
|
||||
{
|
||||
Network(Network::NetID::DWCAN_08),
|
||||
Network(Network::NetID::DWCAN_02),
|
||||
Network(Network::NetID::DWCAN_04),
|
||||
Network(Network::NetID::DWCAN_06)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const LIN_SETTINGS* getLINSettingsFor(Network net) const override {
|
||||
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
switch(net.getNetID()) {
|
||||
case Network::NetID::LIN_01:
|
||||
return &(cfg->lin1);
|
||||
case Network::NetID::LIN_02:
|
||||
return &(cfg->lin2);
|
||||
case Network::NetID::LIN_03:
|
||||
return &(cfg->lin3);
|
||||
case Network::NetID::LIN_04:
|
||||
return &(cfg->lin4);
|
||||
case Network::NetID::LIN_05:
|
||||
return &(cfg->lin5);
|
||||
case Network::NetID::LIN_06:
|
||||
return &(cfg->lin6);
|
||||
case Network::NetID::LIN_07:
|
||||
return &(cfg->lin7);
|
||||
case Network::NetID::LIN_08:
|
||||
return &(cfg->lin8);
|
||||
case Network::NetID::LIN_09:
|
||||
return &(cfg->lin9);
|
||||
case Network::NetID::LIN_10:
|
||||
return &(cfg->lin10);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override {
|
||||
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -37,6 +37,30 @@ public:
|
||||
|
||||
bool supportsGPTP() const override { return true; }
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIFIRE3;
|
||||
}
|
||||
|
||||
const std::vector<ChipInfo>& getChipInfo() const override {
|
||||
static std::vector<ChipInfo> chips = {
|
||||
{ChipID::neoVIFIRE3_ZCHIP, true, "ZCHIP", "fire3_zchip_ief", 0, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE3_SCHIP, true, "SCHIP", "fire3_schip_ief", 1, FirmwareType::IEF},
|
||||
{ChipID::neoVIFIRE3_LINUX, true, "Linux Flash", "fire3_lnx_flash_ief", 2, FirmwareType::IEF}
|
||||
};
|
||||
return chips;
|
||||
}
|
||||
|
||||
BootloaderPipeline getBootloader() override {
|
||||
return BootloaderPipeline()
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_ZCHIP, BootloaderCommunication::Application, true, false)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_SCHIP, BootloaderCommunication::Application, false, true)
|
||||
.add<FlashPhase>(ChipID::neoVIFIRE3_LINUX, BootloaderCommunication::Application, false, false, false)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_ZCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_SCHIP, BootloaderCommunication::Application)
|
||||
.add<FinalizePhase>(ChipID::neoVIFIRE3_LINUX, BootloaderCommunication::Application)
|
||||
.add<ReconnectPhase>()
|
||||
.addSetting(BootloaderSetting::UpdateAll, true);
|
||||
}
|
||||
protected:
|
||||
NeoVIRED2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIRED2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -13,8 +13,11 @@ namespace icsneo {
|
||||
class NeoVIION : public Plasion {
|
||||
public:
|
||||
// USB PID is 0x0901, standard driver is DXX
|
||||
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIION, DeviceType::ION, 0x0901);
|
||||
ICSNEO_FINDABLE_DEVICE(NeoVIION, DeviceType::ION, "40");
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIION;
|
||||
}
|
||||
private:
|
||||
NeoVIION(neodevice_t neodevice, const driver_factory_t& makeDriver) : Plasion(neodevice) {
|
||||
initialize<NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -11,8 +11,11 @@ namespace icsneo {
|
||||
class NeoVIPLASMA : public Plasion {
|
||||
public:
|
||||
// USB PID is 0x0801, standard driver is DXX
|
||||
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIPLASMA, DeviceType::PLASMA, 0x0801);
|
||||
ICSNEO_FINDABLE_DEVICE(NeoVIPLASMA, DeviceType::PLASMA, "30");
|
||||
|
||||
ProductID getProductID() const override {
|
||||
return ProductID::neoVIPLASMA;
|
||||
}
|
||||
private:
|
||||
NeoVIPLASMA(neodevice_t neodevice, const driver_factory_t& makeDriver) : Plasion(neodevice) {
|
||||
initialize<NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user