diff --git a/HARDWARE.md b/HARDWARE.md index 479f769..b5bd8c4 100644 --- a/HARDWARE.md +++ b/HARDWARE.md @@ -17,6 +17,10 @@ - RADA2B - CAN works - Ethernet works + - RADComet + - CAN works + - CAN FD works + - Ethernet works - Connecting over USB - ValueCAN 4 series diff --git a/device/devicefinder.cpp b/device/devicefinder.cpp index d62a874..97278f1 100644 --- a/device/devicefinder.cpp +++ b/device/devicefinder.cpp @@ -149,6 +149,10 @@ std::vector> DeviceFinder::FindAll() { makeIfSerialMatches(dev, newFoundDevices); #endif + #ifdef __RADCOMET_H_ + makeIfSerialMatches(dev, newFoundDevices); + #endif + #ifdef __RADEPSILON_H_ makeIfSerialMatches(dev, newFoundDevices); #endif @@ -276,6 +280,10 @@ const std::vector& DeviceFinder::GetSupportedDevices() { RADA2B::DEVICE_TYPE, #endif + #ifdef __RADCOMET_H_ + RADCOMET::DEVICE_TYPE, + #endif + #ifdef __RADEPSILON_H_ RADEpsilon::DEVICE_TYPE, #endif diff --git a/include/icsneo/device/devicetype.h b/include/icsneo/device/devicetype.h index 4835a41..ad1a34f 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), + RADComet = (0x00000024), FIRE3_FlexRay = (0x00000025), RED = (0x00000040), ECU = (0x00000080), @@ -134,6 +135,8 @@ public: return "RAD-A2B"; case RADEpsilon: return "RAD-Epsilon"; + case RADComet: + return "RAD-Comet"; case RED: return "neoVI RED"; case ECU: @@ -230,6 +233,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_RADCOMET ((devicetype_t)0x00000024) #define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)0x00000025) #define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040) #define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080) diff --git a/include/icsneo/device/idevicesettings.h b/include/icsneo/device/idevicesettings.h index b9aabd5..7f893da 100644 --- a/include/icsneo/device/idevicesettings.h +++ b/include/icsneo/device/idevicesettings.h @@ -349,6 +349,22 @@ typedef struct ETHERNET_SETTINGS2_t } ETHERNET_SETTINGS2; #define ETHERNET_SETTINGS2_SIZE 16 +typedef struct ETHERNET10T1S_SETTINGS_t +{ + uint8_t max_burst_count; + uint8_t burst_timer; + uint8_t max_num_nodes; + uint8_t local_id; + uint8_t to_timer; + uint8_t flags; + uint8_t local_id_alternate; + uint8_t rsvd[5]; +} ETHERNET10T1S_SETTINGS; +#define ETHERNET10T1S_SETTINGS_SIZE 12 + +#define ETHERNET10T1S_SETTINGS_FLAG_ENABLE_PLCA 0x01 +#define ETHERNET10T1S_SETTINGS_FLAG_TERMINATION 0x02 + #define ETHERNET_SETTINGS10G_FLAG_FULL_DUPLEX 0x01 #define ETHERNET_SETTINGS10G_FLAG_AUTO_NEG 0x02 #define ETHERNET_SETTINGS10G_FLAG_TCPIP_ENABLE 0x04 diff --git a/include/icsneo/device/tree/radcomet/radcomet.h b/include/icsneo/device/tree/radcomet/radcomet.h new file mode 100644 index 0000000..247b3e3 --- /dev/null +++ b/include/icsneo/device/tree/radcomet/radcomet.h @@ -0,0 +1,72 @@ +#ifndef __RADCOMET_H_ +#define __RADCOMET_H_ + +#ifdef __cplusplus + +#include "icsneo/device/device.h" +#include "icsneo/device/devicetype.h" +#include "icsneo/communication/packetizer.h" +#include "icsneo/communication/decoder.h" +#include "icsneo/device/tree/radcomet/radcometsettings.h" + +namespace icsneo { + +class RADCOMET : public Device { +public: + // Serial numbers start with RC + // USB PID is 0x1207, standard driver is FTDI3 + // Ethernet MAC allocation is 0x1D, standard driver is Raw + ICSNEO_FINDABLE_DEVICE(RADCOMET, DeviceType::RADComet, "RC"); + + static const std::vector& GetSupportedNetworks() { + static std::vector supportedNetworks = { + Network::NetID::HSCAN, + Network::NetID::HSCAN2, + + Network::NetID::Ethernet, + + Network::NetID::OP_Ethernet1, + Network::NetID::OP_Ethernet2, + + }; + return supportedNetworks; + } + + bool getEthPhyRegControlSupported() const override { return true; } + +protected: + RADCOMET(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) { + initialize(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& 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); } +}; + +} + +#endif // __cplusplus + +#endif \ No newline at end of file diff --git a/include/icsneo/device/tree/radcomet/radcometsettings.h b/include/icsneo/device/tree/radcomet/radcometsettings.h new file mode 100644 index 0000000..24fe584 --- /dev/null +++ b/include/icsneo/device/tree/radcomet/radcometsettings.h @@ -0,0 +1,99 @@ +#ifndef __RADCOMETSETTINGS_H_ +#define __RADCOMETSETTINGS_H_ + +#include +#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 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; +} radcomet_settings_t; +#pragma pack(pop) + +#ifdef __cplusplus + +#include + +class RADCOMETSettings : public IDeviceSettings { +public: + RADCOMETSettings(std::shared_ptr com) : IDeviceSettings(com, sizeof(radcomet_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; + } + } +}; + +} + +#endif // __cplusplus + +#endif diff --git a/include/icsneo/platform/posix/devices.h b/include/icsneo/platform/posix/devices.h index 954a3a4..5ec6b74 100644 --- a/include/icsneo/platform/posix/devices.h +++ b/include/icsneo/platform/posix/devices.h @@ -12,6 +12,7 @@ #include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviplasma.h" #include "icsneo/device/tree/rada2b/rada2b.h" +#include "icsneo/device/tree/radcomet/radcomet.h" #include "icsneo/device/tree/radepsilon/radepsilon.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.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 3a9c758..eac2653 100644 --- a/include/icsneo/platform/windows/devices.h +++ b/include/icsneo/platform/windows/devices.h @@ -12,6 +12,7 @@ #include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviplasma.h" #include "icsneo/device/tree/rada2b/rada2b.h" +#include "icsneo/device/tree/radcomet/radcomet.h" #include "icsneo/device/tree/radepsilon/radepsilon.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgigastar/radgigastar.h"