Compare commits

...

6 Commits

Author SHA1 Message Date
Kyle Schwarz bc6f5eca9c Device: Conditionally retrieve component versions 2024-04-17 14:36:42 -04:00
Kyle Schwarz 53ba297a44 RADComet: Suppress C4201 for nameless struct/union 2024-04-17 14:35:40 -04:00
Kyle Schwarz d9bf4f423e Device: Fix DFU supported check 2024-04-17 14:25:45 -04:00
Kyle Schwarz ba3bceaee0 RADComet: Update settings 2024-04-17 14:24:56 -04:00
Kyle Schwarz 31d47613e7 RADGigastar: Update settings 2024-04-17 14:24:36 -04:00
Bryant Jones 9c830a91a2 Device: Add RAD-Comet3 support 2024-04-11 21:40:38 +00:00
29 changed files with 323 additions and 15 deletions

View File

@ -21,6 +21,9 @@
- CAN works
- CAN FD works
- Ethernet works
- RADComet3
- CAN works
- Ethernet works
- Connecting over USB
- ValueCAN 4 series
@ -48,3 +51,6 @@
- CAN works
- Ethernet works
- RADMoon3
- RADComet3
- CAN works
- Ethernet works

View File

@ -220,10 +220,13 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) {
// Get component versions *after* the extension "onDeviceOpen" hooks (e.g. device reflashes)
if(supportsComponentVersions()) {
if(auto compVersions = com->getComponentVersionsSync())
componentVersions = std::move(*compVersions);
else
// It's possible the device is on older firmware so don't return false here
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::EventWarning);
}
if(!settings->disabled) {
// Since we will not fail the open if a settings read fails,

View File

@ -177,6 +177,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
makeIfSerialRangeMatches<RADComet2>(dev, newFoundDevices);
#endif
#ifdef __RADCOMET3_H_
makeIfSerialMatches<RADComet3>(dev, newFoundDevices);
#endif
#ifdef __RADEPSILON_H_
makeIfSerialMatches<RADEpsilon>(dev, newFoundDevices);
#endif
@ -316,6 +320,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
RADComet::DEVICE_TYPE,
#endif
#ifdef __RADCOMET3_H_
RADComet3::DEVICE_TYPE,
#endif
#ifdef __RADEPSILON_H_
RADEpsilon::DEVICE_TYPE,
#endif

View File

@ -715,6 +715,8 @@ public:
virtual bool isOnlineSupported() const { return true; }
virtual bool supportsComponentVersions() const { return false; }
protected:
bool online = false;
int messagePollingCallbackID = 0;

View File

@ -50,6 +50,7 @@ public:
RADMoon3 = (0x00000023),
RADComet = (0x00000024),
FIRE3_FlexRay = (0x00000025),
RADComet3 = (0x00000027),
RED = (0x00000040),
ECU = (0x00000080),
IEVB = (0x00000100),
@ -186,6 +187,8 @@ public:
return "neoOBD2 SIM";
case FIRE3_FlexRay:
return "neoVI FIRE3 FlexRay";
case RADComet3:
return "RAD-Comet 3";
case DONT_REUSE0:
case DONT_REUSE1:
case DONT_REUSE2:
@ -239,6 +242,7 @@ private:
#define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023)
#define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024)
#define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)0x00000025)
#define ICSNEO_DEVICETYPE_RADCOMET3 ((devicetype_t)0x00000027)
#define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040)
#define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080)
#define ICSNEO_DEVICETYPE_IEVB ((devicetype_t)0x00000100)

View File

@ -327,6 +327,35 @@ typedef struct SERDESPOC_SETTINGS_t
} SERDESPOC_SETTINGS;
#define SERDESPOC_SETTINGS_SIZE 10
enum
{
SERDESGEN_MOD_ID_NONE = 0,
SERDESGEN_MOD_ID_FPD3_2x2 = 1,
SERDESGEN_MOD_ID_GMSL2_2x2 = 2,
SERDESGEN_MOD_ID_GMSL1_4x4 = 3,
SERDESGEN_MOD_ID_FPD3_TO_GMSL2_2x2 = 4,
// new modules go above this line
SERDESGEN_MOD_ID_UNKNOWN = -1,
};
#define SERDESGEN_SETTINGS_FLAG_TX_PATGEN_ENABLE 0x0001
typedef struct SERDESGEN_SETTINGS_t
{
/*
* bit0: enable pattern generator
*/
uint16_t flags;
uint8_t rsvd1;
uint8_t mod_id; // connected module passed back from device
uint16_t tx_speed; // Mbps per lane, all tx ports
uint16_t rx_speed; // Mbps per lane, all rx ports
// reserved space for the future
// maybe pattern generator settings
uint8_t rsvd2[24];
} SERDESGEN_SETTINGS;
#define SERDESGEN_SETTINGS_SIZE 32
#define ETHERNET_SETTINGS2_FLAG_FULL_DUPLEX 0x01
#define ETHERNET_SETTINGS2_FLAG_AUTO_NEG 0x02
#define ETHERNET_SETTINGS2_FLAG_TCPIP_ENABLE 0x04

