Drivers: Decouple from devices

This allows us to better implement alternative drivers
for devices, such as for device sharing servers or
talking to CoreMini processors within the same device.
This commit is contained in:
Paul Hollinsky
2022-03-27 14:30:31 -04:00
parent 0ff12300f3
commit 781fc2c034
66 changed files with 780 additions and 1566 deletions
+28 -14
View File
@@ -7,6 +7,7 @@
#include <memory>
#include <utility>
#include <cstring>
#include <cstdint>
#include <atomic>
#include <type_traits>
#include "icsneo/api/eventmanager.h"
@@ -16,6 +17,7 @@
#include "icsneo/device/nullsettings.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/deviceversion.h"
#include "icsneo/device/founddevice.h"
#include "icsneo/disk/diskreaddriver.h"
#include "icsneo/disk/diskwritedriver.h"
#include "icsneo/disk/nulldiskdriver.h"
@@ -32,6 +34,20 @@
#include "icsneo/platform/optional.h"
#include "icsneo/platform/nodiscard.h"
#define ICSNEO_FINDABLE_DEVICE_BASE(className, type) \
static constexpr DeviceType::Enum DEVICE_TYPE = type; \
className(const FoundDevice& dev) : className(neodevice_t(dev, DEVICE_TYPE), dev.makeDriver) {}
// Devices which are discernable by the first two characters of their serial
#define ICSNEO_FINDABLE_DEVICE(className, type, serialStart) \
static constexpr const char* SERIAL_START = serialStart; \
ICSNEO_FINDABLE_DEVICE_BASE(className, type)
// Devices which are discernable by their USB PID
#define ICSNEO_FINDABLE_DEVICE_BY_PID(className, type, pid) \
static constexpr const uint16_t PRODUCT_ID = pid; \
ICSNEO_FINDABLE_DEVICE_BASE(className, type)
namespace icsneo {
class DeviceExtension;
@@ -46,7 +62,6 @@ public:
uint16_t getTimestampResolution() const;
DeviceType getType() const { return DeviceType(data.type); }
uint16_t getProductId() const { return productId; }
std::string getSerial() const { return data.serial; }
uint32_t getSerialNumber() const { return Device::SerialStringToNum(getSerial()); }
const neodevice_t& getNeoDevice() const { return data; }
@@ -308,7 +323,6 @@ public:
std::unique_ptr<IDeviceSettings> settings;
protected:
uint16_t productId = 0;
bool online = false;
int messagePollingCallbackID = 0;
int internalHandlerCallbackID = 0;
@@ -323,21 +337,23 @@ protected:
std::array<optional<double>, 2> miscAnalog;
// START Initialization Functions
Device(neodevice_t neodevice = { 0 }) {
data = neodevice;
Device(neodevice_t neodevice) : data(neodevice) {
data.device = this;
}
template<typename Driver, typename Settings = NullSettings, typename DiskRead = Disk::NullDriver, typename DiskWrite = Disk::NullDriver>
void initialize() {
template<typename Settings = NullSettings, typename DiskRead = Disk::NullDriver, typename DiskWrite = Disk::NullDriver>
void initialize(const driver_factory_t& makeDriver) {
report = makeEventHandler();
auto driver = makeDriver<Driver>();
setupDriver(*driver);
auto encoder = makeEncoder();
setupEncoder(*encoder);
auto decoder = makeDecoder();
setupDecoder(*decoder);
com = makeCommunication(std::move(driver), std::bind(&Device::makeConfiguredPacketizer, this), std::move(encoder), std::move(decoder));
com = makeCommunication(
makeDriver(report, getWritableNeoDevice()),
std::bind(&Device::makeConfiguredPacketizer, this),
std::move(encoder),
std::move(decoder)
);
setupCommunication(*com);
settings = makeSettings<Settings>(com);
setupSettings(*settings);
@@ -354,10 +370,6 @@ protected:
};
}
template<typename Driver>
std::unique_ptr<Driver> makeDriver() { return std::unique_ptr<Driver>(new Driver(report, getWritableNeoDevice())); }
virtual void setupDriver(Driver&) {}
virtual std::unique_ptr<Packetizer> makePacketizer() { return std::unique_ptr<Packetizer>(new Packetizer(report)); }
virtual void setupPacketizer(Packetizer&) {}
std::unique_ptr<Packetizer> makeConfiguredPacketizer() {
@@ -377,7 +389,9 @@ protected:
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer,
std::unique_ptr<Encoder> e,
std::unique_ptr<Decoder> d) { return std::make_shared<Communication>(report, std::move(t), makeConfiguredPacketizer, std::move(e), std::move(d)); }
virtual void setupCommunication(Communication&) {}
virtual void setupCommunication(Communication& communication) {
communication.packetizer = communication.makeConfiguredPacketizer();
}
template<typename Settings>
std::unique_ptr<IDeviceSettings> makeSettings(std::shared_ptr<Communication> com) {
+21
View File
@@ -0,0 +1,21 @@
#ifndef __FOUNDDEVICE_H_
#define __FOUNDDEVICE_H_
#include "icsneo/communication/driver.h"
#include "icsneo/device/neodevice.h"
namespace icsneo {
typedef std::function< std::unique_ptr<Driver>(device_eventhandler_t err, neodevice_t& forDevice) > driver_factory_t;
class FoundDevice {
public:
neodevice_handle_t handle = 0;
char serial[7] = {};
uint16_t productId = 0;
driver_factory_t makeDriver;
};
} // namespace icsneo
#endif // __FOUNDDEVICE_H_
+7
View File
@@ -9,6 +9,7 @@
namespace icsneo {
class Device;
class FoundDevice;
}
typedef icsneo::Device* devicehandle_t;
@@ -20,7 +21,13 @@ typedef int32_t neodevice_handle_t;
#pragma pack(push, 1)
#ifdef __cplusplus
typedef struct neodevice_t {
neodevice_t();
neodevice_t(const icsneo::FoundDevice& found, devicetype_t inType);
#else
typedef struct {
#endif
devicehandle_t device; // Pointer back to the C++ device object
neodevice_handle_t handle; // Handle for use by the underlying driver
devicetype_t type;
@@ -7,7 +7,6 @@
#include "icsneo/device/devicetype.h"
#include "icsneo/communication/packetizer.h"
#include "icsneo/communication/decoder.h"
#include "icsneo/platform/cdcacm.h"
#include "icsneo/device/tree/etherbadge/etherbadgesettings.h"
namespace icsneo {
@@ -15,49 +14,35 @@ 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<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new EtherBADGE(neodevice));
return found;
}
// USB PID is 0x1107, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(EtherBADGE, DeviceType::EtherBADGE, "EB");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> 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<CDCACM, EtherBADGESettings>();
protected:
EtherBADGE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<EtherBADGESettings>(makeDriver);
}
protected:
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool requiresVehiclePower() const override { return false; }
};
@@ -5,23 +5,14 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/cdcacm.h"
namespace icsneo {
class NeoOBD2PRO : public Device {
public:
// Serial numbers are NP****
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::OBD2_PRO;
static constexpr const uint16_t PRODUCT_ID = 0x1103;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new NeoOBD2PRO(neodevice));
return found;
}
// Serial numbers start with NP
// USB PID is 0x1103, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(NeoOBD2PRO, DeviceType::OBD2_PRO, "NP");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -32,19 +23,17 @@ public:
}
private:
NeoOBD2PRO(neodevice_t neodevice) : Device(neodevice) {
initialize<CDCACM>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
NeoOBD2PRO(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize(makeDriver);
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool requiresVehiclePower() const override { return false; }
};
@@ -5,23 +5,14 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/cdcacm.h"
namespace icsneo {
class NeoOBD2SIM : public Device {
public:
// Serial numbers are OS****
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::OBD2_SIM;
static constexpr const uint16_t PRODUCT_ID = 0x1100;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new NeoOBD2SIM(neodevice));
return found;
}
// Serial numbers start with OS
// USB PID is 0x1100, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(NeoOBD2SIM, DeviceType::OBD2_SIM, "OS");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -32,19 +23,17 @@ public:
}
private:
NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) {
initialize<CDCACM>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
NeoOBD2SIM(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize(makeDriver);
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool requiresVehiclePower() const override { return false; }
};
@@ -5,23 +5,14 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/ftdi.h"
#include "icsneo/device/tree/neovifire/neovifiresettings.h"
namespace icsneo {
class NeoVIFIRE : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE;
static constexpr const uint16_t PRODUCT_ID = 0x0701;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.emplace_back(new NeoVIFIRE(neodevice)); // Creation of the shared_ptr
return found;
}
// USB PID is 0x0701, standard driver is FTDI
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIFIRE, DeviceType::FIRE, 0x0701);
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -67,19 +58,17 @@ public:
}
private:
NeoVIFIRE(neodevice_t neodevice) : Device(neodevice) {
initialize<FTDI, NeoVIFIRESettings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
NeoVIFIRE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIFIRESettings>(makeDriver);
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
@@ -5,15 +5,16 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/ftdi.h"
#include "icsneo/device/tree/neovifire2/neovifire2settings.h"
namespace icsneo {
class NeoVIFIRE2 : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE2;
static constexpr const char* SERIAL_START = "CY";
// Serial numbers start with CY
// USB PID is 0x1000, standard driver is FTDI
// Ethernet MAC allocation is 0x04, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(NeoVIFIRE2, DeviceType::FIRE2, "CY");
enum class SKU {
Standard,
@@ -87,8 +88,22 @@ public:
}
protected:
NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
NeoVIFIRE2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIFIRE2Settings>(makeDriver);
}
void setupSettings(IDeviceSettings& ssettings) override {
if(com->driver->isEthernet()) {
// TODO Check firmware version, old firmwares will reset Ethernet settings on settings send
ssettings.readonly = true;
}
}
bool currentDriverSupportsDFU() const override { return com->driver->isEthernet(); }
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
packetizer.align16bit = !com->driver->isEthernet();
}
virtual void setupEncoder(Encoder& encoder) override {
@@ -96,13 +111,13 @@ protected:
encoder.supportCANFD = true;
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
if(message->data.size() < sizeof(neovifire2_status_t))
@@ -1,71 +0,0 @@
#ifndef __NEOVIFIRE2ETH_H_
#define __NEOVIFIRE2ETH_H_
#ifdef __cplusplus
#include "icsneo/device/tree/neovifire2/neovifire2.h"
#include "icsneo/platform/pcap.h"
#include <memory>
namespace icsneo {
class NeoVIFIRE2ETH : public NeoVIFIRE2 {
public:
static constexpr const uint16_t PRODUCT_ID = 0x0004;
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<NeoVIFIRE2ETH>(new NeoVIFIRE2ETH({}));
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 FIRE 2
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.push_back(std::make_shared<NeoVIFIRE2ETH>(std::move(device)));
break;
}
}
return found;
}
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
initialize<PCAP, NeoVIFIRE2Settings>();
productId = PRODUCT_ID;
}
bool currentDriverSupportsDFU() const override { return false; }
protected:
void setupSettings(IDeviceSettings& ssettings) override {
// TODO Check firmware version, old firmwares will reset Ethernet settings on settings send
ssettings.readonly = true;
}
void setupPacketizer(Packetizer& packetizer) override {
NeoVIFIRE2::setupPacketizer(packetizer);
packetizer.align16bit = false;
}
};
}
#endif // __cplusplus
#endif
@@ -1,34 +0,0 @@
#ifndef __NEOVIFIRE2USB_H_
#define __NEOVIFIRE2USB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/neovifire2/neovifire2.h"
#include "icsneo/platform/ftdi.h"
namespace icsneo {
class NeoVIFIRE2USB : public NeoVIFIRE2 {
public:
static constexpr const uint16_t PRODUCT_ID = 0x1000;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.emplace_back(new NeoVIFIRE2USB(neodevice)); // Creation of the shared_ptr
return found;
}
private:
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
initialize<FTDI, NeoVIFIRE2Settings>();
productId = PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif
@@ -3,7 +3,6 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/pcap.h"
#include "icsneo/disk/extextractordiskreaddriver.h"
#include "icsneo/disk/neomemorydiskdriver.h"
#include "icsneo/device/tree/neovired2/neovired2settings.h"
@@ -12,41 +11,9 @@ 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;
}
// Serial numbers start with D2
// Ethernet MAC allocation is 0x0E, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(NeoVIRED2, DeviceType::RED2, "D2");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -68,10 +35,8 @@ public:
}
protected:
NeoVIRED2(neodevice_t neodevice) : Device(neodevice) {
initialize<PCAP, NeoVIRED2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
NeoVIRED2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<NeoVIRED2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
}
virtual void setupEncoder(Encoder& encoder) override {
@@ -84,13 +49,13 @@ protected:
packetizer.align16bit = false;
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
+4 -15
View File
@@ -5,7 +5,6 @@
#include "icsneo/device/tree/plasion/plasion.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/ftdi.h"
#include "icsneo/disk/plasiondiskreaddriver.h"
#include "icsneo/disk/neomemorydiskdriver.h"
@@ -13,22 +12,12 @@ namespace icsneo {
class NeoVIION : public Plasion {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::ION;
static constexpr const uint16_t PRODUCT_ID = 0x0901;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.emplace_back(new NeoVIION(neodevice));
return found;
}
// USB PID is 0x0901, standard driver is FTDI
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIION, DeviceType::ION, 0x0901);
private:
NeoVIION(neodevice_t neodevice) : Plasion(neodevice) {
initialize<FTDI, NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
NeoVIION(neodevice_t neodevice, const driver_factory_t& makeDriver) : Plasion(neodevice) {
initialize<NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
}
virtual std::shared_ptr<Communication> makeCommunication(
@@ -5,28 +5,17 @@
#include "icsneo/device/tree/plasion/plasion.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/ftdi.h"
namespace icsneo {
class NeoVIPLASMA : public Plasion {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::PLASMA;
static constexpr const uint16_t PRODUCT_ID = 0x0801;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.emplace_back(new NeoVIPLASMA(neodevice));
return found;
}
// USB PID is 0x0801, standard driver is FTDI
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIPLASMA, DeviceType::PLASMA, 0x0801);
private:
NeoVIPLASMA(neodevice_t neodevice) : Plasion(neodevice) {
initialize<FTDI>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
NeoVIPLASMA(neodevice_t neodevice, const driver_factory_t& makeDriver) : Plasion(neodevice) {
initialize<NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
}
virtual std::shared_ptr<Communication> makeCommunication(
+3 -5
View File
@@ -5,7 +5,6 @@
#include "icsneo/device/device.h"
#include "icsneo/communication/multichannelcommunication.h"
#include "icsneo/platform/ftdi.h"
#include "icsneo/device/extensions/flexray/extension.h"
namespace icsneo {
@@ -45,6 +44,8 @@ public:
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
using Device::Device;
// TODO This is done so that Plasion can still transmit it's basic networks, awaiting slave VNET support
virtual bool isSupportedRXNetwork(const Network&) const override { return true; }
virtual bool isSupportedTXNetwork(const Network&) const override { return true; }
@@ -55,7 +56,7 @@ protected:
addExtension(std::make_shared<FlexRay::Extension>(*this, flexRayControllers));
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
for(auto& netid : GetSupportedNetworks())
rxNetworks.emplace_back(netid);
// TODO Check configuration for FlexRay ColdStart mode, disable FlexRay 2 if so
@@ -87,9 +88,6 @@ protected:
const fire2vnet_status_t* status = reinterpret_cast<const fire2vnet_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
public:
Plasion(neodevice_t neodevice) : Device(neodevice) {}
};
}
@@ -3,23 +3,14 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/cdcacm.h"
namespace icsneo {
class RADEpsilon : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADEpsilon;
static constexpr const char* SERIAL_START = "RE";
static constexpr const uint16_t PRODUCT_ID = 0x1109;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new RADEpsilon(neodevice));
return found;
}
// Serial numbers start with RE
// USB PID is 0x1109, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(RADEpsilon, DeviceType::RADEpsilon, "RE");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -34,10 +25,8 @@ public:
}
protected:
RADEpsilon(neodevice_t neodevice) : Device(neodevice) {
initialize<CDCACM>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
RADEpsilon(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize(makeDriver);
}
virtual void setupEncoder(Encoder& encoder) override {
@@ -45,13 +34,13 @@ protected:
encoder.supportCANFD = true;
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
@@ -5,7 +5,6 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/pcap.h"
#include "icsneo/communication/packetizer.h"
#include "icsneo/communication/decoder.h"
#include "icsneo/device/tree/radgalaxy/radgalaxysettings.h"
@@ -15,41 +14,8 @@ namespace icsneo {
class RADGalaxy : public Device {
public:
// Serial numbers start with RG
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADGalaxy;
static constexpr const uint16_t PRODUCT_ID = 0x0003;
static constexpr const char* SERIAL_START = "RG";
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<RADGalaxy>(new RADGalaxy({}));
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 RADGalaxy
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.emplace_back(new RADGalaxy(std::move(device)));
break;
}
}
return found;
}
// Ethernet MAC allocation is 0x03, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(RADGalaxy, DeviceType::RADGalaxy, "RG");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -85,15 +51,13 @@ public:
return supportedNetworks;
}
RADGalaxy(neodevice_t neodevice) : Device(neodevice) {
initialize<PCAP, RADGalaxySettings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
RADGalaxy(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADGalaxySettings>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
packetizer.disableChecksum = true;
@@ -11,16 +11,18 @@ namespace icsneo {
class RADGigastar : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADGigastar;
static constexpr const char* SERIAL_START = "GS";
// Serial numbers start with GS
// USB PID is 0x1204, standard driver is FTDI3
// Ethernet MAC allocation is 0x0F, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(RADGigastar, DeviceType::RADGigastar, "GS");
size_t getEthernetActivationLineCount() const override { return 1; }
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADGigastar(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
RADGigastar(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADGigastarSettings>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
@@ -1,58 +0,0 @@
#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->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 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
@@ -1,34 +0,0 @@
#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
+6 -4
View File
@@ -11,14 +11,16 @@ namespace icsneo {
class RADMars : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADMars;
static constexpr const char* SERIAL_START = "GL";
// Serial numbers start with GL (previously, RAD-Gigalog)
// USB PID is 0x1203, standard driver is FTDI3
// Ethernet MAC allocation is 0x0A, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(RADMars, DeviceType::RADMars, "GL");
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
RADMars(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
RADMars(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADMarsSettings>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
@@ -1,58 +0,0 @@
#ifndef __RADMARS_ETH_H_
#define __RADMARS_ETH_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radmars/radmars.h"
#include "icsneo/platform/pcap.h"
namespace icsneo {
class RADMarsETH : public RADMars {
public:
static constexpr const uint16_t PRODUCT_ID = 0x000A;
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<RADMarsETH>(new RADMarsETH({}));
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 RAD-Mars
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.push_back(std::shared_ptr<RADMarsETH>(new RADMarsETH(std::move(device))));
break;
}
}
return found;
}
private:
RADMarsETH(neodevice_t neodevice) : RADMars(neodevice) {
initialize<PCAP, RADMarsSettings>();
productId = PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif
@@ -1,34 +0,0 @@
#ifndef __RADMARS_USB_H_
#define __RADMARS_USB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radmars/radmars.h"
#include "icsneo/platform/ftdi3.h"
namespace icsneo {
class RADMarsUSB : public RADMars {
public:
static constexpr const uint16_t PRODUCT_ID = 0x1203;
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 RADMarsUSB(neodevice)); // Creation of the shared_ptr
return found;
}
private:
RADMarsUSB(neodevice_t neodevice) : RADMars(neodevice) {
initialize<FTDI3, RADMarsSettings>();
productId = PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif
+5 -17
View File
@@ -6,15 +6,14 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/tree/radmoon2/radmoon2settings.h"
#include "icsneo/platform/ftdi3.h"
namespace icsneo {
class RADMoon2 : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADMoon2;
static constexpr const uint16_t PRODUCT_ID = 0x1202;
static constexpr const char* SERIAL_START = "RM";
// Serial numbers start with RM
// USB PID is 0x1202, standard driver is FTDI3
ICSNEO_FINDABLE_DEVICE(RADMoon2, DeviceType::RADMoon2, "RM");
enum class SKU {
Standard,
@@ -22,15 +21,6 @@ public:
APM1000E_CLK, // Clock Option and Keysight Branding
};
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 RADMoon2(neodevice));
return found;
}
SKU getSKU() const {
switch(getSerial().back()) {
case 'A':
@@ -70,10 +60,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADMoon2(neodevice_t neodevice) : Device(neodevice) {
initialize<FTDI3, RADMoon2Settings>();
productId = PRODUCT_ID;
getWritableNeoDevice().type = DEVICE_TYPE;
RADMoon2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADMoon2Settings>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
@@ -6,24 +6,14 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/tree/radmoonduo/radmoonduosettings.h"
#include "icsneo/platform/cdcacm.h"
namespace icsneo {
class RADMoonDuo : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADMoonDuo;
static constexpr const uint16_t PRODUCT_ID = 0x1106;
static constexpr const char* SERIAL_START = "MD";
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new RADMoonDuo(neodevice));
return found;
}
// Serial numbers start with MD
// USB PID is 1106, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(RADMoonDuo, DeviceType::RADMoonDuo, "MD");
static const std::vector<Network>& GetSupportedNetworks() {
// If Converter1 Target is set to USB/CM, OP_Ethernet2 will be exposed to the PC
@@ -36,10 +26,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADMoonDuo(neodevice_t neodevice) : Device(neodevice) {
initialize<CDCACM, RADMoonDuoSettings>();
productId = PRODUCT_ID;
getWritableNeoDevice().type = DEVICE_TYPE;
RADMoonDuo(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADMoonDuoSettings>(makeDriver);
}
virtual void setupEncoder(Encoder& encoder) override {
+8 -12
View File
@@ -5,8 +5,6 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/communication/packetizer.h"
#include "icsneo/communication/decoder.h"
#include "icsneo/device/tree/radpluto/radplutosettings.h"
namespace icsneo {
@@ -14,9 +12,8 @@ namespace icsneo {
class RADPluto : public Device {
public:
// Serial numbers start with PL
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADPluto;
static constexpr const uint16_t PRODUCT_ID = 0x1104;
static constexpr const char* SERIAL_START = "PL";
// USB PID is 1104, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(RADPluto, DeviceType::RADPluto, "PL");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -35,27 +32,26 @@ public:
return supportedNetworks;
}
RADPluto(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADPluto(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADPlutoSettings>(makeDriver);
}
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
encoder.supportEthPhy = true;
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool requiresVehiclePower() const override { return false; }
};
@@ -1,33 +0,0 @@
#ifndef __RADPLUTOUSB_H_
#define __RADPLUTOUSB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radpluto/radpluto.h"
#include "icsneo/platform/cdcacm.h"
namespace icsneo {
class RADPlutoUSB : public RADPluto {
public:
// Serial numbers start with RP
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new RADPlutoUSB(neodevice));
return found;
}
private:
RADPlutoUSB(neodevice_t neodevice) : RADPluto(neodevice) {
initialize<CDCACM, RADPlutoSettings>();
}
};
}
#endif // __cplusplus
#endif
+9 -10
View File
@@ -12,9 +12,9 @@ namespace icsneo {
class RADStar2 : public Device {
public:
// Serial numbers start with RS
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADStar2;
static constexpr const uint16_t PRODUCT_ID = 0x0005;
static constexpr const char* SERIAL_START = "RS";
// USB PID is 0x0005, standard driver is FTDI
// Ethernet MAC allocation is 0x05, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(RADStar2, DeviceType::RADStar2, "RS");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -30,6 +30,10 @@ public:
}
protected:
RADStar2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADStar2Settings>(makeDriver);
}
virtual void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
packetizer.disableChecksum = true;
@@ -46,18 +50,13 @@ protected:
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
RADStar2(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
@@ -1,58 +0,0 @@
#ifndef __RADSTAR2ETH_H_
#define __RADSTAR2ETH_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radstar2/radstar2.h"
#include "icsneo/communication/network.h"
#include "icsneo/communication/message/serialnumbermessage.h"
#include "icsneo/platform/pcap.h"
namespace icsneo {
class RADStar2ETH : public RADStar2 {
public:
// Serial numbers start with RS
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<RADStar2ETH>(new RADStar2ETH({}));
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 RADStar2
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.push_back(std::make_shared<RADStar2ETH>(device));
break;
}
}
return found;
}
RADStar2ETH(neodevice_t neodevice) : RADStar2(neodevice) {
initialize<PCAP, RADStar2Settings>();
}
};
}
#endif // __cplusplus
#endif
@@ -1,33 +0,0 @@
#ifndef __RADSTAR2USB_H_
#define __RADSTAR2USB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/radstar2/radstar2.h"
#include "icsneo/platform/ftdi.h"
namespace icsneo {
class RADStar2USB : public RADStar2 {
public:
// Serial numbers start with RS
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.emplace_back(new RADStar2USB(neodevice));
return found;
}
private:
RADStar2USB(neodevice_t neodevice) : RADStar2(neodevice) {
initialize<FTDI, RADStar2Settings>();
}
};
}
#endif // __cplusplus
#endif
@@ -6,30 +6,20 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/device/tree/radsupermoon/radsupermoonsettings.h"
#include "icsneo/platform/ftdi3.h"
namespace icsneo {
class RADSupermoon : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADSupermoon;
static constexpr const uint16_t PRODUCT_ID = 0x1201;
static constexpr const char* SERIAL_START = "SM";
// Serial numbers start with SM
// USB PID is 0x1201, standard driver is FTDI3
ICSNEO_FINDABLE_DEVICE(RADSupermoon, DeviceType::RADSupermoon, "SM");
enum class SKU {
Standard,
APM1000ET, // Keysight Branding
};
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 RADSupermoon(neodevice));
return found;
}
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::Ethernet,
@@ -60,10 +50,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; }
protected:
RADSupermoon(neodevice_t neodevice) : Device(neodevice) {
initialize<FTDI3, RADSupermoonSettings>();
productId = PRODUCT_ID;
getWritableNeoDevice().type = DEVICE_TYPE;
RADSupermoon(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADSupermoonSettings>(makeDriver);
}
void setupPacketizer(Packetizer& packetizer) override {
@@ -12,16 +12,8 @@ namespace icsneo {
class ValueCAN3 : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN3;
static constexpr const uint16_t PRODUCT_ID = 0x0601;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.emplace_back(new ValueCAN3(neodevice));
return found;
}
// USB PID is 0x0601, standard driver is FTDI
ICSNEO_FINDABLE_DEVICE_BY_PID(ValueCAN3, DeviceType::VCAN3, 0x0701);
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -32,19 +24,17 @@ public:
}
private:
ValueCAN3(neodevice_t neodevice) : Device(neodevice) {
initialize<FTDI, ValueCAN3Settings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
ValueCAN3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<ValueCAN3Settings>(makeDriver);
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool requiresVehiclePower() const override { return false; }
};
@@ -5,27 +5,14 @@
#include "icsneo/device/tree/valuecan4/valuecan4.h"
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1settings.h"
#include "icsneo/platform/cdcacm.h"
#include <string>
namespace icsneo {
class ValueCAN4_1 : public ValueCAN4 {
public:
// Serial numbers start with V1 for 4-1
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_1;
static constexpr const char* SERIAL_START = "V1";
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
found.emplace_back(new ValueCAN4_1(neodevice));
}
return found;
}
// USB PID is 0x1101 (shared by all ValueCAN 4s), standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(ValueCAN4_1, DeviceType::VCAN4_1, "V1");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
@@ -35,25 +22,22 @@ public:
}
protected:
ValueCAN4_1(neodevice_t neodevice, const driver_factory_t& makeDriver) : ValueCAN4(neodevice) {
initialize<ValueCAN4_1Settings>(makeDriver);
}
void setupEncoder(Encoder& encoder) override {
ValueCAN4::setupEncoder(encoder);
encoder.supportCANFD = false; // VCAN 4-1 does not support CAN FD
}
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
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); }
private:
ValueCAN4_1(neodevice_t neodevice) : ValueCAN4(neodevice) {
initialize<CDCACM, ValueCAN4_1Settings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = USB_PRODUCT_ID;
}
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
@@ -5,33 +5,20 @@
#include "icsneo/device/tree/valuecan4/valuecan4.h"
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2settings.h"
#include "icsneo/platform/cdcacm.h"
#include <string>
namespace icsneo {
class ValueCAN4_2 : public ValueCAN4 {
public:
// Serial numbers start with V2 for 4-2
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2;
static constexpr const char* SERIAL_START = "V2";
// USB PID is 0x1101 (shared by all ValueCAN 4s), standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(ValueCAN4_2, DeviceType::VCAN4_2, "V2");
enum class SKU {
Standard,
AP0200A, // USB A and Keysight Branding
};
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
found.emplace_back(new ValueCAN4_2(neodevice));
}
return found;
}
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
@@ -60,20 +47,17 @@ public:
}
protected:
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
ValueCAN4_2(neodevice_t neodevice, const driver_factory_t& makeDriver) : ValueCAN4(neodevice) {
initialize<ValueCAN4_2Settings>(makeDriver);
}
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); }
private:
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
initialize<CDCACM, ValueCAN4_2Settings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = USB_PRODUCT_ID;
}
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
@@ -5,15 +5,15 @@
#include "icsneo/device/tree/valuecan4/valuecan4.h"
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2elsettings.h"
#include <string>
namespace icsneo {
class ValueCAN4_2EL : public ValueCAN4 {
public:
// Serial numbers start with VE for 4-2EL
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2EL;
static constexpr const char* SERIAL_START = "VE";
// USB PID is 0x1101 (shared by all ValueCAN 4s), standard driver is CDCACM
// Ethernet MAC allocation is 0x0B, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(ValueCAN4_2EL, DeviceType::VCAN4_2EL, "VE");
enum class SKU {
Standard,
@@ -53,14 +53,16 @@ public:
Network::NetID::HSCAN,
Network::NetID::HSCAN2,
Network::NetID::Ethernet
Network::NetID::Ethernet,
Network::NetID::LIN
};
return supportedNetworks;
}
protected:
ValueCAN4_2EL(neodevice_t neodevice) : ValueCAN4(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
ValueCAN4_2EL(neodevice_t neodevice, const driver_factory_t& makeDriver) : ValueCAN4(neodevice) {
initialize<ValueCAN4_2ELSettings>(makeDriver);
}
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
@@ -80,6 +82,13 @@ protected:
const valuecan4_2el_status_t* status = reinterpret_cast<const valuecan4_2el_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
bool currentDriverSupportsDFU() const override { return com->driver->isEthernet(); }
void setupPacketizer(Packetizer& packetizer) override {
ValueCAN4::setupPacketizer(packetizer);
packetizer.align16bit = !com->driver->isEthernet();
}
};
}
@@ -1,68 +0,0 @@
#ifndef __VALUECAN4_2EL_ETH_H_
#define __VALUECAN4_2EL_ETH_H_
#ifdef __cplusplus
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
#include "icsneo/platform/pcap.h"
#include <string>
namespace icsneo {
class ValueCAN4_2EL_ETH : public ValueCAN4_2EL {
public:
static constexpr const uint16_t ETH_PRODUCT_ID = 0x000B;
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<ValueCAN4_2EL_ETH>(new ValueCAN4_2EL_ETH({}));
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 ValueCAN4-2EL
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.push_back(std::shared_ptr<ValueCAN4_2EL_ETH>(new ValueCAN4_2EL_ETH(std::move(device))));
break;
}
}
return found;
}
bool currentDriverSupportsDFU() const override { return false; }
protected:
void setupPacketizer(Packetizer& packetizer) override {
ValueCAN4_2EL::setupPacketizer(packetizer);
packetizer.align16bit = false;
}
private:
ValueCAN4_2EL_ETH(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) {
initialize<PCAP, ValueCAN4_2ELSettings>();
productId = ETH_PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif
@@ -1,36 +0,0 @@
#ifndef __VALUECAN4_2EL_USB_H_
#define __VALUECAN4_2EL_USB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
#include "icsneo/platform/cdcacm.h"
#include <string>
namespace icsneo {
class ValueCAN4_2EL_USB : public ValueCAN4_2EL {
public:
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
found.emplace_back(new ValueCAN4_2EL_USB(neodevice));
}
return found;
}
private:
ValueCAN4_2EL_USB(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) {
initialize<CDCACM, ValueCAN4_2ELSettings>();
productId = USB_PRODUCT_ID;
}
};
}
#endif // __cplusplus
#endif
@@ -5,16 +5,14 @@
#include "icsneo/device/tree/valuecan4/valuecan4.h"
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h"
#include "icsneo/platform/cdcacm.h"
#include <string>
namespace icsneo {
class ValueCAN4_4 : public ValueCAN4 {
public:
// Serial numbers start with V4 for 4-4
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_4;
static constexpr const char* SERIAL_START = "V4";
// USB PID is 0x1101 (shared by all ValueCAN 4s), standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(ValueCAN4_4, DeviceType::VCAN4_4, "V4");
enum class SKU {
Standard,
@@ -23,17 +21,6 @@ public:
AP0400A_OBD, // OBD, USB A, and Keysight Branding
};
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
found.emplace_back(new ValueCAN4_4(neodevice));
}
return found;
}
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
@@ -71,20 +58,17 @@ public:
}
protected:
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
ValueCAN4_4(neodevice_t neodevice, const driver_factory_t& makeDriver) : ValueCAN4(neodevice) {
initialize<ValueCAN4_4Settings>(makeDriver);
}
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); }
private:
ValueCAN4_4(neodevice_t neodevice) : ValueCAN4(neodevice) {
initialize<CDCACM, ValueCAN4_4Settings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = USB_PRODUCT_ID;
}
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
};
}
@@ -10,17 +10,16 @@ namespace icsneo {
class ValueCAN4 : public Device {
public:
// All ValueCAN 4 devices share a USB PID
static constexpr const uint16_t USB_PRODUCT_ID = 0x1101;
// All ValueCAN 4 devices share a USB PID of 0x1101
protected:
using Device::Device;
virtual void setupEncoder(Encoder& encoder) override {
Device::setupEncoder(encoder);
encoder.supportCANFD = true;
}
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {}
bool requiresVehiclePower() const override { return false; }
};
@@ -11,12 +11,40 @@ namespace icsneo {
class ValueCAN4Industrial : public ValueCAN4 {
public:
// Serial numbers start with IV for Industrial
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_IND;
static constexpr const char* SERIAL_START = "IV";
// USB PID is 0x1101 (shared by all ValueCAN 4s), standard driver is CDCACM
// Ethernet MAC allocation is 0x12, standard driver is Raw
ICSNEO_FINDABLE_DEVICE(ValueCAN4Industrial, DeviceType::VCAN4_IND, "IV");
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::HSCAN2,
Network::NetID::Ethernet,
Network::NetID::LIN
};
return supportedNetworks;
}
protected:
ValueCAN4Industrial(neodevice_t neodevice) : ValueCAN4(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
ValueCAN4Industrial(neodevice_t neodevice, const driver_factory_t& makeDriver) : ValueCAN4(neodevice) {
initialize<ValueCAN4IndustrialSettings>(makeDriver);
}
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
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
bool currentDriverSupportsDFU() const override { return com->driver->isEthernet(); }
void setupPacketizer(Packetizer& packetizer) override {
ValueCAN4::setupPacketizer(packetizer);
packetizer.align16bit = !com->driver->isEthernet();
}
};
@@ -1,85 +0,0 @@
#ifndef __VALUECAN4INDUSTRIAL_ETH_H_
#define __VALUECAN4INDUSTRIAL_ETH_H_
#ifdef __cplusplus
#include "icsneo/device/tree/valuecan4/valuecan4industrial.h"
#include "icsneo/platform/pcap.h"
#include <string>
namespace icsneo {
class ValueCAN4IndustrialETH : public ValueCAN4Industrial {
public:
static constexpr const uint16_t ETH_PRODUCT_ID = 0x0012;
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<ValueCAN4IndustrialETH>(new ValueCAN4IndustrialETH({}));
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 ValueCAN 4 Industrial
auto device = foundDev.device;
device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0';
found.push_back(std::shared_ptr<ValueCAN4IndustrialETH>(new ValueCAN4IndustrialETH(std::move(device))));
break;
}
}
return found;
}
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::HSCAN2,
// No Network::NetID::Ethernet, since we're communicating over it instead
};
return supportedNetworks;
}
bool currentDriverSupportsDFU() const override { return false; }
protected:
void setupPacketizer(Packetizer& packetizer) override {
ValueCAN4Industrial::setupPacketizer(packetizer);
packetizer.align16bit = false;
}
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); }
private:
ValueCAN4IndustrialETH(neodevice_t neodevice) : ValueCAN4Industrial(neodevice) {
initialize<PCAP, ValueCAN4IndustrialSettings>();
}
};
}
#endif // __cplusplus
#endif
@@ -1,54 +0,0 @@
#ifndef __VALUECAN4INDUSTRIAL_USB_H_
#define __VALUECAN4INDUSTRIAL_USB_H_
#ifdef __cplusplus
#include "icsneo/device/tree/valuecan4/valuecan4industrial.h"
#include "icsneo/platform/cdcacm.h"
#include <string>
namespace icsneo {
class ValueCAN4IndustrialUSB : public ValueCAN4Industrial {
public:
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
found.emplace_back(new ValueCAN4IndustrialUSB(neodevice));
}
return found;
}
static const std::vector<Network>& GetSupportedNetworks() {
static std::vector<Network> supportedNetworks = {
Network::NetID::HSCAN,
Network::NetID::HSCAN2,
Network::NetID::Ethernet
};
return supportedNetworks;
}
protected:
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); }
private:
ValueCAN4IndustrialUSB(neodevice_t neodevice) : ValueCAN4Industrial(neodevice) {
initialize<CDCACM, ValueCAN4IndustrialSettings>();
}
};
}
#endif // __cplusplus
#endif
+6 -17
View File
@@ -13,16 +13,8 @@ namespace icsneo {
class VividCAN : public Device {
public:
// Serial numbers start with VV
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VividCAN;
static constexpr const uint16_t PRODUCT_ID = 0x1102;
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
found.emplace_back(new VividCAN(neodevice));
return found;
}
// USB PID is 0x1102, standard driver is CDCACM
ICSNEO_FINDABLE_DEVICE(VividCAN, DeviceType::VividCAN, "VV");
// VividCAN does not go online, you can only set settings
bool goOnline() override {
@@ -36,14 +28,11 @@ public:
}
protected:
bool requiresVehiclePower() const override { return false; }
private:
VividCAN(neodevice_t neodevice) : Device(neodevice) {
initialize<CDCACM, VividCANSettings>();
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
VividCAN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<VividCANSettings>(makeDriver);
}
bool requiresVehiclePower() const override { return false; }
};
}