Support the neoVI RED 2

pull/35/head
Paul Hollinsky 2021-05-27 22:47:36 -04:00
parent d4f6c12394
commit b340d167dc
6 changed files with 283 additions and 0 deletions

View File

@ -19,6 +19,10 @@ static std::vector<DeviceType> supportedDevices = {
NeoOBD2SIM::DEVICE_TYPE, NeoOBD2SIM::DEVICE_TYPE,
#endif #endif
#ifdef __NEOVIRED2_H_
NeoVIRED2::DEVICE_TYPE,
#endif
#ifdef __NEOVIFIRE_H_ #ifdef __NEOVIFIRE_H_
NeoVIFIRE::DEVICE_TYPE, NeoVIFIRE::DEVICE_TYPE,
#endif #endif
@ -153,6 +157,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
findResults.push_back(NeoVIFIRE2USB::Find()); findResults.push_back(NeoVIFIRE2USB::Find());
#endif #endif
#ifdef __NEOVIRED2_H_
findResults.push_back(NeoVIRED2::Find(pcapDevices));
#endif
#ifdef __NEOVIION_H_ #ifdef __NEOVIION_H_
findResults.push_back(NeoVIION::Find()); findResults.push_back(NeoVIION::Find());
#endif #endif

View File

@ -42,6 +42,7 @@ public:
RADJupiter = (0x00000011), RADJupiter = (0x00000011),
VCAN4_IND = (0x00000012), VCAN4_IND = (0x00000012),
RADGigastar = (0x00000013), RADGigastar = (0x00000013),
RED2 = (0x00000014),
EtherBADGE = (0x00000016), EtherBADGE = (0x00000016),
RED = (0x00000040), RED = (0x00000040),
ECU = (0x00000080), ECU = (0x00000080),
@ -119,6 +120,8 @@ public:
return "ValueCAN 4 Industrial"; return "ValueCAN 4 Industrial";
case RADGigastar: case RADGigastar:
return "RAD-Gigastar"; return "RAD-Gigastar";
case RED2:
return "neoVI RED 2";
case EtherBADGE: case EtherBADGE:
return "EtherBADGE"; return "EtherBADGE";
case RED: case RED:
@ -210,6 +213,7 @@ private:
#define ICSNEO_DEVICETYPE_RADJUPITER ((devicetype_t)0x00000011) #define ICSNEO_DEVICETYPE_RADJUPITER ((devicetype_t)0x00000011)
#define ICSNEO_DEVICETYPE_VCAN4_IND ((devicetype_t)0x00000012) #define ICSNEO_DEVICETYPE_VCAN4_IND ((devicetype_t)0x00000012)
#define ICSNEO_DEVICETYPE_RADGIGASTAR ((devicetype_t)0x00000013) #define ICSNEO_DEVICETYPE_RADGIGASTAR ((devicetype_t)0x00000013)
#define ICSNEO_DEVICETYPE_RED2 ((devicetype_t)0x00000014)
#define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) #define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016)
#define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040) #define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040)
#define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080) #define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080)

View File

@ -0,0 +1,91 @@
#ifndef __NEOVIRED2_H_
#define __NEOVIRED2_H_
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/pcap.h"
#include "icsneo/device/tree/neovired2/neovired2settings.h"
namespace icsneo {
class NeoVIRED2 : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RED2;
static constexpr const char* SERIAL_START = "D2";
static constexpr const uint16_t PRODUCT_ID = 0x000E;
static std::vector<std::shared_ptr<Device>> Find(const std::vector<PCAP::PCAPFoundDevice>& pcapDevices) {
std::vector<std::shared_ptr<Device>> found;
for(auto& foundDev : pcapDevices) {
auto fakedev = std::shared_ptr<NeoVIRED2>(new NeoVIRED2({}));
for (auto& payload : foundDev.discoveryPackets)
fakedev->com->packetizer->input(payload);
for (auto& packet : fakedev->com->packetizer->output()) {
std::shared_ptr<Message> msg;
if (!fakedev->com->decoder->decode(msg, packet))
continue; // We failed to decode this packet
if(!msg || msg->type != Message::Type::Main51)
continue; // Not a message we care about
auto sn = std::dynamic_pointer_cast<SerialNumberMessage>(msg);
if(!sn)
continue; // Not a serial number message
if(sn->deviceSerial.length() < 2)
continue;
if(sn->deviceSerial.substr(0, 2) != SERIAL_START)
continue; // Not a RED 2
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.emplace_back(new NeoVIRED2(std::move(device)));
break;
}
}
return found;
}
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::MSCAN,
Network::NetID::HSCAN2,
Network::NetID::HSCAN3,
Network::NetID::HSCAN4,
Network::NetID::HSCAN5,
Network::NetID::HSCAN6,
Network::NetID::HSCAN7,
Network::NetID::Ethernet,
Network::NetID::LIN,
Network::NetID::LIN2
};
return supportedNetworks;
}
protected:
NeoVIRED2(neodevice_t neodevice) : Device(neodevice) {
initialize<PCAP, NeoVIRED2Settings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
}
virtual 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
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
#endif