View File

@ -26,6 +26,8 @@ public:
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
protected:
EtherBADGE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<EtherBADGESettings>(makeDriver);

View File

@ -87,6 +87,8 @@ public:
};
}
bool supportsComponentVersions() const override { return true; }
protected:
NeoVIFIRE2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIFIRE2Settings, Disk::NeoMemoryDiskDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
@ -99,7 +101,7 @@ protected:
}
}
bool currentDriverSupportsDFU() const override { return com->driver->isEthernet(); }
bool currentDriverSupportsDFU() const override { return !com->driver->isEthernet(); }
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);

View File

@ -50,6 +50,8 @@ public:
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
protected:
NeoVIFIRE3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIFIRE3Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);

View File

@ -52,6 +52,8 @@ public:
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
protected:
NeoVIFIRE3FlexRay(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIFIRE3FlexRaySettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);

View File

@ -35,6 +35,8 @@ public:
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
protected:
NeoVIRED2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIRED2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);

View File

@ -15,6 +15,8 @@ public:
// USB PID is 0x0901, standard driver is FTDI
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIION, DeviceType::ION, 0x0901);
bool supportsComponentVersions() const override { return true; }
private:
NeoVIION(neodevice_t neodevice, const driver_factory_t& makeDriver) : Plasion(neodevice) {
initialize<NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);

View File

@ -10,6 +10,11 @@ namespace icsneo {
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201) // nameless struct/union
#endif
#pragma pack(push, 2)
typedef struct {
// ECU ID used in CAN communications.
@ -32,7 +37,17 @@ typedef struct {
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
uint16_t iso_parity_1;
uint16_t iso_msg_termination_1;
uint64_t network_enables;
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 termination_enables;
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
RAD_REPORTING_SETTINGS reporting;
@ -59,8 +74,14 @@ typedef struct {
} radcomet_settings_t;
#pragma pack(pop)
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#ifdef __cplusplus
static_assert(sizeof(radcomet_settings_t) == 466, "RADComet settings size mismatch");
#include <iostream>
class RADCometSettings : public IDeviceSettings {

View File

@ -0,0 +1,87 @@
#ifndef __RADCOMET3_H_
#define __RADCOMET3_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radcomet3/radcomet3.h"
#include "icsneo/device/tree/radcomet3/radcomet3settings.h"
namespace icsneo {
class RADComet3 : public Device {
public:
// Serial numbers start with C3
// USB PID is 0x1208, standard driver is FTDI3
// Ethernet MAC allocation is 0x20, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(RADComet3, DeviceType::RADComet3, "C3");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::HSCAN2,
Network::NetID::Ethernet,
Network::NetID::OP_Ethernet1,
Network::NetID::OP_Ethernet2,
Network::NetID::OP_Ethernet3,
Network::NetID::OP_Ethernet4,
Network::NetID::OP_Ethernet5,
Network::NetID::OP_Ethernet6,
Network::NetID::OP_Ethernet7,
Network::NetID::LIN,
Network::NetID::ISO9141,
Network::NetID::MDIO1,
Network::NetID::MDIO2,
};
return supportedNetworks;
}
size_t getEthernetActivationLineCount() const override { return 1; }
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADComet3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADComet3Settings>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
packetizer.disableChecksum = true;
packetizer.align16bit = false;
}
void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
encoder.supportEthPhy = true;
}
void setupDecoder(Decoder& decoder) override {
Device::setupDecoder(decoder);
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
}
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); }
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
return 32*1024*1024;
}
};
}
#endif // __cplusplus
#endif

