From eaa1409af08f4a75e1128e640fceb4b86f7a6c47 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 8 Sep 2020 17:41:47 -0400 Subject: [PATCH] Update/add settings structures for several devices --- include/icsneo/device/idevicesettings.h | 90 ++++++++++ .../device/tree/etherbadge/etherbadge.h | 4 +- .../tree/etherbadge/etherbadgesettings.h | 101 +++++++++++ .../device/tree/neovifire2/neovifire2eth.h | 4 +- .../tree/neovifire2/neovifire2settings.h | 1 + .../icsneo/device/tree/radgalaxy/radgalaxy.h | 11 +- .../device/tree/radgalaxy/radgalaxysettings.h | 168 ++++++++++++++++++ .../device/tree/radstar2/radstar2settings.h | 1 + .../icsneo/device/tree/vividcan/vividcan.h | 3 +- .../device/tree/vividcan/vividcansettings.h | 91 ++++++++++ 10 files changed, 465 insertions(+), 9 deletions(-) create mode 100644 include/icsneo/device/tree/etherbadge/etherbadgesettings.h create mode 100644 include/icsneo/device/tree/radgalaxy/radgalaxysettings.h create mode 100644 include/icsneo/device/tree/vividcan/vividcansettings.h diff --git a/include/icsneo/device/idevicesettings.h b/include/icsneo/device/idevicesettings.h index 5bc21a9..e26aadd 100644 --- a/include/icsneo/device/idevicesettings.h +++ b/include/icsneo/device/idevicesettings.h @@ -154,6 +154,96 @@ typedef struct } TIMESYNC_ICSHARDWARE_SETTINGS; #define TIMESYNC_ICSHARDWARE_SETTINGS_SIZE 4 +typedef struct DISK_SETTINGS_t +{ + uint8_t disk_layout;// RAID0, spanned, etc + uint8_t disk_format;// FAT32 + uint32_t disk_enables;// mask of enabled disks in this layout + uint8_t rsvd[8]; +} DISK_SETTINGS; +#define DISK_SETTINGS_SIZE 14 + +#define ETHERNET_SETTINGS2_FLAG_FULL_DUPLEX 0x01 +#define ETHERNET_SETTINGS2_FLAG_AUTO_NEG 0x02 +#define ETHERNET_SETTINGS2_FLAG_TCPIP_ENABLE 0x04 +#define ETHERNET_SETTINGS2_FLAG_RTSP_ENABLE 0x08 +#define ETHERNET_SETTINGS2_FLAG_DEVICE_HOSTING_ENABLE 0x10 +#define ETHERNET_SETTINGS2_FLAG_COMM_IN_USE 0x80 + +typedef struct ETHERNET_SETTINGS2_t +{ + /* bit0: 0=half duplex, 1=full duplex + * bit1: auto negot + * bit2: enable tcp/ip stack + * bit3: enable rtsp server + * bit4: enable intepid device hosting (go online and log other devices) + */ + uint8_t flags; + uint8_t link_speed;//0=10, 1=100, 2=1000 + uint32_t ip_addr; + uint32_t netmask; + uint32_t gateway; + uint8_t rsvd[2]; +} ETHERNET_SETTINGS2; +#define ETHERNET_SETTINGS2_SIZE 16 + +#define ETHERNET_SETTINGS10G_FLAG_FULL_DUPLEX 0x01 +#define ETHERNET_SETTINGS10G_FLAG_AUTO_NEG 0x02 +#define ETHERNET_SETTINGS10G_FLAG_TCPIP_ENABLE 0x04 +#define ETHERNET_SETTINGS10G_FLAG_RTSP_ENABLE 0x08 +#define ETHERNET_SETTINGS10G_FLAG_DEVICE_HOSTING_ENABLE 0x10 +#define ETHERNET_SETTINGS10G_FLAG_COMM_IN_USE 0x80000000 + +typedef struct ETHERNET10G_SETTINGS_t +{ + /* bit0: 0=half duplex, 1=full duplex + * bit1: auto negot + * bit2: enable tcp/ip stack + * bit3: enable rtsp server + * bit4: enable intepid device hosting (go online and log other devices) + * bit31: comm in use + */ + uint32_t flags; + uint32_t ip_addr; + uint32_t netmask; + uint32_t gateway; + uint8_t link_speed;//0=10, 1=100, 2=1000, 3=2500, 4=5000, 5=10000 + uint8_t rsvd2[7]; +} ETHERNET10G_SETTINGS; +#define ETHERNET10G_SETTINGS_SIZE 24 + +typedef struct LOGGER_SETTINGS_t +{ + /* bit6-0: timeout in seconds + * bit7: 1=disable coremini/logging during extraction for timeout + */ + uint8_t extraction_timeout; + uint8_t rsvd[3]; +} LOGGER_SETTINGS; +#define LOGGER_SETTINGS_SIZE 4 + +#define RAD_REPORTING_SETTINGS_FLAG_TEMP_ENABLE 0x00000001 +#define RAD_REPORTING_SETTINGS_FLAG_MIC2_GPS_ENABLE 0x00000002 // USB port 1 +#define RAD_REPORTING_SETTINGS_FLAG_INT_GPS_ENABLE 0x00000004 +#define RAD_REPORTING_SETTINGS_FLAG_MIC2_GPS_ENABLE2 0x00000008 // USB port 2 +#define RAD_REPORTING_SETTINGS_FLAG_MISC1_DIN 0x00000010 +#define RAD_REPORTING_SETTINGS_FLAG_MISC2_DIN 0x00000020 +#define RAD_REPORTING_SETTINGS_FLAG_MISC1_PWMIN 0x00000040 +#define RAD_REPORTING_SETTINGS_FLAG_MISC2_PWMIN 0x00000080 +#define RAD_REPORTING_SETTINGS_FLAG_AIN1 0x00000100 +#define RAD_REPORTING_SETTINGS_FLAG_AIN2 0x00000200 + +typedef struct RAD_REPORTING_SETTINGS_t +{ + uint32_t flags; + uint16_t temp_interval_ms; + uint16_t gps_interval_ms; + uint16_t serdes_interval_ms; + uint16_t io_interval_ms; + uint8_t rsvd[4]; +} RAD_REPORTING_SETTINGS; +#define RAD_REPORTING_SETTINGS_SIZE 16 + typedef struct _STextAPISettings { uint32_t can1_tx_id; diff --git a/include/icsneo/device/tree/etherbadge/etherbadge.h b/include/icsneo/device/tree/etherbadge/etherbadge.h index 868dded..9e4075e 100644 --- a/include/icsneo/device/tree/etherbadge/etherbadge.h +++ b/include/icsneo/device/tree/etherbadge/etherbadge.h @@ -8,6 +8,7 @@ #include "icsneo/communication/packetizer.h" #include "icsneo/communication/decoder.h" #include "icsneo/platform/stm32.h" +#include "icsneo/device/tree/etherbadge/etherbadgesettings.h" namespace icsneo { @@ -30,6 +31,7 @@ public: static const std::vector& GetSupportedNetworks() { static std::vector supportedNetworks = { Network::NetID::HSCAN, + Network::NetID::HSCAN2, Network::NetID::LIN, @@ -41,7 +43,7 @@ public: EtherBADGE(neodevice_t neodevice) : Device(neodevice) { getWritableNeoDevice().type = DEVICE_TYPE; productId = PRODUCT_ID; - initialize(); + initialize(); } protected: diff --git a/include/icsneo/device/tree/etherbadge/etherbadgesettings.h b/include/icsneo/device/tree/etherbadge/etherbadgesettings.h new file mode 100644 index 0000000..84dbda3 --- /dev/null +++ b/include/icsneo/device/tree/etherbadge/etherbadgesettings.h @@ -0,0 +1,101 @@ +#ifndef __ETHERBADGESETTINGS_H_ +#define __ETHERBADGESETTINGS_H_ + +#include +#include "icsneo/device/idevicesettings.h" + +#ifdef __cplusplus + +namespace icsneo { + +#endif + +#pragma pack(push, 2) +typedef struct { + uint16_t perf_en;//2 + + CAN_SETTINGS can1;//12 + CANFD_SETTINGS canfd1;//10 + CAN_SETTINGS can2;//12 + CANFD_SETTINGS canfd2;//10 + LIN_SETTINGS lin1;//10 + + uint16_t network_enables;//2 + uint16_t network_enables_2;//2 + uint16_t network_enables_3;//2 + uint64_t termination_enables;//8 + + uint32_t pwr_man_timeout;//4 + uint16_t pwr_man_enable;//2 + + uint16_t network_enabled_on_boot;//2 + + /* ISO15765-2 Transport Layer */ + int16_t iso15765_separation_time_offset;//2 + uint16_t iso9141_kwp_enable_reserved;//2 + uint16_t iso_tester_pullup_enable;//2 + uint16_t iso_parity;//2 + uint16_t iso_msg_termination;//2 + ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;//114 + ETHERNET_SETTINGS ethernet;//8 + + uint16_t misc_io_initial_ddr;//2 + uint16_t misc_io_initial_latch;//2 + uint16_t misc_io_report_period;//2 + uint16_t misc_io_on_report_events;//2 + uint16_t misc_io_analog_enable;//2 + uint16_t ain_sample_period;//2 + uint16_t ain_threshold;//2 + + STextAPISettings text_api;//72 + + struct + { + uint32_t disableUsbCheckOnBoot : 1; + uint32_t enableLatencyTest : 1; + uint32_t enablePcEthernetComm : 1; + uint32_t reserved : 29; + } flags;//4 +} etherbadge_settings_t; +#pragma pack(pop) + +#ifdef __cplusplus + +#include + +class EtherBADGESettings : public IDeviceSettings { +public: + EtherBADGESettings(std::shared_ptr com) : IDeviceSettings(com, sizeof(etherbadge_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 \ No newline at end of file diff --git a/include/icsneo/device/tree/neovifire2/neovifire2eth.h b/include/icsneo/device/tree/neovifire2/neovifire2eth.h index 3c77094..57d100c 100644 --- a/include/icsneo/device/tree/neovifire2/neovifire2eth.h +++ b/include/icsneo/device/tree/neovifire2/neovifire2eth.h @@ -52,9 +52,9 @@ public: } protected: - virtual void setupSettings(IDeviceSettings* ssettings) { + void setupSettings(IDeviceSettings& ssettings) override { // TODO Check firmware version, old firmwares will reset Ethernet settings on settings send - ssettings->readonly = true; + ssettings.readonly = true; } }; diff --git a/include/icsneo/device/tree/neovifire2/neovifire2settings.h b/include/icsneo/device/tree/neovifire2/neovifire2settings.h index d245042..fd7271f 100644 --- a/include/icsneo/device/tree/neovifire2/neovifire2settings.h +++ b/include/icsneo/device/tree/neovifire2/neovifire2settings.h @@ -104,6 +104,7 @@ typedef struct { uint16_t digitalIoThresholdTicks; uint16_t digitalIoThresholdEnable; TIMESYNC_ICSHARDWARE_SETTINGS timeSync; + DISK_SETTINGS disk; } neovifire2_settings_t; #pragma pack(pop) diff --git a/include/icsneo/device/tree/radgalaxy/radgalaxy.h b/include/icsneo/device/tree/radgalaxy/radgalaxy.h index c14c46a..8d12b57 100644 --- a/include/icsneo/device/tree/radgalaxy/radgalaxy.h +++ b/include/icsneo/device/tree/radgalaxy/radgalaxy.h @@ -8,6 +8,7 @@ #include "icsneo/platform/pcap.h" #include "icsneo/communication/packetizer.h" #include "icsneo/communication/decoder.h" +#include "icsneo/device/tree/radgalaxy/radgalaxysettings.h" namespace icsneo { @@ -83,7 +84,7 @@ public: } RADGalaxy(neodevice_t neodevice) : Device(neodevice) { - initialize(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = PRODUCT_ID; } @@ -95,23 +96,23 @@ protected: packetizer.align16bit = false; } - virtual void setupEncoder(Encoder& encoder) override { + void setupEncoder(Encoder& encoder) override { Device::setupEncoder(encoder); encoder.supportCANFD = true; } - virtual void setupDecoder(Decoder& decoder) override { + void setupDecoder(Decoder& decoder) override { Device::setupDecoder(decoder); decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns } - virtual void setupSupportedRXNetworks(std::vector& rxNetworks) override { + 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 - virtual void setupSupportedTXNetworks(std::vector& txNetworks) override { setupSupportedRXNetworks(txNetworks); } + void setupSupportedTXNetworks(std::vector& txNetworks) override { setupSupportedRXNetworks(txNetworks); } }; } diff --git a/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h b/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h new file mode 100644 index 0000000..980c079 --- /dev/null +++ b/include/icsneo/device/tree/radgalaxy/radgalaxysettings.h @@ -0,0 +1,168 @@ +#ifndef __RADGALAXYSETTINGS_H_ +#define __RADGALAXYSETTINGS_H_ + +#include +#include "icsneo/device/idevicesettings.h" + +#ifdef __cplusplus + +namespace icsneo { + +#endif + +#pragma pack(push, 2) +typedef struct { + uint16_t perf_en; + + OP_ETH_GENERAL_SETTINGS opEthGen; + OP_ETH_SETTINGS opEth1; + OP_ETH_SETTINGS opEth2; + OP_ETH_SETTINGS opEth3; + OP_ETH_SETTINGS opEth4; + OP_ETH_SETTINGS opEth5; + OP_ETH_SETTINGS opEth6; + OP_ETH_SETTINGS opEth7; + OP_ETH_SETTINGS opEth8; + OP_ETH_SETTINGS opEth9; + OP_ETH_SETTINGS opEth10; + OP_ETH_SETTINGS opEth11; + OP_ETH_SETTINGS opEth12; + + 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; + + /* Native CAN are either LS1/LS2 or SW1/SW2 */ + SWCAN_SETTINGS swcan1; + uint16_t network_enables; + SWCAN_SETTINGS swcan2; + uint16_t network_enables_2; + + LIN_SETTINGS lin1; + uint16_t misc_io_initial_ddr; + uint16_t misc_io_initial_latch; + uint16_t misc_io_report_period; + uint16_t misc_io_on_report_events; + uint16_t misc_io_analog_enable; + uint16_t ain_sample_period; + uint16_t ain_threshold; + + uint32_t pwr_man_timeout; + uint16_t pwr_man_enable; + + uint16_t network_enabled_on_boot; + + uint16_t iso15765_separation_time_offset; + + uint16_t iso_9141_kwp_enable_reserved; + ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1; + uint16_t iso_parity_1; + + uint16_t iso_msg_termination_1; + + uint16_t idle_wakeup_network_enables_1; + uint16_t idle_wakeup_network_enables_2; + + uint16_t network_enables_3; + uint16_t idle_wakeup_network_enables_3; + + uint16_t can_switch_mode; + STextAPISettings text_api; + TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings; + uint16_t hwComLatencyTestEn; + RAD_REPORTING_SETTINGS reporting; + DISK_SETTINGS disk; + LOGGER_SETTINGS logger; +} radgalaxy_settings_t; +#pragma pack(pop) + +#ifdef __cplusplus + +#include + +class RADGalaxySettings : public IDeviceSettings { +public: + RADGalaxySettings(std::shared_ptr com) : IDeviceSettings(com, sizeof(radgalaxy_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::MSCAN: + return &(cfg->can2); + case Network::NetID::HSCAN2: + return &(cfg->can3); + case Network::NetID::HSCAN3: + return &(cfg->can4); + case Network::NetID::HSCAN4: + return &(cfg->can5); + case Network::NetID::HSCAN5: + return &(cfg->can6); + case Network::NetID::HSCAN6: + return &(cfg->can7); + case Network::NetID::HSCAN7: + return &(cfg->can8); + 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::MSCAN: + return &(cfg->canfd2); + case Network::NetID::HSCAN2: + return &(cfg->canfd3); + case Network::NetID::HSCAN3: + return &(cfg->canfd4); + case Network::NetID::HSCAN4: + return &(cfg->canfd5); + case Network::NetID::HSCAN5: + return &(cfg->canfd6); + case Network::NetID::HSCAN6: + return &(cfg->canfd7); + case Network::NetID::HSCAN7: + return &(cfg->canfd8); + default: + return nullptr; + } + } + const SWCAN_SETTINGS* getSWCANSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::SWCAN: + return &(cfg->swcan1); + case Network::NetID::SWCAN2: + return &(cfg->swcan2); + default: + return nullptr; + } + } +}; + +} + +#endif // __cplusplus + +#endif \ No newline at end of file diff --git a/include/icsneo/device/tree/radstar2/radstar2settings.h b/include/icsneo/device/tree/radstar2/radstar2settings.h index 3412a6b..bc3379a 100644 --- a/include/icsneo/device/tree/radstar2/radstar2settings.h +++ b/include/icsneo/device/tree/radstar2/radstar2settings.h @@ -59,6 +59,7 @@ typedef struct { uint16_t pc_com_mode; TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings; uint16_t hwComLatencyTestEn; + RAD_REPORTING_SETTINGS reporting; } radstar2_settings_t; #pragma pack(pop) diff --git a/include/icsneo/device/tree/vividcan/vividcan.h b/include/icsneo/device/tree/vividcan/vividcan.h index 4966af5..147c5eb 100644 --- a/include/icsneo/device/tree/vividcan/vividcan.h +++ b/include/icsneo/device/tree/vividcan/vividcan.h @@ -6,6 +6,7 @@ #include "icsneo/device/device.h" #include "icsneo/device/devicetype.h" #include "icsneo/platform/stm32.h" +#include "icsneo/device/tree/vividcan/vividcansettings.h" namespace icsneo { @@ -36,7 +37,7 @@ public: private: VividCAN(neodevice_t neodevice) : Device(neodevice) { - initialize(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = PRODUCT_ID; } diff --git a/include/icsneo/device/tree/vividcan/vividcansettings.h b/include/icsneo/device/tree/vividcan/vividcansettings.h new file mode 100644 index 0000000..375fd81 --- /dev/null +++ b/include/icsneo/device/tree/vividcan/vividcansettings.h @@ -0,0 +1,91 @@ +#ifndef __VIVIDCANSETTINGS_H_ +#define __VIVIDCANSETTINGS_H_ + +#include +#include "icsneo/device/idevicesettings.h" + +#ifdef __cplusplus + +namespace icsneo { + +#endif + +#pragma pack(push, 2) +typedef struct { + uint32_t ecu_id; + + CAN_SETTINGS can1;// 12 bytes + SWCAN_SETTINGS swcan1;// 14 bytes + CAN_SETTINGS lsftcan1;// 12 bytes + + uint16_t network_enables; + uint16_t network_enabled_on_boot; + + uint16_t iso15765_separation_time_offset; + + uint16_t perf_en; + + uint32_t pwr_man_timeout; + uint16_t pwr_man_enable; + + uint16_t can_switch_mode; + uint16_t termination_enables; + + struct + { + uint32_t disableUsbCheckOnBoot : 1; + uint32_t enableLatencyTest : 1; + uint32_t reserved : 30; + } flags; +} vividcan_settings_t; +#pragma pack(pop) + +#ifdef __cplusplus + +#include + +class VividCANSettings : public IDeviceSettings { +public: + VividCANSettings(std::shared_ptr com) : IDeviceSettings(com, sizeof(vividcan_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::LSFTCAN: + return &(cfg->lsftcan1); + default: + return nullptr; + } + } + const CAN_SETTINGS* getLSFTCANSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::LSFTCAN: + return &(cfg->lsftcan1); + default: + return nullptr; + } + } + const SWCAN_SETTINGS* getSWCANSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::SWCAN: + return &(cfg->swcan1); + default: + return nullptr; + } + } +}; + +} + +#endif // __cplusplus + +#endif \ No newline at end of file