Refactor for a central include directory

This commit is contained in:
Paul Hollinsky
2018-10-22 11:52:34 -04:00
parent 12451def11
commit 8e6b0d0b0e
127 changed files with 263 additions and 265 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
#include "include/device.h"
#include "communication/message/callback/include/messagecallback.h"
#include "communication/include/command.h"
#include "icsneo/device/device.h"
#include "icsneo/communication/message/callback/messagecallback.h"
#include "icsneo/communication/command.h"
#include <string.h>
#include <iostream>
#include <sstream>
+2 -2
View File
@@ -1,5 +1,5 @@
#include "device/include/devicefinder.h"
#include "platform/include/devices.h"
#include "icsneo/device/devicefinder.h"
#include "icsneo/platform/devices.h"
using namespace icsneo;
+2 -2
View File
@@ -1,5 +1,5 @@
#include "device/include/idevicesettings.h"
#include "communication/message/filter/include/main51messagefilter.h"
#include "icsneo/device/idevicesettings.h"
#include "icsneo/communication/message/filter/main51messagefilter.h"
#include <cstring>
using namespace icsneo;
-93
View File
@@ -1,93 +0,0 @@
#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <vector>
#include <memory>
#include <cstring>
#include "device/include/neodevice.h"
#include "device/include/idevicesettings.h"
#include "device/include/devicetype.h"
#include "communication/include/communication.h"
#include "communication/include/packetizer.h"
#include "communication/include/encoder.h"
#include "communication/include/decoder.h"
#include "communication/message/include/resetstatusmessage.h"
#include "third-party/concurrentqueue/concurrentqueue.h"
namespace icsneo {
class Device {
public:
Device(neodevice_t neodevice = { 0 }) {
data = neodevice;
data.device = this;
}
virtual ~Device() {
disableMessagePolling();
close();
}
static std::string SerialNumToString(uint32_t serial);
static uint32_t SerialStringToNum(const std::string& serial);
static bool SerialStringIsNumeric(const std::string& serial);
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; }
virtual bool open();
virtual bool close();
virtual bool isOnline() const { return online; }
virtual bool goOnline();
virtual bool goOffline();
// Message polling related functions
void enableMessagePolling();
bool disableMessagePolling();
std::vector<std::shared_ptr<Message>> getMessages();
bool getMessages(std::vector<std::shared_ptr<Message>>& container, size_t limit = 0);
size_t getCurrentMessageCount() { return pollingContainer.size_approx(); }
size_t getPollingMessageLimit() { return pollingMessageLimit; }
void setPollingMessageLimit(size_t newSize) {
pollingMessageLimit = newSize;
enforcePollingMessageLimit();
}
bool transmit(std::shared_ptr<Message> message);
bool transmit(std::vector<std::shared_ptr<Message>> messages);
void handleInternalMessage(std::shared_ptr<Message> message);
std::unique_ptr<IDeviceSettings> settings;
protected:
uint16_t productId = 0;
bool online = false;
int messagePollingCallbackID = 0;
int internalHandlerCallbackID = 0;
std::shared_ptr<Communication> com;
neodevice_t& getWritableNeoDevice() { return data; }
private:
neodevice_t data;
std::shared_ptr<ResetStatusMessage> latestResetStatus;
enum class LEDState : uint8_t {
Offline = 0x04,
CoreMiniRunning = 0x08, // This should override "offline" if the CoreMini is running
Online = 0x10
};
LEDState ledState;
void updateLEDState();
size_t pollingMessageLimit = 20000;
moodycamel::ConcurrentQueue<std::shared_ptr<Message>> pollingContainer;
void enforcePollingMessageLimit();
};
}
#endif
-17
View File
@@ -1,17 +0,0 @@
#ifndef __DEVICEFINDER_H_
#define __DEVICEFINDER_H_
#include "device/include/device.h"
#include <vector>
#include <memory>
namespace icsneo {
class DeviceFinder {
public:
static std::vector<std::shared_ptr<Device>> FindAll();
};
}
#endif
-164
View File
@@ -1,164 +0,0 @@
#ifndef __DEVICETYPE_H_
#define __DEVICETYPE_H_
// Hold the length of the longest name, so that C applications can allocate memory accordingly
// Currently the longest is "Intrepid Ethernet Evaluation Board"
#define DEVICE_TYPE_LONGEST_NAME (35 + 1) // Add 1 so that if someone forgets, they still have space for null terminator
#ifndef __cplusplus
#include <stdint.h>
typedef uint32_t devicetype_t;
#else
#include <ostream>
#include <cstdint>
typedef uint32_t devicetype_t;
namespace icsneo {
class DeviceType {
public:
// This enum used to be a bitfield, but has since become an enum as we have more than 32 devices
enum Enum : devicetype_t {
Unknown = (0x00000000),
BLUE = (0x00000001),
ECU_AVB = (0x00000002),
RADSupermoon = (0x00000003),
DW_VCAN = (0x00000004),
RADMoon2 = (0x00000005),
RADGigalog = (0x00000006),
VCAN4_1 = (0x00000007),
FIRE = (0x00000008),
RADPluto = (0x00000009),
VCAN4_2EL = (0x0000000a),
RADIO_CANHUB = (0x0000000b),
VCAN3 = (0x00000010),
RED = (0x00000040),
ECU = (0x00000080),
IEVB = (0x00000100),
Pendant = (0x00000200),
OBD2_PRO = (0x00000400),
ECUChip_UART = (0x00000800),
PLASMA = (0x00001000),
DONT_REUSE0 = (0x00002000), // Previously FIRE_VNET
NEOAnalog = (0x00004000),
CT_OBD = (0x00008000),
DONT_REUSE1 = (0x00010000), // Previously PLASMA_1_12
DONT_REUSE2 = (0x00020000), // Previously PLASMA_1_13
ION = (0x00040000),
RADStar = (0x00080000),
DONT_REUSE3 = (0x00100000), // Previously ION3
VCAN4_4 = (0x00200000),
VCAN4_2 = (0x00400000),
CMProbe = (0x00800000),
EEVB = (0x01000000),
VCANrf = (0x02000000),
FIRE2 = (0x04000000),
Flex = (0x08000000),
RADGalaxy = (0x10000000),
RADStar2 = (0x20000000),
VividCAN = (0x40000000),
OBD2_SIM = (0x80000000)
};
static const char* GetDeviceTypeString(DeviceType::Enum type) {
// Adding something? Make sure you update DEVICE_TYPE_LONGEST_NAME at the top!
switch(type) {
case Unknown:
return "Unknown";
case BLUE:
return "neoVI BLUE";
case ECU_AVB:
return "neoECU AVB";
case RADSupermoon:
return "RADSupermoon";
case DW_VCAN:
return "DW_VCAN";
case RADMoon2:
return "RADMoon 2";
case RADGigalog:
return "RADGigalog";
case VCAN4_1:
return "ValueCAN 4-1";
case FIRE:
return "neoVI FIRE";
case RADPluto:
return "RADPluto";
case VCAN4_2EL:
return "ValueCAN 4-2EL";
case RADIO_CANHUB:
return "RADIO_CANHUB";
case VCAN3:
return "ValueCAN 3";
case RED:
return "neoVI RED";
case ECU:
return "neoECU";
case IEVB:
return "IEVB";
case Pendant:
return "Pendant";
case OBD2_PRO:
return "neoOBD2 PRO";
case ECUChip_UART:
return "neoECU Chip UART";
case PLASMA:
return "neoVI PLASMA";
case NEOAnalog:
return "NEOAnalog";
case CT_OBD:
return "CT_OBD";
case ION:
return "neoVI ION";
case RADStar:
return "RADStar";
case VCAN4_4:
return "ValueCAN 4-4";
case VCAN4_2:
return "ValueCAN 4-2";
case CMProbe:
return "CMProbe";
case EEVB:
return "Intrepid Ethernet Evaluation Board";
case VCANrf:
return "ValueCAN.rf";
case FIRE2:
return "neoVI FIRE 2";
case Flex:
return "neoVI Flex";
case RADGalaxy:
return "RADGalaxy";
case RADStar2:
return "RADStar 2";
case VividCAN:
return "VividCAN";
case OBD2_SIM:
return "neoOBD2-SIM";
case DONT_REUSE0:
case DONT_REUSE1:
case DONT_REUSE2:
case DONT_REUSE3:
// Intentionally don't use default so that the compiler throws a warning when something is added
return "Unknown neoVI";
}
return "Unknown neoVI";
}
DeviceType() { value = DeviceType::Enum::Unknown; }
DeviceType(devicetype_t netid) { value = (DeviceType::Enum)netid; }
DeviceType(DeviceType::Enum netid) { value = netid; }
DeviceType::Enum getDeviceType() const { return value; }
std::string toString() const { return GetDeviceTypeString(getDeviceType()); }
friend std::ostream& operator<<(std::ostream& os, const DeviceType& type) {
os << type.toString().c_str();
return os;
}
private:
DeviceType::Enum value;
};
}
#endif // __cplusplus
#endif
-318
View File
@@ -1,318 +0,0 @@
#ifndef __IDEVICESETTINGS_H_
#define __IDEVICESETTINGS_H_
#include <stdint.h>
#pragma pack(push, 2)
/* SetBaudrate in CAN_SETTINGS */
enum
{
AUTO,
USE_TQ
};
/* Baudrate in CAN_SETTINGS/CANFD_SETTINGS */
enum
{
BPS20,
BPS33,
BPS50,
BPS62,
BPS83,
BPS100,
BPS125,
BPS250,
BPS500,
BPS800,
BPS1000,
BPS666,
BPS2000,
BPS4000,
CAN_BPS5000,
CAN_BPS6667,
CAN_BPS8000,
CAN_BPS10000,
};
/* Mode in CAN_SETTINGS */
enum
{
NORMAL = 0,
DISABLE = 1,
LOOPBACK = 2,
LISTEN_ONLY = 3,
LISTEN_ALL = 7
};
typedef struct
{
uint8_t Mode;
uint8_t SetBaudrate;
uint8_t Baudrate;
uint8_t transceiver_mode;
uint8_t TqSeg1;
uint8_t TqSeg2;
uint8_t TqProp;
uint8_t TqSync;
uint16_t BRP;
uint8_t auto_baud;
uint8_t innerFrameDelay25us;
} CAN_SETTINGS;
#define CAN_SETTINGS_SIZE 12
/* FDMode in CANFD_SETTINGS */
enum
{
NO_CANFD,
CANFD_ENABLED,
CANFD_BRS_ENABLED,
CANFD_ENABLED_ISO,
CANFD_BRS_ENABLED_ISO
};
typedef struct _CANFD_SETTINGS
{
uint8_t FDMode; /* mode, secondary baudrate for canfd */
uint8_t FDBaudrate;
uint8_t FDTqSeg1;
uint8_t FDTqSeg2;
uint8_t FDTqProp;
uint8_t FDTqSync;
uint16_t FDBRP;
uint8_t FDTDC;
uint8_t reserved;
} CANFD_SETTINGS;
#define CANFD_SETTINGS_SIZE 10
typedef struct ETHERNET_SETTINGS_t
{
uint8_t duplex; /* 0 = half, 1 = full */
uint8_t link_speed;
uint8_t auto_neg;
uint8_t led_mode;
uint8_t rsvd[4];
} ETHERNET_SETTINGS;
#define ETHERNET_SETTINGS_SIZE 8
typedef struct
{
uint8_t MasterEnable;
uint8_t SlaveEnable;
uint8_t MasterNetwork;
uint8_t SlaveNetwork;
} TIMESYNC_ICSHARDWARE_SETTINGS;
#define TIMESYNC_ICSHARDWARE_SETTINGS_SIZE 4
typedef struct _STextAPISettings
{
uint32_t can1_tx_id;
uint32_t can1_rx_id;
union {
struct sCAN1Options
{
unsigned bExtended : 1;
unsigned : 15;
};
uint32_t DWord;
} can1_options;
uint32_t can2_tx_id;
uint32_t can2_rx_id;
union {
struct sCAN2Options
{
unsigned bExtended : 1;
unsigned : 15;
};
uint32_t DWord;
} can2_options;
uint32_t network_enables;
uint32_t can3_tx_id;
uint32_t can3_rx_id;
union {
struct sCAN3Options
{
unsigned bExtended : 1;
unsigned : 15;
};
uint32_t DWord;
} can3_options;
uint32_t can4_tx_id;
uint32_t can4_rx_id;
union {
struct sCAN4Options
{
unsigned bExtended : 1;
unsigned : 15;
};
uint32_t DWord;
} can4_options;
uint32_t reserved[5];
} STextAPISettings;
#define STextAPISettings_SIZE 72
/* high_speed_auto_switch in SWCAN_SETTINGS */
enum
{
SWCAN_AUTOSWITCH_DISABLED,
SWCAN_AUTOSWITCH_NO_RESISTOR,
SWCAN_AUTOSWITCH_WITH_RESISTOR,
SWCAN_AUTOSWITCH_DISABLED_RESISTOR_ENABLED
};
typedef struct
{
uint8_t Mode;
uint8_t SetBaudrate;
uint8_t Baudrate;
uint8_t transceiver_mode;
uint8_t TqSeg1;
uint8_t TqSeg2;
uint8_t TqProp;
uint8_t TqSync;
uint16_t BRP;
uint16_t high_speed_auto_switch;
uint8_t auto_baud;
uint8_t RESERVED;
} SWCAN_SETTINGS;
#define SWCAN_SETTINGS_SIZE 14
/* Baudrate in LIN_SETTINGS / ISO9141_KEYWORD2000_SETTINGS / UART_SETTINGS */
enum
{
BPS5000,
BPS10400,
BPS33333,
BPS50000,
BPS62500,
BPS71429,
BPS83333,
BPS100000,
BPS117647
};
/* MasterResistor in LIN_SETTINGS */
enum
{
RESISTOR_ON,
RESISTOR_OFF
};
/* Mode in LIN_SETTINGS */
enum
{
SLEEP_MODE,
SLOW_MODE,
NORMAL_MODE,
FAST_MODE
};
typedef struct _LIN_SETTINGS
{
uint32_t Baudrate; /* New products since FIREVNETEP should rely on this only */
uint16_t spbrg; /* Precompiled to be 40Mhz/Baudrate/16 - 1. Only used in neoVI FIRE/FIREVNET(4dw) */
uint8_t brgh; /* Must be zero */
uint8_t numBitsDelay;
uint8_t MasterResistor;
uint8_t Mode;
} LIN_SETTINGS;
#define LIN_SETTINGS_SIZE 10
typedef struct
{
uint16_t time_500us;
uint16_t k;
uint16_t l;
} ISO9141_KEYWORD2000__INIT_STEP;
#define ISO9141_KEYWORD2000__INIT_STEP_SIZE 6
typedef struct
{
uint32_t Baudrate;
uint16_t spbrg;
uint16_t brgh;
ISO9141_KEYWORD2000__INIT_STEP init_steps[16];
uint8_t init_step_count;
uint16_t p2_500us;
uint16_t p3_500us;
uint16_t p4_500us;
uint16_t chksum_enabled;
} ISO9141_KEYWORD2000_SETTINGS;
#define ISO9141_KEYWORD2000_SETTINGS_SIZE 114
typedef struct _UART_SETTINGS
{
uint16_t Baudrate;
uint16_t spbrg;
uint16_t brgh;
uint16_t parity;
uint16_t stop_bits;
uint8_t flow_control; /* 0- off, 1 - Simple CTS RTS */
uint8_t reserved_1;
union abcd {
uint32_t bOptions;
struct _sOptions
{
unsigned invert_tx : 1;
unsigned invert_rx : 1;
unsigned half_duplex : 1;
unsigned reserved_bits : 13;
unsigned reserved_bits2 : 16;
} sOptions;
};
} UART_SETTINGS;
#define UART_SETTINGS_SIZE 16
#pragma pack(pop)
#ifdef __cplusplus
#include "communication/include/communication.h"
#include <iostream>
namespace icsneo {
class IDeviceSettings {
public:
static constexpr uint16_t GS_VERSION = 5;
static uint16_t CalculateGSChecksum(const std::vector<uint8_t>& settings);
IDeviceSettings(std::shared_ptr<Communication> com, size_t size) : com(com), structSize(size) {}
virtual ~IDeviceSettings() {}
bool ok() { return settingsLoaded; }
bool refresh(bool ignoreChecksum = false); // Get from device
// Send to device, if temporary device keeps settings in volatile RAM until power cycle, otherwise saved to EEPROM
bool apply(bool temporary = false);
bool applyDefaults(bool temporary = false);
virtual bool setBaudrateFor(Network net, uint32_t baudrate);
virtual CAN_SETTINGS* getCANSettingsFor(Network net) { (void)net; return nullptr; }
virtual CANFD_SETTINGS* getCANFDSettingsFor(Network net) { (void)net; return nullptr; }
void* getRawStructurePointer() { return settings.data(); }
template<typename T> T* getStructurePointer() { return static_cast<T*>((void*)settings.data()); }
template<typename T> T getStructureCopy() { return *getStructurePointer<T>(); }
template<typename T> bool setStructure(const T& newStructure);
uint8_t getEnumValueForBaudrate(uint32_t baudrate);
bool readonly = false;
protected:
std::shared_ptr<Communication> com;
size_t structSize;
bool settingsLoaded = false;
std::vector<uint8_t> settings;
};
}
#endif // __cplusplus
#endif
-32
View File
@@ -1,32 +0,0 @@
#ifndef __NEODEVICE_H_
#define __NEODEVICE_H_
#include <stdint.h>
#include "device/include/devicetype.h"
#ifdef __cplusplus
// A forward declaration is needed as there is a circular dependency
namespace icsneo {
class Device;
}
typedef icsneo::Device* devicehandle_t;
#else
typedef void* devicehandle_t;
#endif
typedef int32_t neodevice_handle_t;
#pragma pack(push, 1)
typedef struct {
devicehandle_t device; // Pointer back to the C++ device object
neodevice_handle_t handle; // Handle for use by the underlying driver
devicetype_t type;
char serial[7];
} neodevice_t;
#pragma pack(pop)
#endif
-37
View File
@@ -1,37 +0,0 @@
#ifndef __NEOOBD2PRO_H_
#define __NEOOBD2PRO_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.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;
NeoOBD2PRO(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new STM32(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<NeoOBD2PRO>(neodevice));
return found;
}
};
}
#endif
-37
View File
@@ -1,37 +0,0 @@
#ifndef __NEOOBD2SIM_H_
#define __NEOOBD2SIM_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.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;
NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new STM32(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<NeoOBD2SIM>(neodevice));
return found;
}
};
}
#endif
-60
View File
@@ -1,60 +0,0 @@
#ifndef __NEOVIFIRE_H_
#define __NEOVIFIRE_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class NeoVIFIRE : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE;
static constexpr const uint16_t PRODUCT_ID = 0x0701;
NeoVIFIRE(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
enum class Mode : char {
Application = 'A',
Bootloader = 'B'
};
bool goOnline() {
// Enter mode is only needed on very old FIRE devices, will be ignored by newer devices
if(!enterMode(Mode::Application))
return false;
return Device::goOnline();
}
bool enterMode(Mode mode) {
// Included for compatibility with bootloaders on very old FIRE devices
// Mode will be a uppercase char like 'A'
if(!com->rawWrite({ (uint8_t)mode }))
return false;
// We then expect to see that same mode back in lowercase
// This won't happen in the case of new devices, though, so we assume it worked
return true;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<NeoVIFIRE>(neodevice));
return found;
}
};
}
#endif
-30
View File
@@ -1,30 +0,0 @@
#ifndef __NEOVIFIRE2_H_
#define __NEOVIFIRE2_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class NeoVIFIRE2 : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE2;
static constexpr const char* SERIAL_START = "CY";
NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
}
protected:
static std::shared_ptr<Communication> MakeCommunication(std::unique_ptr<ICommunication> transport) {
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
encoder->supportCANFD = true;
auto decoder = std::unique_ptr<Decoder>(new Decoder());
return std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
}
};
}
#endif
-57
View File
@@ -1,57 +0,0 @@
#ifndef __NEOVIFIRE2ETH_H_
#define __NEOVIFIRE2ETH_H_
#include "device/neovifire2/include/neovifire2.h"
#include "platform/include/pcap.h"
#include "device/neovifire2/include/neovifire2settings.h"
#include <memory>
namespace icsneo {
class NeoVIFIRE2ETH : public NeoVIFIRE2 {
public:
static constexpr const uint16_t PRODUCT_ID = 0x0004;
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
com = MakeCommunicaiton(std::unique_ptr<ICommunication>(new PCAP(getWritableNeoDevice())));
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
settings->readonly = true;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto& foundDev : PCAP::FindAll()) {
auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::unique_ptr<Decoder>(new Decoder());
for(auto& payload : foundDev.discoveryPackets)
packetizer->input(payload);
for(auto& packet : packetizer->output()) {
std::shared_ptr<Message> msg;
if(!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 FIRE 2
foundDev.device.serial[sn->deviceSerial.copy(foundDev.device.serial, sizeof(foundDev.device.serial))] = '\0';
found.push_back(std::make_shared<NeoVIFIRE2ETH>(foundDev.device));
break;
}
}
return found;
}
};
}
#endif
@@ -1,147 +0,0 @@
#ifndef __NEOVIFIRE2SETTINGS_H_
#define __NEOVIFIRE2SETTINGS_H_
#include <stdint.h>
#include "device/include/idevicesettings.h"
#ifdef __cplusplus
namespace icsneo {
#endif
#pragma pack(push, 2)
typedef struct {
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;
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;
CAN_SETTINGS lsftcan1;
CAN_SETTINGS lsftcan2;
LIN_SETTINGS lin1;
uint16_t misc_io_initial_ddr;
LIN_SETTINGS lin2;
uint16_t misc_io_initial_latch;
LIN_SETTINGS lin3;
uint16_t misc_io_report_period;
LIN_SETTINGS lin4;
uint16_t misc_io_on_report_events;
LIN_SETTINGS lin5;
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;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
uint16_t iso_parity_2;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_3;
uint16_t iso_parity_3;
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_4;
uint16_t iso_parity_4;
uint16_t iso_msg_termination_1;
uint16_t iso_msg_termination_2;
uint16_t iso_msg_termination_3;
uint16_t iso_msg_termination_4;
uint16_t idle_wakeup_network_enables_1;
uint16_t idle_wakeup_network_enables_2;
/* reserved for HSCAN6/7, LSFT2, etc.. */
uint16_t network_enables_3;
uint16_t idle_wakeup_network_enables_3;
uint16_t can_switch_mode;
STextAPISettings text_api;
uint64_t termination_enables;
LIN_SETTINGS lin6;
ETHERNET_SETTINGS ethernet;
uint16_t slaveVnetA;
uint16_t slaveVnetB;
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;
uint16_t digitalIoThresholdTicks;
uint16_t digitalIoThresholdEnable;
TIMESYNC_ICSHARDWARE_SETTINGS timeSync;
} neovifire2_settings_t;
#pragma pack(pop)
#ifdef __cplusplus
#include <iostream>
class NeoVIFIRE2Settings : public IDeviceSettings {
public:
NeoVIFIRE2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire2_settings_t)) {}
CAN_SETTINGS* getCANSettingsFor(Network net) override {
auto cfg = getStructurePointer<neovifire2_settings_t>();
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;
}
}
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
};
}
#endif // __cplusplus
#endif
-31
View File
@@ -1,31 +0,0 @@
#ifndef __NEOVIFIRE2USB_H_
#define __NEOVIFIRE2USB_H_
#include "device/neovifire2/include/neovifire2.h"
#include "platform/include/ftdi.h"
#include "device/neovifire2/include/neovifire2settings.h"
namespace icsneo {
class NeoVIFIRE2USB : public NeoVIFIRE2 {
public:
static constexpr const uint16_t PRODUCT_ID = 0x1000;
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
com = MakeCommunication(std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice())));
settings = std::unique_ptr<IDeviceSettings>(new NeoVIFIRE2Settings(com));
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<NeoVIFIRE2USB>(neodevice));
return found;
}
};
}
#endif
-31
View File
@@ -1,31 +0,0 @@
#ifndef __NEOVIION_H_
#define __NEOVIION_H_
#include "device/plasion/include/plasion.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class NeoVIION : public Plasion {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::ION;
static constexpr const uint16_t PRODUCT_ID = 0x0901;
NeoVIION(neodevice_t neodevice) : Plasion(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<NeoVIION>(neodevice));
return found;
}
};
}
#endif
-31
View File
@@ -1,31 +0,0 @@
#ifndef __NEOVIPLASMA_H_
#define __NEOVIPLASMA_H_
#include "device/plasion/include/plasion.h"
#include "device/include/devicetype.h"
#include "platform/include/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;
NeoVIPLASMA(neodevice_t neodevice) : Plasion(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<NeoVIPLASMA>(neodevice));
return found;
}
};
}
#endif
-23
View File
@@ -1,23 +0,0 @@
#ifndef __PLASION_H_
#define __PLASION_H_
#include "device/include/device.h"
#include "communication/include/multichannelcommunication.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class Plasion : public Device {
public:
Plasion(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<MultiChannelCommunication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
}
};
}
#endif
-72
View File
@@ -1,72 +0,0 @@
#ifndef __RADGALAXY_H_
#define __RADGALAXY_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/pcap.h"
#include "communication/include/packetizer.h"
#include "communication/include/decoder.h"
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::shared_ptr<Packetizer> MakePacketizer() {
auto packetizer = std::make_shared<Packetizer>();
packetizer->disableChecksum = true;
packetizer->align16bit = false;
return packetizer;
}
RADGalaxy(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new PCAP(getWritableNeoDevice()));
auto packetizer = MakePacketizer();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto& foundDev : PCAP::FindAll()) {
auto packetizer = MakePacketizer();
auto decoder = std::unique_ptr<Decoder>(new Decoder());
for(auto& payload : foundDev.discoveryPackets)
packetizer->input(payload);
for(auto& packet : packetizer->output()) {
std::shared_ptr<Message> msg;
if(!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 RADGalaxy
foundDev.device.serial[sn->deviceSerial.copy(foundDev.device.serial, sizeof(foundDev.device.serial))] = '\0';
found.push_back(std::make_shared<RADGalaxy>(foundDev.device));
break;
}
}
return found;
}
};
}
#endif
-23
View File
@@ -1,23 +0,0 @@
#ifndef __RADSTAR2_H_
#define __RADSTAR2_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
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";
RADStar2(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
};
}
#endif
-65
View File
@@ -1,65 +0,0 @@
#ifndef __RADSTAR2ETH_H_
#define __RADSTAR2ETH_H_
#include "device/radstar2/include/radstar2.h"
#include "communication/include/network.h"
#include "communication/message/include/serialnumbermessage.h"
#include "platform/include/pcap.h"
namespace icsneo {
class RADStar2ETH : public RADStar2 {
public:
static std::shared_ptr<Packetizer> MakePacketizer() {
auto packetizer = std::make_shared<Packetizer>();
packetizer->disableChecksum = true;
packetizer->align16bit = false;
return packetizer;
}
// Serial numbers start with RS
RADStar2ETH(neodevice_t neodevice) : RADStar2(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new PCAP(getWritableNeoDevice()));
auto packetizer = MakePacketizer();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto& foundDev : PCAP::FindAll()) {
auto packetizer = MakePacketizer();
auto decoder = std::unique_ptr<Decoder>(new Decoder());
for(auto& payload : foundDev.discoveryPackets)
packetizer->input(payload);
for(auto& packet : packetizer->output()) {
std::shared_ptr<Message> msg;
if(!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 RADStar2
foundDev.device.serial[sn->deviceSerial.copy(foundDev.device.serial, sizeof(foundDev.device.serial))] = '\0';
found.push_back(std::make_shared<RADStar2ETH>(foundDev.device));
break;
}
}
return found;
}
};
}
#endif
-32
View File
@@ -1,32 +0,0 @@
#ifndef __RADSTAR2USB_H_
#define __RADSTAR2USB_H_
#include "device/radstar2/include/radstar2.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class RADStar2USB : public RADStar2 {
public:
// Serial numbers start with RS
RADStar2USB(neodevice_t neodevice) : RADStar2(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<RADStar2USB>(neodevice));
return found;
}
};
}
#endif
@@ -1,38 +0,0 @@
#ifndef __RADSUPERMOON_H_
#define __RADSUPERMOON_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class RADSupermoon : public Device {
public:
// Serial numbers start with VV
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADSupermoon;
static constexpr const uint16_t PRODUCT_ID = 0x1201;
RADSupermoon(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
// RSM does not connect at all yet (needs FTDI D3xx driver, not the 2xx compatible one)
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<RADSupermoon>(neodevice));
return found;
}
};
}
#endif
-36
View File
@@ -1,36 +0,0 @@
#ifndef __VALUECAN3_H_
#define __VALUECAN3_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h"
namespace icsneo {
class ValueCAN3 : public Device {
public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN3;
static constexpr const uint16_t PRODUCT_ID = 0x0601;
ValueCAN3(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new FTDI(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : FTDI::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<ValueCAN3>(neodevice));
return found;
}
};
}
#endif
-35
View File
@@ -1,35 +0,0 @@
#ifndef __VALUECAN4_1_H_
#define __VALUECAN4_1_H_
#include "device/valuecan4/include/valuecan4.h"
#include "device/valuecan4/settings/include/valuecan4-1settings.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;
ValueCAN4_1(neodevice_t neodevice) : ValueCAN4(neodevice) {
com = MakeCommunication(getWritableNeoDevice());
com->encoder->supportCANFD = false; // VCAN 4-1 does not support CAN FD
settings = std::unique_ptr<IDeviceSettings>(new ValueCAN4_1Settings(com));
getWritableNeoDevice().type = DEVICE_TYPE;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == "V1")
found.push_back(std::make_shared<ValueCAN4_1>(neodevice));
}
return found;
}
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef __VALUECAN4_2_H_
#define __VALUECAN4_2_H_
#include "device/valuecan4/include/valuecan4.h"
#include "device/valuecan4/settings/include/valuecan4-2settings.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;
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
com = MakeCommunication(getWritableNeoDevice());
settings = std::unique_ptr<IDeviceSettings>(new ValueCAN4_2Settings(com));
getWritableNeoDevice().type = DEVICE_TYPE;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == "V2")
found.push_back(std::make_shared<ValueCAN4_2>(neodevice));
}
return found;
}
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef __VALUECAN4_2EL_H_
#define __VALUECAN4_2EL_H_
#include "device/valuecan4/include/valuecan4.h"
#include "device/valuecan4/settings/include/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;
ValueCAN4_2EL(neodevice_t neodevice) : ValueCAN4(neodevice) {
com = MakeCommunication(getWritableNeoDevice());
settings = std::unique_ptr<IDeviceSettings>(new ValueCAN4_2ELSettings(com));
getWritableNeoDevice().type = DEVICE_TYPE;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == "VE")
found.push_back(std::make_shared<ValueCAN4_2EL>(neodevice));
}
return found;
}
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef __VALUECAN4_4_H_
#define __VALUECAN4_4_H_
#include "device/valuecan4/include/valuecan4.h"
#include "device/valuecan4/settings/include/valuecan4-4settings.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;
ValueCAN4_4(neodevice_t neodevice) : ValueCAN4(neodevice) {
com = MakeCommunication(getWritableNeoDevice());
settings = std::unique_ptr<IDeviceSettings>(new ValueCAN4_4Settings(com));
getWritableNeoDevice().type = DEVICE_TYPE;
}
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
if(std::string(neodevice.serial).substr(0, 2) == "V4")
found.push_back(std::make_shared<ValueCAN4_4>(neodevice));
}
return found;
}
};
}
#endif
-30
View File
@@ -1,30 +0,0 @@
#ifndef __VALUECAN4_H_
#define __VALUECAN4_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.h"
namespace icsneo {
class ValueCAN4 : public Device {
public:
static constexpr const uint16_t PRODUCT_ID = 0x1101;
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {
productId = PRODUCT_ID;
}
protected:
static std::shared_ptr<Communication> MakeCommunication(neodevice_t& nd) {
auto transport = std::unique_ptr<ICommunication>(new STM32(nd));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
encoder->supportCANFD = true;
auto decoder = std::unique_ptr<Decoder>(new Decoder());
return std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
}
};
}
#endif
@@ -1,21 +0,0 @@
#ifndef __VALUECAN4_1_2_SETTINGS_H_
#define __VALUECAN4_1_2_SETTINGS_H_
#include "device/include/idevicesettings.h"
#include "device/valuecan4/settings/include/valuecan4settings.h"
#ifdef __cplusplus
namespace icsneo {
class ValueCAN4_1_2Settings : public IDeviceSettings {
public:
ValueCAN4_1_2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan4_1_2_settings_t)) {}
// We do not override getCANSettingsFor or getCANFDSettingsFor here because they will be device specific
};
}
#endif // __cplusplus
#endif
@@ -1,29 +0,0 @@
#ifndef __VALUECAN4_1_SETTINGS_H_
#define __VALUECAN4_1_SETTINGS_H_
#include "device/valuecan4/settings/include/valuecan4-1-2settings.h"
#ifdef __cplusplus
namespace icsneo {
class ValueCAN4_1Settings : public ValueCAN4_1_2Settings {
public:
ValueCAN4_1Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
CAN_SETTINGS* getCANSettingsFor(Network net) override {
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->can1);
default:
return nullptr;
}
}
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
};
}
#endif // __cplusplus
#endif
@@ -1,36 +0,0 @@
#ifndef __VALUECAN4_2EL_SETTINGS_H_
#define __VALUECAN4_2EL_SETTINGS_H_
#include "device/include/idevicesettings.h"
#include "device/valuecan4/settings/include/valuecan4-4-2elsettings.h"
#ifdef __cplusplus
namespace icsneo {
class ValueCAN4_2ELSettings : public ValueCAN4_4_2ELSettings {
public:
ValueCAN4_2ELSettings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
CAN_SETTINGS* getCANSettingsFor(Network net) override {
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->can1);
case Network::NetID::HSCAN2:
return &(cfg->can2);
case Network::NetID::HSCAN3:
return &(cfg->can3);
case Network::NetID::HSCAN4:
return &(cfg->can4);
default:
return nullptr;
}
}
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
};
}
#endif // __cplusplus
#endif
@@ -1,31 +0,0 @@
#ifndef __VALUECAN4_2_SETTINGS_H_
#define __VALUECAN4_2_SETTINGS_H_
#include "device/valuecan4/settings/include/valuecan4-1-2settings.h"
#ifdef __cplusplus
namespace icsneo {
class ValueCAN4_2Settings : public ValueCAN4_1_2Settings {
public:
ValueCAN4_2Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
CAN_SETTINGS* getCANSettingsFor(Network net) override {
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->can1);
case Network::NetID::HSCAN2:
return &(cfg->can2);
default:
return nullptr;
}
}
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
};
}
#endif // __cplusplus
#endif
@@ -1,21 +0,0 @@
#ifndef __VALUECAN4_4_2EL_SETTINGS_H_
#define __VALUECAN4_4_2EL_SETTINGS_H_
#include "device/include/idevicesettings.h"
#include "device/valuecan4/settings/include/valuecan4settings.h"
#ifdef __cplusplus
namespace icsneo {
class ValueCAN4_4_2ELSettings : public IDeviceSettings {
public:
ValueCAN4_4_2ELSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan4_4_2el_settings_t)) {}
// We do not override getCANSettingsFor, getCANFDSettingsFor, or getEthernetSettingsFor here because they will be device specific
};
}
#endif // __cplusplus
#endif
@@ -1,36 +0,0 @@
#ifndef __VALUECAN4_4_SETTINGS_H_
#define __VALUECAN4_4_SETTINGS_H_
#include "device/include/idevicesettings.h"
#include "device/valuecan4/settings/include/valuecan4-4-2elsettings.h"
#ifdef __cplusplus
namespace icsneo {
class ValueCAN4_4Settings : public ValueCAN4_4_2ELSettings {
public:
ValueCAN4_4Settings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
CAN_SETTINGS* getCANSettingsFor(Network net) override {
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
switch(net.getNetID()) {
case Network::NetID::HSCAN:
return &(cfg->can1);
case Network::NetID::HSCAN2:
return &(cfg->can2);
case Network::NetID::HSCAN3:
return &(cfg->can3);
case Network::NetID::HSCAN4:
return &(cfg->can4);
default:
return nullptr;
}
}
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
};
}
#endif // __cplusplus
#endif
@@ -1,86 +0,0 @@
#ifndef __VALUECAN4_SETTINGS_H_
#define __VALUECAN4_SETTINGS_H_
#include <stdint.h>
#include "device/include/idevicesettings.h"
#ifdef __cplusplus
namespace icsneo {
#endif
// This is where the actual settings structures for all the ValueCAN 4 line live
// ValueCAN 4-1 and 4-2 share a structure, and 4-4 shares with 4-2EL
#pragma pack(push, 2)
typedef struct {
/* Performance Test */
uint16_t perf_en;
CAN_SETTINGS can1;
CANFD_SETTINGS canfd1;
CAN_SETTINGS can2;
CANFD_SETTINGS canfd2;
uint64_t network_enables;
uint64_t termination_enables;
uint32_t pwr_man_timeout;
uint16_t pwr_man_enable;
uint16_t network_enabled_on_boot;
/* ISO15765-2 Transport Layer */
int16_t iso15765_separation_time_offset;
STextAPISettings text_api;
struct
{
uint32_t disableUsbCheckOnBoot : 1;
uint32_t enableLatencyTest : 1;
uint32_t reserved : 30;
} flags;
} valuecan4_1_2_settings_t, valuecan4_1_settings_t, valuecan4_2_settings_t;
typedef struct {
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;
uint16_t network_enables;
uint16_t network_enables_2;
LIN_SETTINGS lin1;
uint16_t network_enabled_on_boot;
int16_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 network_enables_3;
STextAPISettings text_api;
uint64_t termination_enables;
ETHERNET_SETTINGS ethernet;
struct
{
uint32_t enableLatencyTest : 1;
uint32_t enablePcEthernetComm : 1;
uint32_t reserved : 30;
} flags;
uint16_t pwr_man_enable;
uint16_t pwr_man_timeout;
} valuecan4_4_2el_settings_t, valuecan4_4_settings_t, valuecan4_2el_settings_t;
#pragma pack(pop)
#ifdef __cplusplus
} // End of namespace
#endif // __cplusplus
#endif
-39
View File
@@ -1,39 +0,0 @@
#ifndef __VIVIDCAN_H_
#define __VIVIDCAN_H_
#include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.h"
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;
VividCAN(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::unique_ptr<ICommunication>(new STM32(getWritableNeoDevice()));
auto packetizer = std::make_shared<Packetizer>();
auto encoder = std::unique_ptr<Encoder>(new Encoder(packetizer));
auto decoder = std::unique_ptr<Decoder>(new Decoder());
com = std::make_shared<Communication>(std::move(transport), packetizer, std::move(encoder), std::move(decoder));
getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID;
}
bool goOnline() { return false; }
static std::vector<std::shared_ptr<Device>> Find() {
std::vector<std::shared_ptr<Device>> found;
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
found.push_back(std::make_shared<VividCAN>(neodevice));
return found;
}
};
}
#endif