Implement DeviceType and icsneo_getProductName

pull/4/head
Paul Hollinsky 2018-09-26 20:43:49 -04:00
parent bbcc5b2d7b
commit 06b7181492
17 changed files with 83 additions and 43 deletions

View File

@ -201,4 +201,13 @@ bool icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit) {
device->device->setPollingMessageLimit(newLimit); device->device->setPollingMessageLimit(newLimit);
return true; return true;
}
bool icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLength) {
if(!icsneo_isValidNeoDevice(device))
return false;
*maxLength = device->device->getType().toString().copy(str, *maxLength);
str[*maxLength + 1] = '\0';
return true;
} }

View File

@ -12,7 +12,6 @@
extern "C" { extern "C" {
#endif #endif
extern void DLLExport icsneo_findAllDevices(neodevice_t* devices, size_t* count); extern void DLLExport icsneo_findAllDevices(neodevice_t* devices, size_t* count);
extern void DLLExport icsneo_freeUnconnectedDevices(); extern void DLLExport icsneo_freeUnconnectedDevices();
@ -43,6 +42,8 @@ extern size_t DLLExport icsneo_getPollingMessageLimit(const neodevice_t* device)
extern bool DLLExport icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit); extern bool DLLExport icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit);
extern bool DLLExport icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLength);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
@ -94,6 +95,9 @@ fn_icsneo_getPollingMessageLimit icsneo_getPollingMessageLimit;
typedef bool(*fn_icsneo_setPollingMessageLimit)(const neodevice_t* device, size_t newLimit); typedef bool(*fn_icsneo_setPollingMessageLimit)(const neodevice_t* device, size_t newLimit);
fn_icsneo_setPollingMessageLimit icsneo_setPollingMessageLimit; fn_icsneo_setPollingMessageLimit icsneo_setPollingMessageLimit;
typedef size_t(*fn_icsneo_getProductName)(const neodevice_t* device, char* str, size_t* maxLength);
fn_icsneo_getProductName icsneo_getProductName;
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func) #define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
#define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3 #define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3
void* icsneo_libraryHandle = NULL; void* icsneo_libraryHandle = NULL;
@ -123,6 +127,7 @@ int icsneo_init() {
ICSNEO_IMPORTASSERT(icsneo_getMessages); ICSNEO_IMPORTASSERT(icsneo_getMessages);
ICSNEO_IMPORTASSERT(icsneo_getPollingMessageLimit); ICSNEO_IMPORTASSERT(icsneo_getPollingMessageLimit);
ICSNEO_IMPORTASSERT(icsneo_setPollingMessageLimit); ICSNEO_IMPORTASSERT(icsneo_setPollingMessageLimit);
ICSNEO_IMPORTASSERT(icsneo_getProductName);
icsneo_initialized = true; icsneo_initialized = true;
return 0; return 0;

View File

@ -6,6 +6,7 @@
#include <cstring> #include <cstring>
#include "device/include/neodevice.h" #include "device/include/neodevice.h"
#include "device/include/idevicesettings.h" #include "device/include/idevicesettings.h"
#include "device/include/devicetype.h"
#include "communication/include/communication.h" #include "communication/include/communication.h"
#include "communication/include/packetizer.h" #include "communication/include/packetizer.h"
#include "communication/include/decoder.h" #include "communication/include/decoder.h"
@ -17,10 +18,9 @@ class Device {
public: public:
static constexpr const char* SERIAL_FIND_ON_OPEN = "xxxxxx"; static constexpr const char* SERIAL_FIND_ON_OPEN = "xxxxxx";
Device(neodevice_t neodevice = {}) { Device(neodevice_t neodevice = { 0 }) {
data = neodevice; data = neodevice;
data.device = this; data.device = this;
setProductName("undefined");
} }
virtual ~Device() { virtual ~Device() {
disableMessagePolling(); disableMessagePolling();
@ -31,7 +31,7 @@ public:
static uint32_t SerialStringToNum(const std::string& serial); static uint32_t SerialStringToNum(const std::string& serial);
static bool SerialStringIsNumeric(const std::string& serial); static bool SerialStringIsNumeric(const std::string& serial);
std::string getProductName() const { return data.type; } DeviceType getType() const { return DeviceType(data.type); }
uint16_t getProductId() const { return productId; } uint16_t getProductId() const { return productId; }
std::string getSerial() const { return data.serial; } std::string getSerial() const { return data.serial; }
uint32_t getSerialNumber() const { return Device::SerialStringToNum(getSerial()); } uint32_t getSerialNumber() const { return Device::SerialStringToNum(getSerial()); }
@ -64,11 +64,6 @@ protected:
std::shared_ptr<Communication> com; std::shared_ptr<Communication> com;
neodevice_t& getWritableNeoDevice() { return data; } neodevice_t& getWritableNeoDevice() { return data; }
void setProductName(const std::string& newName) {
#pragma warning( disable : 4996 )
auto copied = newName.copy(data.type, sizeof(data.type) - 1);
data.type[copied] = '\0';
}
private: private:
neodevice_t data; neodevice_t data;

View File

@ -1,15 +1,24 @@
#ifndef __DEVICETYPE_H_ #ifndef __DEVICETYPE_H_
#define __DEVICETYPE_H_ #define __DEVICETYPE_H_
#include <cstdint> typedef uint32_t devicetype_t;
// 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>
#else
#include <ostream> #include <ostream>
#include <cstdint>
namespace icsneo { namespace icsneo {
class DeviceType { class DeviceType {
public: public:
// This enum used to be a bitfield, but has since become an enum as we have more than 32 devices // This enum used to be a bitfield, but has since become an enum as we have more than 32 devices
enum Enum : uint32_t { enum Enum : devicetype_t {
Unknown = (0x00000000), Unknown = (0x00000000),
BLUE = (0x00000001), BLUE = (0x00000001),
ECU_AVB = (0x00000002), ECU_AVB = (0x00000002),
@ -51,6 +60,7 @@ public:
OBD2_SIM = (0x80000000) OBD2_SIM = (0x80000000)
}; };
static const char* GetDeviceTypeString(DeviceType::Enum type) { static const char* GetDeviceTypeString(DeviceType::Enum type) {
// Adding something? Make sure you update DEVICE_TYPE_LONGEST_NAME at the top!
switch(type) { switch(type) {
case Unknown: case Unknown:
return "Unknown"; return "Unknown";
@ -63,7 +73,7 @@ public:
case DW_VCAN: case DW_VCAN:
return "DW_VCAN"; return "DW_VCAN";
case RADMoon2: case RADMoon2:
return "RADMoon2"; return "RADMoon 2";
case RADGigalog: case RADGigalog:
return "RADGigalog"; return "RADGigalog";
case VCAN4_1: case VCAN4_1:
@ -87,7 +97,7 @@ public:
case Pendant: case Pendant:
return "Pendant"; return "Pendant";
case OBD2_PRO: case OBD2_PRO:
return "neoOBD2-PRO"; return "neoOBD2 PRO";
case ECUChip_UART: case ECUChip_UART:
return "neoECU Chip UART"; return "neoECU Chip UART";
case PLASMA: case PLASMA:
@ -97,7 +107,7 @@ public:
case CT_OBD: case CT_OBD:
return "CT_OBD"; return "CT_OBD";
case ION: case ION:
return "ION"; return "neoVI ION";
case RADStar: case RADStar:
return "RADStar"; return "RADStar";
case VCAN4_4: case VCAN4_4:
@ -117,7 +127,7 @@ public:
case RADGalaxy: case RADGalaxy:
return "RADGalaxy"; return "RADGalaxy";
case RADStar2: case RADStar2:
return "RADStar2"; return "RADStar 2";
case VividCAN: case VividCAN:
return "VividCAN"; return "VividCAN";
case OBD2_SIM: case OBD2_SIM:
@ -129,14 +139,16 @@ public:
// Intentionally don't use default so that the compiler throws a warning when something is added // Intentionally don't use default so that the compiler throws a warning when something is added
return "Unknown neoVI"; return "Unknown neoVI";
} }
return "Unknown neoVI";
} }
DeviceType() { value = DeviceType::Enum::Unknown; } DeviceType() { value = DeviceType::Enum::Unknown; }
DeviceType(uint32_t netid) { value = (DeviceType::Enum)netid; } DeviceType(devicetype_t netid) { value = (DeviceType::Enum)netid; }
DeviceType(DeviceType::Enum netid) { value = netid; } DeviceType(DeviceType::Enum netid) { value = netid; }
DeviceType::Enum getDeviceType() const { return value; } DeviceType::Enum getDeviceType() const { return value; }
std::string toString() const { return GetDeviceTypeString(getDeviceType()); }
friend std::ostream& operator<<(std::ostream& os, const DeviceType& DeviceType) { friend std::ostream& operator<<(std::ostream& os, const DeviceType& DeviceType) {
os << GetDeviceTypeString(DeviceType.getDeviceType()); os << DeviceType.toString();
return os; return os;
} }
@ -144,6 +156,8 @@ private:
DeviceType::Enum value; DeviceType::Enum value;
}; };
}; }
#endif // __cplusplus
#endif #endif

View File

@ -2,6 +2,7 @@
#define __NEODEVICE_H_ #define __NEODEVICE_H_
#include <stdint.h> #include <stdint.h>
#include "device/include/devicetype.h"
#ifdef __cplusplus #ifdef __cplusplus
// A forward declaration is needed as there is a circular dependency // A forward declaration is needed as there is a circular dependency
@ -17,11 +18,15 @@ typedef void* devicehandle_t;
typedef int32_t neodevice_handle_t; typedef int32_t neodevice_handle_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
devicehandle_t device; devicehandle_t device;
neodevice_handle_t handle; neodevice_handle_t handle;
devicetype_t type;
char serial[7]; char serial[7];
char type[64];
} neodevice_t; } neodevice_t;
#pragma pack(pop)
#endif #endif

View File

@ -2,6 +2,7 @@
#define __NEOOBD2PRO_H_ #define __NEOOBD2PRO_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.h" #include "platform/include/stm32.h"
namespace icsneo { namespace icsneo {
@ -9,14 +10,14 @@ namespace icsneo {
class NeoOBD2PRO : public Device { class NeoOBD2PRO : public Device {
public: public:
// Serial numbers are NP**** // Serial numbers are NP****
static constexpr const char* PRODUCT_NAME = "neoOBD2 PRO"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::OBD2_PRO;
static constexpr const uint16_t PRODUCT_ID = 0x1103; static constexpr const uint16_t PRODUCT_ID = 0x1103;
NeoOBD2PRO(neodevice_t neodevice) : Device(neodevice) { NeoOBD2PRO(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<STM32>(getWritableNeoDevice()); auto transport = std::make_shared<STM32>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,6 +2,7 @@
#define __NEOOBD2SIM_H_ #define __NEOOBD2SIM_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.h" #include "platform/include/stm32.h"
namespace icsneo { namespace icsneo {
@ -9,14 +10,14 @@ namespace icsneo {
class NeoOBD2SIM : public Device { class NeoOBD2SIM : public Device {
public: public:
// Serial numbers are OS**** // Serial numbers are OS****
static constexpr const char* PRODUCT_NAME = "neoOBD2-SIM"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::OBD2_SIM;
static constexpr const uint16_t PRODUCT_ID = 0x1100; static constexpr const uint16_t PRODUCT_ID = 0x1100;
NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) { NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<STM32>(getWritableNeoDevice()); auto transport = std::make_shared<STM32>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,20 +2,21 @@
#define __NEOVIFIRE_H_ #define __NEOVIFIRE_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
class NeoVIFIRE : public Device { class NeoVIFIRE : public Device {
public: public:
static constexpr const char* PRODUCT_NAME = "neoVI FIRE"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE;
static constexpr const uint16_t PRODUCT_ID = 0x0701; static constexpr const uint16_t PRODUCT_ID = 0x0701;
NeoVIFIRE(neodevice_t neodevice) : Device(neodevice) { NeoVIFIRE(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<FTDI>(getWritableNeoDevice()); auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,15 +2,16 @@
#define __NEOVIFIRE2_H_ #define __NEOVIFIRE2_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
class NeoVIFIRE2 : public Device { class NeoVIFIRE2 : public Device {
public: public:
static constexpr const char* PRODUCT_NAME = "neoVI FIRE 2"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::FIRE2;
NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) { NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) {
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
} }
}; };

View File

@ -2,16 +2,17 @@
#define __NEOVIION_H_ #define __NEOVIION_H_
#include "device/plasion/include/plasion.h" #include "device/plasion/include/plasion.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
class NeoVIION : public Plasion { class NeoVIION : public Plasion {
public: public:
static constexpr const char* PRODUCT_NAME = "neoVI ION"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::ION;
static constexpr const uint16_t PRODUCT_ID = 0x0901; static constexpr const uint16_t PRODUCT_ID = 0x0901;
NeoVIION(neodevice_t neodevice) : Plasion(neodevice) { NeoVIION(neodevice_t neodevice) : Plasion(neodevice) {
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,16 +2,17 @@
#define __NEOVIPLASMA_H_ #define __NEOVIPLASMA_H_
#include "device/plasion/include/plasion.h" #include "device/plasion/include/plasion.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
class NeoVIPLASMA : public Plasion { class NeoVIPLASMA : public Plasion {
public: public:
static constexpr const char* PRODUCT_NAME = "neoVI PLASMA"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::PLASMA;
static constexpr const uint16_t PRODUCT_ID = 0x0801; static constexpr const uint16_t PRODUCT_ID = 0x0801;
NeoVIPLASMA(neodevice_t neodevice) : Plasion(neodevice) { NeoVIPLASMA(neodevice_t neodevice) : Plasion(neodevice) {
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,6 +2,7 @@
#define __RADGALAXY_H_ #define __RADGALAXY_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/pcap.h" #include "platform/include/pcap.h"
#include "communication/include/packetizer.h" #include "communication/include/packetizer.h"
#include "communication/include/decoder.h" #include "communication/include/decoder.h"
@ -11,7 +12,7 @@ namespace icsneo {
class RADGalaxy : public Device { class RADGalaxy : public Device {
public: public:
// Serial numbers start with RG // Serial numbers start with RG
static constexpr const char* PRODUCT_NAME = "RADGalaxy"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADGalaxy;
static constexpr const uint16_t PRODUCT_ID = 0x0003; static constexpr const uint16_t PRODUCT_ID = 0x0003;
RADGalaxy(neodevice_t neodevice) : Device(neodevice) { RADGalaxy(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<PCAP>(getWritableNeoDevice()); auto transport = std::make_shared<PCAP>(getWritableNeoDevice());
@ -20,7 +21,7 @@ public:
packetizer->align16bit = false; packetizer->align16bit = false;
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,6 +2,7 @@
#define __RADSTAR2_H_ #define __RADSTAR2_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
@ -9,14 +10,14 @@ namespace icsneo {
class RADStar2 : public Device { class RADStar2 : public Device {
public: public:
// Serial numbers start with RS // Serial numbers start with RS
static constexpr const char* PRODUCT_NAME = "RADStar 2"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADStar2;
static constexpr const uint16_t PRODUCT_ID = 0x0005; static constexpr const uint16_t PRODUCT_ID = 0x0005;
RADStar2(neodevice_t neodevice) : Device(neodevice) { RADStar2(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<FTDI>(getWritableNeoDevice()); auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,6 +2,7 @@
#define __RADSUPERMOON_H_ #define __RADSUPERMOON_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
@ -9,7 +10,7 @@ namespace icsneo {
class RADSupermoon : public Device { class RADSupermoon : public Device {
public: public:
// Serial numbers start with VV // Serial numbers start with VV
static constexpr const char* PRODUCT_NAME = "RADSupermoon"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADSupermoon;
static constexpr const uint16_t PRODUCT_ID = 0x1201; static constexpr const uint16_t PRODUCT_ID = 0x1201;
RADSupermoon(neodevice_t neodevice) : Device(neodevice) { RADSupermoon(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<FTDI>(getWritableNeoDevice()); auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
@ -18,7 +19,7 @@ public:
packetizer->align16bit = false; packetizer->align16bit = false;
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }
// RSM does not connect at all yet (needs FTDI D3xx driver, not the 2xx compatible one) // RSM does not connect at all yet (needs FTDI D3xx driver, not the 2xx compatible one)

View File

@ -2,20 +2,21 @@
#define __VALUECAN3_H_ #define __VALUECAN3_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/ftdi.h" #include "platform/include/ftdi.h"
namespace icsneo { namespace icsneo {
class ValueCAN3 : public Device { class ValueCAN3 : public Device {
public: public:
static constexpr const char* PRODUCT_NAME = "ValueCAN 3"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN3;
static constexpr const uint16_t PRODUCT_ID = 0x0601; static constexpr const uint16_t PRODUCT_ID = 0x0601;
ValueCAN3(neodevice_t neodevice) : Device(neodevice) { ValueCAN3(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<FTDI>(getWritableNeoDevice()); auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,6 +2,7 @@
#define __VALUECAN4_H_ #define __VALUECAN4_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.h" #include "platform/include/stm32.h"
namespace icsneo { namespace icsneo {
@ -9,14 +10,14 @@ namespace icsneo {
class ValueCAN4 : public Device { class ValueCAN4 : public Device {
public: public:
// Serial numbers are V0 for 4-4, VE for 4-2EL, V2 for 4-2, and V1 for 4-1 // Serial numbers are V0 for 4-4, VE for 4-2EL, V2 for 4-2, and V1 for 4-1
static constexpr const char* PRODUCT_NAME = "ValueCAN 4"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2; // TODO Split headers and determine the correct type
static constexpr const uint16_t PRODUCT_ID = 0x1101; static constexpr const uint16_t PRODUCT_ID = 0x1101;
ValueCAN4(neodevice_t neodevice) : Device(neodevice) { ValueCAN4(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<STM32>(getWritableNeoDevice()); auto transport = std::make_shared<STM32>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }

View File

@ -2,6 +2,7 @@
#define __VIVIDCAN_H_ #define __VIVIDCAN_H_
#include "device/include/device.h" #include "device/include/device.h"
#include "device/include/devicetype.h"
#include "platform/include/stm32.h" #include "platform/include/stm32.h"
namespace icsneo { namespace icsneo {
@ -9,14 +10,14 @@ namespace icsneo {
class VividCAN : public Device { class VividCAN : public Device {
public: public:
// Serial numbers start with VV // Serial numbers start with VV
static constexpr const char* PRODUCT_NAME = "VividCAN"; static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VividCAN;
static constexpr const uint16_t PRODUCT_ID = 0x1102; static constexpr const uint16_t PRODUCT_ID = 0x1102;
VividCAN(neodevice_t neodevice) : Device(neodevice) { VividCAN(neodevice_t neodevice) : Device(neodevice) {
auto transport = std::make_shared<STM32>(getWritableNeoDevice()); auto transport = std::make_shared<STM32>(getWritableNeoDevice());
auto packetizer = std::make_shared<Packetizer>(); auto packetizer = std::make_shared<Packetizer>();
auto decoder = std::make_shared<Decoder>(); auto decoder = std::make_shared<Decoder>();
com = std::make_shared<Communication>(transport, packetizer, decoder); com = std::make_shared<Communication>(transport, packetizer, decoder);
setProductName(PRODUCT_NAME); getWritableNeoDevice().type = DEVICE_TYPE;
productId = PRODUCT_ID; productId = PRODUCT_ID;
} }