View File

@ -0,0 +1,113 @@
#ifndef __RADCOMET3SETTINGS_H_
#define __RADCOMET3SETTINGS_H_
#include <stdint.h>
#include "icsneo/device/idevicesettings.h"
#ifdef __cplusplus
namespace icsneo {
#endif
#pragma pack(push, 2)
typedef struct {
// ECU ID used in CAN communications.
// TX ID = ECU ID with bit28 cleared,
// RX ID = ECUID with bit28 set,
// ECU ID = 0 implies ECU ID = serial no with bit 27 set
uint32_t ecu_id;
uint16_t perf_en;
struct
{
uint16_t hwComLatencyTestEn : 1;
uint16_t disableUsbCheckOnBoot : 1;
uint16_t reserved : 14;
} flags;
uint16_t network_enabled_on_boot;
CAN_SETTINGS can1;
CANFD_SETTINGS canfd1;
CAN_SETTINGS can2;
CANFD_SETTINGS canfd2;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
uint16_t iso_parity_1;
uint16_t iso_msg_termination_1;
uint64_t network_enables;
uint64_t network_enables_2;
uint64_t termination_enables;
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
RAD_REPORTING_SETTINGS reporting;
int16_t iso15765_separation_time_offset;
uint32_t pwr_man_timeout;
uint16_t pwr_man_enable;
RAD_GPTP_SETTINGS gPTP;
STextAPISettings text_api;
// Ethernet 10/100/1000
ETHERNET_SETTINGS2 ethernet;
// Ethernet General
OP_ETH_GENERAL_SETTINGS opEthGen;
// 100/1000T1
ETHERNET_SETTINGS2 ethT1;
OP_ETH_SETTINGS opEth1;
// 10T1S
ETHERNET_SETTINGS2 ethT1s1;
ETHERNET10T1S_SETTINGS t1s1;
// 10T1S
ETHERNET_SETTINGS2 ethT1s2;
ETHERNET10T1S_SETTINGS t1s2;
// 10T1S
ETHERNET_SETTINGS2 ethT1s3;
ETHERNET10T1S_SETTINGS t1s3;
// 10T1S
ETHERNET_SETTINGS2 ethT1s4;
ETHERNET10T1S_SETTINGS t1s4;
// 10T1S
ETHERNET_SETTINGS2 ethT1s5;
ETHERNET10T1S_SETTINGS t1s5;
// 10T1S
ETHERNET_SETTINGS2 ethT1s6;
ETHERNET10T1S_SETTINGS t1s6;
LIN_SETTINGS lin1;
} radcomet3_settings_t;
#pragma pack(pop)
#ifdef __cplusplus
#include <iostream>
class RADComet3Settings : public IDeviceSettings {
public:
RADComet3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radcomet3_settings_t)) {}
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radcomet3_settings_t>();
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<radcomet3_settings_t>();
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;
}
}
};
}
#endif // __cplusplus
#endif

View File

