ValueCAN 4-2EL: Add communication over Ethernet
The device can communicate with the PC over its Ethernet if the enablePcEthernetComm setting is set within the structure. This stops the Ethernet port from being used for vehicle data.pull/32/head
parent
d2676afa11
commit
8843ace87e
|
|
@ -94,8 +94,12 @@ static std::vector<DeviceType> supportedDevices = {
|
||||||
ValueCAN4_2::DEVICE_TYPE,
|
ValueCAN4_2::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN4_2EL_H_
|
#ifdef __VALUECAN4_2EL_ETH_H_
|
||||||
ValueCAN4_2EL::DEVICE_TYPE,
|
ValueCAN4_2EL_ETH::DEVICE_TYPE,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __VALUECAN4_2EL_USB_H_
|
||||||
|
ValueCAN4_2EL_USB::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN4_4_H_
|
#ifdef __VALUECAN4_4_H_
|
||||||
|
|
@ -204,8 +208,12 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
||||||
findResults.push_back(ValueCAN4_2::Find());
|
findResults.push_back(ValueCAN4_2::Find());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN4_2EL_H_
|
#ifdef __VALUECAN4_2EL_ETH_H_
|
||||||
findResults.push_back(ValueCAN4_2EL::Find());
|
findResults.push_back(ValueCAN4_2EL_ETH::Find(pcapDevices));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __VALUECAN4_2EL_USB_H_
|
||||||
|
findResults.push_back(ValueCAN4_2EL_USB::Find());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __VALUECAN4_4_H_
|
#ifdef __VALUECAN4_4_H_
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1settings.h"
|
||||||
|
#include "icsneo/platform/stm32.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -13,11 +14,13 @@ class ValueCAN4_1 : public ValueCAN4 {
|
||||||
public:
|
public:
|
||||||
// Serial numbers start with V1 for 4-1
|
// Serial numbers start with V1 for 4-1
|
||||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_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() {
|
static std::vector<std::shared_ptr<Device>> Find() {
|
||||||
std::vector<std::shared_ptr<Device>> found;
|
std::vector<std::shared_ptr<Device>> found;
|
||||||
|
|
||||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
|
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||||
if(std::string(neodevice.serial).substr(0, 2) == "V1")
|
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||||
found.emplace_back(new ValueCAN4_1(neodevice));
|
found.emplace_back(new ValueCAN4_1(neodevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,6 +52,7 @@ private:
|
||||||
ValueCAN4_1(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
ValueCAN4_1(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||||
initialize<STM32, ValueCAN4_1Settings>();
|
initialize<STM32, ValueCAN4_1Settings>();
|
||||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||||
|
productId = USB_PRODUCT_ID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2settings.h"
|
||||||
|
#include "icsneo/platform/stm32.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -13,11 +14,13 @@ class ValueCAN4_2 : public ValueCAN4 {
|
||||||
public:
|
public:
|
||||||
// Serial numbers start with V2 for 4-2
|
// Serial numbers start with V2 for 4-2
|
||||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2;
|
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2;
|
||||||
|
static constexpr const char* SERIAL_START = "V2";
|
||||||
|
|
||||||
static std::vector<std::shared_ptr<Device>> Find() {
|
static std::vector<std::shared_ptr<Device>> Find() {
|
||||||
std::vector<std::shared_ptr<Device>> found;
|
std::vector<std::shared_ptr<Device>> found;
|
||||||
|
|
||||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
|
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||||
if(std::string(neodevice.serial).substr(0, 2) == "V2")
|
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||||
found.emplace_back(new ValueCAN4_2(neodevice));
|
found.emplace_back(new ValueCAN4_2(neodevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,6 +48,7 @@ private:
|
||||||
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||||
initialize<STM32, ValueCAN4_2Settings>();
|
initialize<STM32, ValueCAN4_2Settings>();
|
||||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||||
|
productId = USB_PRODUCT_ID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,39 +13,10 @@ class ValueCAN4_2EL : public ValueCAN4 {
|
||||||
public:
|
public:
|
||||||
// Serial numbers start with VE for 4-2EL
|
// Serial numbers start with VE for 4-2EL
|
||||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2EL;
|
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_2EL;
|
||||||
static std::vector<std::shared_ptr<Device>> Find() {
|
static constexpr const char* SERIAL_START = "VE";
|
||||||
std::vector<std::shared_ptr<Device>> found;
|
|
||||||
|
|
||||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
|
|
||||||
if(std::string(neodevice.serial).substr(0, 2) == "VE")
|
|
||||||
found.emplace_back(new ValueCAN4_2EL(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:
|
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:
|
|
||||||
ValueCAN4_2EL(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
ValueCAN4_2EL(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||||
initialize<STM32, ValueCAN4_2ELSettings>();
|
|
||||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
#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->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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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:
|
||||||
|
ValueCAN4_2EL_ETH(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) {
|
||||||
|
initialize<STM32, ValueCAN4_2ELSettings>();
|
||||||
|
productId = ETH_PRODUCT_ID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
#ifndef __VALUECAN4_2EL_USB_H_
|
||||||
|
#define __VALUECAN4_2EL_USB_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
|
||||||
|
#include "icsneo/platform/stm32.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 : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||||
|
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||||
|
found.emplace_back(new ValueCAN4_2EL_USB(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:
|
||||||
|
ValueCAN4_2EL_USB(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) {
|
||||||
|
initialize<STM32, ValueCAN4_2ELSettings>();
|
||||||
|
productId = USB_PRODUCT_ID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||||
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h"
|
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h"
|
||||||
|
#include "icsneo/platform/stm32.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -13,11 +14,13 @@ class ValueCAN4_4 : public ValueCAN4 {
|
||||||
public:
|
public:
|
||||||
// Serial numbers start with V4 for 4-4
|
// Serial numbers start with V4 for 4-4
|
||||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_4;
|
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::VCAN4_4;
|
||||||
|
static constexpr const char* SERIAL_START = "V4";
|
||||||
|
|
||||||
static std::vector<std::shared_ptr<Device>> Find() {
|
static std::vector<std::shared_ptr<Device>> Find() {
|
||||||
std::vector<std::shared_ptr<Device>> found;
|
std::vector<std::shared_ptr<Device>> found;
|
||||||
|
|
||||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID)) {
|
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||||
if(std::string(neodevice.serial).substr(0, 2) == "V4")
|
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||||
found.emplace_back(new ValueCAN4_4(neodevice));
|
found.emplace_back(new ValueCAN4_4(neodevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,6 +50,7 @@ private:
|
||||||
ValueCAN4_4(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
ValueCAN4_4(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||||
initialize<STM32, ValueCAN4_4Settings>();
|
initialize<STM32, ValueCAN4_4Settings>();
|
||||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||||
|
productId = USB_PRODUCT_ID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
#include "icsneo/device/devicetype.h"
|
#include "icsneo/device/devicetype.h"
|
||||||
#include "icsneo/platform/stm32.h"
|
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class ValueCAN4 : public Device {
|
class ValueCAN4 : public Device {
|
||||||
public:
|
public:
|
||||||
static constexpr const uint16_t PRODUCT_ID = 0x1101;
|
// All ValueCAN 4 devices share a USB PID
|
||||||
|
static constexpr const uint16_t USB_PRODUCT_ID = 0x1101;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setupEncoder(Encoder& encoder) override {
|
virtual void setupEncoder(Encoder& encoder) override {
|
||||||
|
|
@ -19,9 +19,7 @@ protected:
|
||||||
encoder.supportCANFD = true;
|
encoder.supportCANFD = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {
|
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {}
|
||||||
productId = PRODUCT_ID;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@
|
||||||
#include "icsneo/device/tree/valuecan3/valuecan3.h"
|
#include "icsneo/device/tree/valuecan3/valuecan3.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-1.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-1.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-2.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2eleth.h"
|
||||||
|
#include "icsneo/device/tree/valuecan4/valuecan4-2elusb.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-4.h"
|
||||||
#include "icsneo/device/tree/vividcan/vividcan.h"
|
#include "icsneo/device/tree/vividcan/vividcan.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@
|
||||||
#include "icsneo/device/tree/valuecan3/valuecan3.h"
|
#include "icsneo/device/tree/valuecan3/valuecan3.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-1.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-1.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-2.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-2eleth.h"
|
||||||
|
#include "icsneo/device/tree/valuecan4/valuecan4-2elusb.h"
|
||||||
#include "icsneo/device/tree/valuecan4/valuecan4-4.h"
|
#include "icsneo/device/tree/valuecan4/valuecan4-4.h"
|
||||||
#include "icsneo/device/tree/vividcan/vividcan.h"
|
#include "icsneo/device/tree/vividcan/vividcan.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue