From a2fecb762100225fe7bd1eba0a03eec670346182 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Thu, 20 Feb 2020 14:43:10 -0500 Subject: [PATCH] Support for EtherBADGE --- device/devicefinder.cpp | 8 +++ include/icsneo/device/devicetype.h | 4 ++ .../device/tree/etherbadge/etherbadge.h | 62 +++++++++++++++++++ include/icsneo/platform/posix/devices.h | 1 + include/icsneo/platform/windows/devices.h | 1 + 5 files changed, 76 insertions(+) create mode 100644 include/icsneo/device/tree/etherbadge/etherbadge.h diff --git a/device/devicefinder.cpp b/device/devicefinder.cpp index 65d2ac8..46c39d6 100644 --- a/device/devicefinder.cpp +++ b/device/devicefinder.cpp @@ -6,6 +6,10 @@ using namespace icsneo; static bool supportedDevicesCached = false; static std::vector supportedDevices = { + #ifdef __ETHERBADGE_H_ + EtherBADGE::DEVICE_TYPE, + #endif + #ifdef __NEOOBD2PRO_H_ NeoOBD2PRO::DEVICE_TYPE, #endif @@ -83,6 +87,10 @@ static std::vector supportedDevices = { std::vector> DeviceFinder::FindAll() { std::vector> foundDevices; std::vector>> findResults; + + #ifdef __ETHERBADGE_H_ + findResults.push_back(EtherBADGE::Find()); + #endif #ifdef __NEOOBD2PRO_H_ findResults.push_back(NeoOBD2PRO::Find()); diff --git a/include/icsneo/device/devicetype.h b/include/icsneo/device/devicetype.h index dd1ff36..dbd6f41 100644 --- a/include/icsneo/device/devicetype.h +++ b/include/icsneo/device/devicetype.h @@ -36,6 +36,7 @@ public: VCAN4_2EL = (0x0000000a), RADIO_CANHUB = (0x0000000b), VCAN3 = (0x00000010), + EtherBADGE = (0x00000016), RED = (0x00000040), ECU = (0x00000080), IEVB = (0x00000100), @@ -92,6 +93,8 @@ public: return "RADIO_CANHUB"; case VCAN3: return "ValueCAN 3"; + case EtherBADGE: + return "EtherBADGE"; case RED: return "neoVI RED"; case ECU: @@ -179,6 +182,7 @@ private: #define ICSNEO_DEVICETYPE_VCAN4_2EL ((devicetype_t)0x0000000a) #define ICSNEO_DEVICETYPE_RADIO_CANHUB ((devicetype_t)0x0000000b) #define ICSNEO_DEVICETYPE_VCAN3 ((devicetype_t)0x00000010) +#define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) #define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040) #define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080) #define ICSNEO_DEVICETYPE_IEVB ((devicetype_t)0x00000100) diff --git a/include/icsneo/device/tree/etherbadge/etherbadge.h b/include/icsneo/device/tree/etherbadge/etherbadge.h new file mode 100644 index 0000000..30ad56f --- /dev/null +++ b/include/icsneo/device/tree/etherbadge/etherbadge.h @@ -0,0 +1,62 @@ +#ifndef __ETHERBADGE_H_ +#define __ETHERBADGE_H_ + +#include "icsneo/device/device.h" +#include "icsneo/device/devicetype.h" +#include "icsneo/communication/packetizer.h" +#include "icsneo/communication/decoder.h" +#include "icsneo/platform/stm32.h" + +namespace icsneo { + +class EtherBADGE : public Device { +public: + // Serial numbers start with EB + static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::EtherBADGE; + static constexpr const uint16_t PRODUCT_ID = 0x1107; + static constexpr const char* SERIAL_START = "EB"; + + static std::vector> Find() { + std::vector> found; + + for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) + found.emplace_back(new EtherBADGE(neodevice)); + + return found; + } + + static const std::vector& GetSupportedNetworks() { + static std::vector supportedNetworks = { + Network::NetID::HSCAN, + + Network::NetID::LIN, + + Network::NetID::OP_Ethernet1 + }; + return supportedNetworks; + } + + EtherBADGE(neodevice_t neodevice) : Device(neodevice) { + getWritableNeoDevice().type = DEVICE_TYPE; + productId = PRODUCT_ID; + initialize(); + } + +protected: + virtual void setupEncoder(Encoder& encoder) override { + Device::setupEncoder(encoder); + encoder.supportCANFD = true; + } + + virtual 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); } +}; + +} + +#endif \ No newline at end of file diff --git a/include/icsneo/platform/posix/devices.h b/include/icsneo/platform/posix/devices.h index b8ca109..636d4eb 100644 --- a/include/icsneo/platform/posix/devices.h +++ b/include/icsneo/platform/posix/devices.h @@ -1,6 +1,7 @@ #ifndef __DEVICES_POSIX_H_ #define __DEVICES_POSIX_H_ +#include "icsneo/device/tree/etherbadge/etherbadge.h" #include "icsneo/device/tree/neoobd2pro/neoobd2pro.h" #include "icsneo/device/tree/neoobd2sim/neoobd2sim.h" #include "icsneo/device/tree/neovifire/neovifire.h" diff --git a/include/icsneo/platform/windows/devices.h b/include/icsneo/platform/windows/devices.h index 9f6f6ed..1f47641 100644 --- a/include/icsneo/platform/windows/devices.h +++ b/include/icsneo/platform/windows/devices.h @@ -1,6 +1,7 @@ #ifndef __DEVICES_WINDOWS_H_ #define __DEVICES_WINDOWS_H_ +#include "icsneo/device/tree/etherbadge/etherbadge.h" #include "icsneo/device/tree/neoobd2pro/neoobd2pro.h" #include "icsneo/device/tree/neoobd2sim/neoobd2sim.h" #include "icsneo/device/tree/neovifire/neovifire.h"