View File

@ -0,0 +1,178 @@
#ifndef __NEOVIRED2SETTINGS_H_
#define __NEOVIRED2SETTINGS_H_
#include <stdint.h>
#include "icsneo/device/idevicesettings.h"
#ifdef __cplusplus
namespace icsneo {
#endif
#pragma pack(push, 2)
typedef struct {
uint16_t perf_en;
uint16_t network_enabled_on_boot;
uint16_t misc_io_on_report_events;
uint16_t pwr_man_enable;
int16_t iso15765_separation_time_offset;
uint16_t slaveVnetA;
uint32_t reserved;
uint64_t termination_enables;
union {
uint64_t word;
struct
{
uint16_t network_enables;
uint16_t network_enables_2;
uint16_t network_enables_3;
};
} network_enables;
uint32_t pwr_man_timeout;
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;
LIN_SETTINGS lin1;
LIN_SETTINGS lin2;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
uint16_t iso_parity_1;
uint16_t iso_msg_termination_1;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
uint16_t iso_parity_2;
uint16_t iso_msg_termination_2;
ETHERNET_SETTINGS ethernet;
TIMESYNC_ICSHARDWARE_SETTINGS timeSync;
STextAPISettings text_api;
struct
{
uint32_t disableUsbCheckOnBoot : 1;
uint32_t enableLatencyTest : 1;
uint32_t busMessagesToAndroid : 1;
uint32_t enablePcEthernetComm : 1;
uint32_t enableDefaultLogger : 1;
uint32_t enableDefaultUpload : 1;
uint32_t reserved : 26;
} flags;
DISK_SETTINGS disk;
uint16_t misc_io_report_period;
uint16_t ain_threshold;
uint16_t misc_io_analog_enable;
uint16_t digitalIoThresholdTicks;
uint16_t digitalIoThresholdEnable;
uint16_t misc_io_initial_ddr;
uint16_t misc_io_initial_latch;
ETHERNET_SETTINGS2 ethernet2;
} neovired2_settings_t;
typedef struct {
uint8_t backupPowerGood;
uint8_t backupPowerEnabled;
uint8_t usbHostPowerEnabled;
uint8_t ethernetActivationLineEnabled;
EthernetNetworkStatus ethernetStatus;
} neovired2_status_t;
#pragma pack(pop)
#ifdef __cplusplus
#include <iostream>
class NeoVIRED2Settings : public IDeviceSettings {
public:
NeoVIRED2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovired2_settings_t)) {}
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
auto cfg = getStructurePointer<neovired2_settings_t>();
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<neovired2_settings_t>();
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;
}
}
virtual std::vector<TerminationGroup> getTerminationGroups() const override {
return {
{
Network(Network::NetID::HSCAN),
Network(Network::NetID::HSCAN3),
Network(Network::NetID::HSCAN5),
Network(Network::NetID::HSCAN7)
},
{
Network(Network::NetID::MSCAN),
Network(Network::NetID::HSCAN2),
Network(Network::NetID::HSCAN4),
Network(Network::NetID::HSCAN6)
}
};
}
protected:
ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override {
auto cfg = getStructurePointer<neovired2_settings_t>();
if(cfg == nullptr)
return nullptr;
return &cfg->termination_enables;
}
};
}
#endif // __cplusplus
#endif

View File

@ -7,6 +7,7 @@
#include "icsneo/device/tree/neovifire/neovifire.h" #include "icsneo/device/tree/neovifire/neovifire.h"
#include "icsneo/device/tree/neovifire2/neovifire2eth.h" #include "icsneo/device/tree/neovifire2/neovifire2eth.h"
#include "icsneo/device/tree/neovifire2/neovifire2usb.h" #include "icsneo/device/tree/neovifire2/neovifire2usb.h"
#include "icsneo/device/tree/neovired2/neovired2.h"
#include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviion.h"
#include "icsneo/device/tree/plasion/neoviplasma.h" #include "icsneo/device/tree/plasion/neoviplasma.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h"

View File

@ -7,6 +7,7 @@
#include "icsneo/device/tree/neovifire/neovifire.h" #include "icsneo/device/tree/neovifire/neovifire.h"
#include "icsneo/device/tree/neovifire2/neovifire2eth.h" #include "icsneo/device/tree/neovifire2/neovifire2eth.h"
#include "icsneo/device/tree/neovifire2/neovifire2usb.h" #include "icsneo/device/tree/neovifire2/neovifire2usb.h"
#include "icsneo/device/tree/neovired2/neovired2.h"
#include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviion.h"
#include "icsneo/device/tree/plasion/neoviplasma.h" #include "icsneo/device/tree/plasion/neoviplasma.h"
#include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h"