@ -24,6 +24,8 @@ public:
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
protected:
RADEpsilon(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize(makeDriver);

View File

@ -60,7 +60,8 @@ typedef struct {
struct
{
uint16_t hwComLatencyTestEn : 1;
uint16_t reserved : 15;
uint16_t disableUsbCheckOnBoot : 1;
uint16_t reserved : 14;
} flags;
ETHERNET_SETTINGS2 ethernet1;
ETHERNET_SETTINGS2 ethernet2;
@ -79,12 +80,16 @@ typedef struct {
SERDESCAM_SETTINGS serdescam4;
RAD_REPORTING_SETTINGS reporting;
uint16_t network_enables_4;
SERDESGEN_SETTINGS serdesgen;
RAD_GPTP_SETTINGS gPTP;
uint64_t network_enables_5;
} radgigastar_settings_t;
#pragma pack(pop)
#ifdef __cplusplus
static_assert(sizeof(radgigastar_settings_t) == 634, "RADGigastar settings size mismatch");
static_assert(sizeof(radgigastar_settings_t) == 710, "RADGigastar settings size mismatch");
#include <iostream>

View File

@ -29,6 +29,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; }
bool supportsComponentVersions() const override { return true; }
protected:
RADJupiter(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADJupiterSettings>(makeDriver);

View File

@ -16,6 +16,8 @@ public:
uint8_t getPhyAddrOrPort() const override { return 1; }
bool supportsComponentVersions() const override { return true; }
protected:
RADMoon2ZL(neodevice_t neodevice, const driver_factory_t& makeDriver) : RADMoon2Base(neodevice) {
initialize<RADMoon2Settings>(makeDriver);

View File

@ -27,6 +27,8 @@ public:
bool isOnlineSupported() const override { return false; }
bool supportsComponentVersions() const override { return true; }
protected:
RADMoon3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADMoon3Settings>(makeDriver);

View File

@ -25,6 +25,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; }
bool supportsComponentVersions() const override { return true; }
protected:
RADMoonDuo(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADMoonDuoSettings>(makeDriver);

View File

@ -34,6 +34,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; }
bool supportsComponentVersions() const override { return true; }
protected:
RADPluto(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADPlutoSettings>(makeDriver);

View File

@ -22,6 +22,8 @@ public:
return supportedNetworks;
}
bool supportsComponentVersions() const override { return true; }
private:
ValueCAN3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<ValueCAN3Settings>(makeDriver);

View File

@ -83,7 +83,7 @@ protected:
ethActivationStatus = status->ethernetActivationLineEnabled;
}
bool currentDriverSupportsDFU() const override { return com->driver->isEthernet(); }
bool currentDriverSupportsDFU() const override { return !com->driver->isEthernet(); }
void setupPacketizer(Packetizer& packetizer) override {
ValueCAN4::setupPacketizer(packetizer);

View File

@ -12,6 +12,8 @@ class ValueCAN4 : public Device {
public:
// All ValueCAN 4 devices share a USB PID of 0x1101
bool supportsComponentVersions() const override { return true; }
protected:
using Device::Device;

View File

@ -40,8 +40,6 @@ protected:
// 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 currentDriverSupportsDFU() const override { return com->driver->isEthernet(); }
void setupPacketizer(Packetizer& packetizer) override {
ValueCAN4::setupPacketizer(packetizer);
packetizer.align16bit = !com->driver->isEthernet();

View File

@ -29,6 +29,8 @@ public:
bool isOnlineSupported() const override { return false; }
bool supportsComponentVersions() const override { return true; }
protected:
VividCAN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<VividCANSettings>(makeDriver);

View File

@ -14,6 +14,7 @@
#include "icsneo/device/tree/rada2b/rada2b.h"
#include "icsneo/device/tree/radcomet/radcomet.h"
#include "icsneo/device/tree/radcomet/radcomet2.h"
#include "icsneo/device/tree/radcomet3/radcomet3.h"
#include "icsneo/device/tree/radepsilon/radepsilon.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
#include "icsneo/device/tree/radgigastar/radgigastar.h"

View File

@ -14,6 +14,7 @@
#include "icsneo/device/tree/rada2b/rada2b.h"
#include "icsneo/device/tree/radcomet/radcomet.h"
#include "icsneo/device/tree/radcomet/radcomet2.h"
#include "icsneo/device/tree/radcomet3/radcomet3.h"
#include "icsneo/device/tree/radepsilon/radepsilon.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
#include "icsneo/device/tree/radgigastar/radgigastar.h"