Add Gigalog, Gigastar, Moon 2, Moon Duo, and Supermoon

The USB drivers for these devices are currently stubbed, it will find them
but not connect.

The Ethernet drivers work though, where applicable.
This commit is contained in:
Paul Hollinsky
2020-09-14 11:57:01 -04:00
parent 9dc4b302ef
commit c48efe8e5b
19 changed files with 922 additions and 147 deletions
@@ -0,0 +1,87 @@
#ifndef __RADGIGASTAR_H_
#define __RADGIGASTAR_H_
#ifdef __cplusplus
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/tree/radgigastar/radgigastarsettings.h"
namespace icsneo {
class RADGigastar : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADGigastar;
static constexpr const char* SERIAL_START = "GS";
protected:
RADGigastar(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
}
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
packetizer.disableChecksum = true;
packetizer.align16bit = false;
}
void setupDecoder(Decoder& decoder) override {
Device::setupDecoder(decoder);
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
}
void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
}
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
static std::vector<Network> supportedRxNetworks = {
Network::NetID::HSCAN,
Network::NetID::MSCAN,
Network::NetID::HSCAN2,
Network::NetID::HSCAN3,
Network::NetID::HSCAN4,
Network::NetID::HSCAN5,
Network::NetID::Ethernet,
Network::NetID::Ethernet2,
Network::NetID::OP_Ethernet1,
Network::NetID::OP_Ethernet2,
Network::NetID::LIN,
Network::NetID::FlexRay
};
rxNetworks.insert(rxNetworks.end(), supportedRxNetworks.begin(), supportedRxNetworks.end());
}
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override {
static std::vector<Network> supportedTxNetworks = {
Network::NetID::HSCAN,
Network::NetID::MSCAN,
Network::NetID::HSCAN2,
Network::NetID::HSCAN3,
Network::NetID::HSCAN4,
Network::NetID::HSCAN5,
Network::NetID::Ethernet,
Network::NetID::Ethernet2,
Network::NetID::OP_Ethernet1,
Network::NetID::OP_Ethernet2,
Network::NetID::LIN
// FlexRay is Receive Only
};
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
}
};
}
#endif // __cplusplus
#endif
@@ -0,0 +1,58 @@
#ifndef __RADGIGASTAR_ETH_H_
#define __RADGIGASTAR_ETH_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radgigastar/radgigastar.h"
#include "icsneo/platform/pcap.h"
namespace icsneo {
class RADGigastarETH : public RADGigastar {
public:
static constexpr const uint16_t PRODUCT_ID = 0x000F;
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<RADGigastarETH>(new RADGigastarETH({}));
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->network.getNetID() != Network::NetID::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 RADGigastar
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.push_back(std::shared_ptr<RADGigastarETH>(new RADGigastarETH(std::move(device))));
break;
}
}
return found;
}
private:
RADGigastarETH(neodevice_t neodevice) : RADGigastar(neodevice) {
initialize<PCAP, RADGigastarSettings>();
productId = PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif
@@ -0,0 +1,142 @@
#ifndef __RADGIGASTARSETTINGS_H_
#define __RADGIGASTARSETTINGS_H_
#include <stdint.h>
#include "icsneo/device/idevicesettings.h"
#ifdef __cplusplus
namespace icsneo {
#endif
#pragma pack(push, 2)
typedef struct {
uint32_t ecu_id;
uint16_t perf_en;
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;
uint16_t network_enables;
uint16_t network_enables_2;
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;
STextAPISettings text_api;
uint64_t termination_enables;
DISK_SETTINGS disk;
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
struct
{
uint16_t hwComLatencyTestEn : 1;
uint16_t reserved : 15;
} flags;
ETHERNET_SETTINGS2 ethernet1;
ETHERNET_SETTINGS2 ethernet2;
LIN_SETTINGS lin1;
OP_ETH_GENERAL_SETTINGS opEthGen;
OP_ETH_SETTINGS opEth1;
OP_ETH_SETTINGS opEth2;
SERDESCAM_SETTINGS serdescam1;
SERDESPOC_SETTINGS serdespoc;
LOGGER_SETTINGS logger;
SERDESCAM_SETTINGS serdescam2;
SERDESCAM_SETTINGS serdescam3;
SERDESCAM_SETTINGS serdescam4;
RAD_REPORTING_SETTINGS reporting;
uint16_t network_enables_4;
} radgigastar_settings_t;
#pragma pack(pop)
#ifdef __cplusplus
static_assert(sizeof(radgigastar_settings_t) == 634, "RADGigastar settings size mismatch");
#include <iostream>
class RADGigastarSettings : public IDeviceSettings {
public:
RADGigastarSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgigastar_settings_t)) {}
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radgigastar_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);
default:
return nullptr;
}
}
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
auto cfg = getStructurePointer<radgigastar_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);
default:
return nullptr;
}
}
};
}
#endif // __cplusplus
#endif
@@ -0,0 +1,34 @@
#ifndef __RADGIGASTAR_USB_H_
#define __RADGIGASTAR_USB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radgigastar/radgigastar.h"
#include "icsneo/platform/ftdi3.h"
namespace icsneo {
class RADGigastarUSB : public RADGigastar {
public:
static constexpr const uint16_t PRODUCT_ID = 0x1204;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI3::FindByProduct(PRODUCT_ID))
found.emplace_back(new RADGigastarUSB(neodevice)); // Creation of the shared_ptr
return found;
}
private:
RADGigastarUSB(neodevice_t neodevice) : RADGigastar(neodevice) {
initialize<FTDI3, RADGigastarSettings>();
productId = PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif