From 52e98af9fd84658fce7701a33d21669385ddd4be Mon Sep 17 00:00:00 2001 From: Jonathan Schwartz Date: Tue, 25 Mar 2025 20:43:18 +0000 Subject: [PATCH] Device: Add RAD-EpsilonXL --- README.md | 2 + .../python/icsneopy/device/devicetype.cpp | 1 + device/devicefinder.cpp | 8 ++ include/icsneo/device/devicetype.h | 4 + .../device/tree/radepsilon/radepsilon.h | 3 +- .../tree/radepsilon/radepsilonsettings.h | 131 ++++++++++++++++++ .../device/tree/radepsilonxl/radepsilonxl.h | 63 +++++++++ include/icsneo/platform/posix/devices.h | 1 + include/icsneo/platform/windows/devices.h | 1 + 9 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 include/icsneo/device/tree/radepsilon/radepsilonsettings.h create mode 100644 include/icsneo/device/tree/radepsilonxl/radepsilonxl.h diff --git a/README.md b/README.md index 2724676..23cd337 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ each of the respective APIs. - RAD-A2B - RAD-Comet 2 - RAD-Comet 3 +- RAD-Epsilon +- RAD-EpsilonXL - RAD-Galaxy - RAD-Galaxy 2 - RAD-Gigastar diff --git a/bindings/python/icsneopy/device/devicetype.cpp b/bindings/python/icsneopy/device/devicetype.cpp index 57a9bb7..68d7b96 100644 --- a/bindings/python/icsneopy/device/devicetype.cpp +++ b/bindings/python/icsneopy/device/devicetype.cpp @@ -33,6 +33,7 @@ void init_devicetype(pybind11::module_& m) { .value("EtherBADGE", DeviceType::Enum::EtherBADGE) .value("RAD_A2B", DeviceType::Enum::RAD_A2B) .value("RADEpsilon", DeviceType::Enum::RADEpsilon) + .value("RADEpsilonXL", DeviceType::Enum::RADEpsilonXL) .value("RADGalaxy2", DeviceType::Enum::RADGalaxy2) .value("RADMoon3", DeviceType::Enum::RADMoon3) .value("RADComet", DeviceType::Enum::RADComet) diff --git a/device/devicefinder.cpp b/device/devicefinder.cpp index f5ba93b..d828303 100644 --- a/device/devicefinder.cpp +++ b/device/devicefinder.cpp @@ -193,6 +193,10 @@ std::vector> DeviceFinder::FindAll() { makeIfSerialMatches(dev, newFoundDevices); #endif + #ifdef __RADEPSILONXL_H_ + makeIfSerialMatches(dev, newFoundDevices); + #endif + #ifdef __RADGALAXY_H_ makeIfSerialMatches(dev, newFoundDevices); #endif @@ -352,6 +356,10 @@ const std::vector& DeviceFinder::GetSupportedDevices() { RADEpsilon::DEVICE_TYPE, #endif + #ifdef __RADEPSILONXL_H_ + RADEpsilonXL::DEVICE_TYPE, + #endif + #ifdef __RADGALAXY_H_ RADGalaxy::DEVICE_TYPE, #endif diff --git a/include/icsneo/device/devicetype.h b/include/icsneo/device/devicetype.h index 64b5ee8..6f7bbb2 100644 --- a/include/icsneo/device/devicetype.h +++ b/include/icsneo/device/devicetype.h @@ -47,6 +47,7 @@ public: EtherBADGE = (0x00000016), RAD_A2B = (0x00000017), RADEpsilon = (0x00000018), + RADEpsilonXL = (0x0000001e), RADGalaxy2 = (0x00000021), RADMoon3 = (0x00000023), RADComet = (0x00000024), @@ -141,6 +142,8 @@ public: return "RAD-A2B"; case RADEpsilon: return "RAD-Epsilon"; + case RADEpsilonXL: + return "RAD-EpsilonXL"; case RADMoon3: return "RAD-Moon 3"; case RADComet: @@ -251,6 +254,7 @@ private: #define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) #define ICSNEO_DEVICETYPE_RAD_A2B ((devicetype_t)0x00000017) #define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)0x00000018) +#define ICSNEO_DEVICETYPE_RADEPSILONXL ((devicetype_t)0x0000001e) #define ICSNEO_DEVICETYPE_RADGALAXY2 ((devicetype_t)0x00000021) #define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023) #define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024) diff --git a/include/icsneo/device/tree/radepsilon/radepsilon.h b/include/icsneo/device/tree/radepsilon/radepsilon.h index 3b51a8a..9c1d34d 100644 --- a/include/icsneo/device/tree/radepsilon/radepsilon.h +++ b/include/icsneo/device/tree/radepsilon/radepsilon.h @@ -3,6 +3,7 @@ #include "icsneo/device/device.h" #include "icsneo/device/devicetype.h" +#include "icsneo/device/tree/radepsilon/radepsilonsettings.h" namespace icsneo { @@ -28,7 +29,7 @@ public: protected: RADEpsilon(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) { - initialize(makeDriver); + initialize(makeDriver); } virtual void setupEncoder(Encoder& encoder) override { diff --git a/include/icsneo/device/tree/radepsilon/radepsilonsettings.h b/include/icsneo/device/tree/radepsilon/radepsilonsettings.h new file mode 100644 index 0000000..ee29f82 --- /dev/null +++ b/include/icsneo/device/tree/radepsilon/radepsilonsettings.h @@ -0,0 +1,131 @@ +#ifndef __RADEPSILONSETTINGS_H_ +#define __RADEPSILONSETTINGS_H_ + +#include +#include "icsneo/device/idevicesettings.h" +#include "icsneo/communication/network.h" + +#ifdef __cplusplus + +namespace icsneo { + +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4201) // nameless struct/union +#endif + +#pragma pack(push, 2) +#define RADEPSILON_MAX_PHY 18 +typedef struct { + uint8_t phyMode[RADEPSILON_MAX_PHY]; + uint8_t enablePhy[RADEPSILON_MAX_PHY]; + uint8_t speed[RADEPSILON_MAX_PHY]; + uint8_t legacy[RADEPSILON_MAX_PHY]; + uint8_t spoofedMac[6]; + uint8_t spoofMacFlag; + uint8_t pad; +} radepsilon_switch_settings_t; + +typedef struct { + /* Performance Test */ + uint16_t perf_en; + + CAN_SETTINGS can1; + CANFD_SETTINGS canfd1; + CAN_SETTINGS can2; + CANFD_SETTINGS canfd2; + LIN_SETTINGS lin1; + + uint16_t network_enables[3]; + uint64_t termination_enables; + uint16_t misc_io_analog_enable; + + uint32_t pwr_man_timeout; + uint16_t pwr_man_enable; + + uint16_t network_enabled_on_boot; + + /* ISO15765-2 Transport Layer */ + int16_t iso15765_separation_time_offset; + uint16_t iso9141_kwp_enable_reserved; + uint16_t iso_tester_pullup_enable; + uint16_t iso_parity; + uint16_t iso_msg_termination; + ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings; + ETHERNET_SETTINGS ethernet; + + STextAPISettings text_api; + + struct + { + uint32_t disableUsbCheckOnBoot : 1; + uint32_t enableLatencyTest : 1; + uint32_t enablePcEthernetComm : 1; + uint32_t reserved : 29; + } flags; + + radepsilon_switch_settings_t switchSettings; + ETHERNET_SETTINGS2 ethernet2; + uint16_t misc_io_on_report_events; + DISK_SETTINGS disk; +} radepsilon_settings_t; +#pragma pack(pop) + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#ifdef __cplusplus + +#include + +class RADEpsilonSettings : public IDeviceSettings { +public: + RADEpsilonSettings(std::shared_ptr com) : IDeviceSettings(com, sizeof(radepsilon_settings_t)) {} + const CAN_SETTINGS* getCANSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::HSCAN: + return &(cfg->can1); + case Network::NetID::HSCAN2: + return &(cfg->can2); + default: + return nullptr; + } + } + const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::HSCAN: + return &(cfg->canfd1); + case Network::NetID::HSCAN2: + return &(cfg->canfd2); + default: + return nullptr; + } + } + + const LIN_SETTINGS* getLINSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LIN: + return &(cfg->lin1); + default: + return nullptr; + } + } +}; + +}; // namespace icsneo + +#endif // __cplusplus + +#endif // __RADEPSILONSETTINGS_H_ diff --git a/include/icsneo/device/tree/radepsilonxl/radepsilonxl.h b/include/icsneo/device/tree/radepsilonxl/radepsilonxl.h new file mode 100644 index 0000000..145f9fc --- /dev/null +++ b/include/icsneo/device/tree/radepsilonxl/radepsilonxl.h @@ -0,0 +1,63 @@ +#ifndef __RADEPSILONXL_H_ +#define __RADEPSILONXL_H_ + +#include "icsneo/device/device.h" +#include "icsneo/device/devicetype.h" +#include "icsneo/device/tree/radepsilon/radepsilonsettings.h" // Shared settings with RADEpsilon + +namespace icsneo { + +class RADEpsilonXL : public Device { +public: + // Serial numbers start with PX + // USB PID is 0x1109, standard driver is CDCACM + ICSNEO_FINDABLE_DEVICE(RADEpsilonXL, DeviceType::RADEpsilonXL, "PX"); + + static const std::vector& GetSupportedNetworks() { + static std::vector supportedNetworks = { + Network::NetID::HSCAN, + Network::NetID::HSCAN2, + + Network::NetID::Ethernet, // Connected to port 6 on the switch + + Network::NetID::LIN + }; + return supportedNetworks; + } + + bool supportsComponentVersions() const override { return true; } + +protected: + RADEpsilonXL(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) { + initialize(makeDriver); + } + + virtual void setupEncoder(Encoder& encoder) override { + Device::setupEncoder(encoder); + encoder.supportCANFD = true; + } + + void setupSupportedRXNetworks(std::vector& 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& txNetworks) override { setupSupportedRXNetworks(txNetworks); } + + std::optional getCoreminiStartAddressFlash() const override { + return 14*1024*1024; + } + + std::optional getCoreminiStartAddressSD() const override { + return 0; + } + + bool supportsEraseMemory() const override { + return true; + } +}; + +}; // namespace icsneo + +#endif // __RADEPSILONXL_H_ diff --git a/include/icsneo/platform/posix/devices.h b/include/icsneo/platform/posix/devices.h index 0f35d5a..618b7da 100644 --- a/include/icsneo/platform/posix/devices.h +++ b/include/icsneo/platform/posix/devices.h @@ -18,6 +18,7 @@ #include "icsneo/device/tree/radcomet3/radcomet3.h" #include "icsneo/device/tree/radmoont1s/radmoont1s.h" #include "icsneo/device/tree/radepsilon/radepsilon.h" +#include "icsneo/device/tree/radepsilonxl/radepsilonxl.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgalaxy2/radgalaxy2.h" #include "icsneo/device/tree/radgigastar/radgigastar.h" diff --git a/include/icsneo/platform/windows/devices.h b/include/icsneo/platform/windows/devices.h index 43a80a0..bf6e827 100644 --- a/include/icsneo/platform/windows/devices.h +++ b/include/icsneo/platform/windows/devices.h @@ -18,6 +18,7 @@ #include "icsneo/device/tree/radcomet3/radcomet3.h" #include "icsneo/device/tree/radmoont1s/radmoont1s.h" #include "icsneo/device/tree/radepsilon/radepsilon.h" +#include "icsneo/device/tree/radepsilonxl/radepsilonxl.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgalaxy2/radgalaxy2.h" #include "icsneo/device/tree/radgigastar/radgigastar.h"