Ethernet (DoIP) Activation Line support

This commit is contained in:
Paul Hollinsky
2021-04-06 22:50:25 -04:00
parent 4e245db94e
commit a6c8acd8e9
28 changed files with 613 additions and 15 deletions
+50
View File
@@ -18,10 +18,12 @@
#include "icsneo/communication/packetizer.h"
#include "icsneo/communication/encoder.h"
#include "icsneo/communication/decoder.h"
#include "icsneo/communication/io.h"
#include "icsneo/communication/message/resetstatusmessage.h"
#include "icsneo/device/extensions/flexray/controller.h"
#include "icsneo/communication/message/flexray/control/flexraycontrolmessage.h"
#include "icsneo/third-party/concurrentqueue/concurrentqueue.h"
#include "icsneo/platform/optional.h"
namespace icsneo {
@@ -86,6 +88,48 @@ public:
virtual size_t getNetworkCountByType(Network::Type) const;
virtual Network getNetworkByNumber(Network::Type, size_t) const;
/**
* Retrieve the number of Ethernet (DoIP) Activation lines present
* on this device.
*/
virtual size_t getEthernetActivationLineCount() const { return 0; }
/**
* Retrieve the number of power-controlled USB Host ports present
* on this device.
*/
virtual size_t getUSBHostPowerCount() const { return 0; }
/**
* Tell whether the current device supports controlling a backup
* power source through the API.
*/
virtual bool getBackupPowerSupported() const { return false; }
/**
* Get the value of a digital IO, returning an empty optional if the
* value is not present, the specified IO is not valid for this device,
* or if an error occurs.
*
* The index number starts counting at 1 to keep the numbers in sync
* with the numbering on the device, and is set to 1 by default.
*/
optional<bool> getDigitalIO(IO type, size_t number = 1);
/**
* Set a digital IO to either a 1, if value is true, or 0 otherwise.
*
* The index number starts counting at 1 to keep the numbers in sync
* with the numbering on the device.
*/
bool setDigitalIO(IO type, size_t number, bool value);
/**
* Set the first digital IO of a given type to either a 1, if value
* is true, or 0 otherwise.
*/
bool setDigitalIO(IO type, bool value) { return setDigitalIO(type, 1, value); }
virtual std::vector<std::shared_ptr<FlexRay::Controller>> getFlexRayControllers() const { return {}; }
const device_eventhandler_t& getEventHandler() const { return report; }
@@ -99,6 +143,10 @@ protected:
int messagePollingCallbackID = 0;
int internalHandlerCallbackID = 0;
device_eventhandler_t report;
optional<bool> ethActivationStatus;
optional<bool> usbHostPowerStatus;
optional<bool> backupPowerEnabled;
optional<bool> backupPowerGood;
// START Initialization Functions
Device(neodevice_t neodevice = { 0 }) {
@@ -185,6 +233,8 @@ protected:
void handleInternalMessage(std::shared_ptr<Message> message);
virtual void handleDeviceStatus(const std::shared_ptr<Message>& message) {}
neodevice_t& getWritableNeoDevice() { return data; }
private:
+29 -6
View File
@@ -47,11 +47,28 @@ enum
enum OPEthLinkMode
{
OPETH_LINK_INVALID = -1,
OPETH_LINK_AUTO = 0,
OPETH_LINK_MASTER,
OPETH_LINK_SLAVE
};
enum EthLinkSpeed
{
ETH_SPEED_10 = 0,
ETH_SPEED_100,
ETH_SPEED_1000,
};
typedef struct
{
uint16_t networkId;
uint8_t linkStatus;
uint8_t linkFullDuplex;
uint8_t linkSpeed; // see EthLinkSpeed
int8_t linkMode; // for automotive networks - see OPEthLinkMode
} EthernetNetworkStatus;
typedef struct
{
uint8_t Mode;
@@ -553,6 +570,12 @@ typedef struct _UART_SETTINGS
#define UART_SETTINGS_SIZE 16
static_assert(sizeof(UART_SETTINGS) == UART_SETTINGS_SIZE, "UART_SETTINGS is the wrong size!");
typedef struct {
uint8_t ethernetActivationLineEnabled;
EthernetNetworkStatus ethernetStatus;
uint8_t unused;
} fire2vnet_status_t, flexray_vnetz_status_t;
#pragma pack(pop)
#ifdef __cplusplus
@@ -592,7 +615,7 @@ public:
const uint8_t* offset = (const uint8_t*)getCANSettingsFor(net);
if(offset == nullptr)
return nullptr;
return static_cast<CAN_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
return reinterpret_cast<CAN_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
}
virtual const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const { (void)net; return nullptr; }
@@ -602,7 +625,7 @@ public:
const uint8_t* offset = (const uint8_t*)getCANFDSettingsFor(net);
if(offset == nullptr)
return nullptr;
return static_cast<CANFD_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
return reinterpret_cast<CANFD_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
}
virtual const CAN_SETTINGS* getLSFTCANSettingsFor(Network net) const { (void)net; return nullptr; }
@@ -612,7 +635,7 @@ public:
const uint8_t* offset = (const uint8_t*)getLSFTCANSettingsFor(net);
if(offset == nullptr)
return nullptr;
return static_cast<CAN_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
return reinterpret_cast<CAN_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
}
virtual const SWCAN_SETTINGS* getSWCANSettingsFor(Network net) const { (void)net; return nullptr; }
@@ -622,13 +645,13 @@ public:
const uint8_t* offset = (const uint8_t*)getSWCANSettingsFor(net);
if(offset == nullptr)
return nullptr;
return static_cast<SWCAN_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
return reinterpret_cast<SWCAN_SETTINGS*>((void*)(settings.data() + (offset - settingsInDeviceRAM.data())));
}
const void* getRawStructurePointer() const { return settingsInDeviceRAM.data(); }
void* getMutableRawStructurePointer() { return settings.data(); }
template<typename T> const T* getStructurePointer() const { return static_cast<const T*>(getRawStructurePointer()); }
template<typename T> T* getMutableStructurePointer() { return static_cast<T*>(getMutableRawStructurePointer()); }
template<typename T> const T* getStructurePointer() const { return reinterpret_cast<const T*>(getRawStructurePointer()); }
template<typename T> T* getMutableStructurePointer() { return reinterpret_cast<T*>(getMutableRawStructurePointer()); }
template<typename T> T getStructure() const { return *getStructurePointer<T>(); }
template<typename T> bool applyStructure(const T& newStructure);
@@ -6,6 +6,7 @@
#include "icsneo/device/device.h"
#include "icsneo/device/devicetype.h"
#include "icsneo/platform/ftdi.h"
#include "icsneo/device/tree/neovifire2/neovifire2settings.h"
namespace icsneo {
@@ -46,6 +47,10 @@ public:
return supportedNetworks;
}
size_t getEthernetActivationLineCount() const override { return 1; }
size_t getUSBHostPowerCount() const override { return 1; }
bool getBackupPowerSupported() const override { return true; }
protected:
NeoVIFIRE2(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
@@ -63,6 +68,16 @@ protected:
// 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 handleDeviceStatus(const std::shared_ptr<Message>& message) override {
if(!message || message->data.size() < sizeof(neovifire2_status_t))
return;
const neovifire2_status_t* status = reinterpret_cast<const neovifire2_status_t*>(message->data.data());
backupPowerEnabled = status->backupPowerEnabled;
backupPowerGood = status->backupPowerGood;
ethActivationStatus = status->ethernetActivationLineEnabled;
usbHostPowerStatus = status->usbHostPowerEnabled;
}
};
}
@@ -5,7 +5,6 @@
#include "icsneo/device/tree/neovifire2/neovifire2.h"
#include "icsneo/platform/pcap.h"
#include "icsneo/device/tree/neovifire2/neovifire2settings.h"
#include <memory>
namespace icsneo {
@@ -106,6 +106,14 @@ typedef struct {
TIMESYNC_ICSHARDWARE_SETTINGS timeSync;
DISK_SETTINGS disk;
} neovifire2_settings_t;
typedef struct {
uint8_t backupPowerGood;
uint8_t backupPowerEnabled;
uint8_t usbHostPowerEnabled;
uint8_t ethernetActivationLineEnabled;
EthernetNetworkStatus ethernetStatus;
} neovifire2_status_t;
#pragma pack(pop)
#ifdef __cplusplus
@@ -5,7 +5,6 @@
#include "icsneo/device/tree/neovifire2/neovifire2.h"
#include "icsneo/platform/ftdi.h"
#include "icsneo/device/tree/neovifire2/neovifire2settings.h"
namespace icsneo {
@@ -41,6 +41,9 @@ public:
return supportedNetworks;
}
// Until VNET support is added, assume we have one FIRE 2 VNET or FlexRay VNETZ as the main
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
virtual std::shared_ptr<Communication> makeCommunication(
std::unique_ptr<Driver> transport,
@@ -92,6 +95,13 @@ protected:
return ret;
}
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
if(!message || message->data.size() < sizeof(fire2vnet_status_t))
return;
const fire2vnet_status_t* status = reinterpret_cast<const fire2vnet_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
public:
Plasion(neodevice_t neodevice) : Device(neodevice) {}
};
@@ -91,6 +91,8 @@ public:
productId = PRODUCT_ID;
}
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
void setupPacketizer(Packetizer& packetizer) override {
Device::setupPacketizer(packetizer);
@@ -115,6 +117,13 @@ protected:
// The supported TX networks are the same as the supported RX networks for this device
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
if(!message || message->data.size() < sizeof(radgalaxy_status_t))
return;
const radgalaxy_status_t* status = reinterpret_cast<const radgalaxy_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
};
}
@@ -87,6 +87,11 @@ typedef struct {
DISK_SETTINGS disk;
LOGGER_SETTINGS logger;
} radgalaxy_settings_t;
typedef struct {
uint8_t unused[3];
uint8_t ethernetActivationLineEnabled;
} radgalaxy_status_t;
#pragma pack(pop)
#ifdef __cplusplus
@@ -14,6 +14,8 @@ public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADGigalog;
static constexpr const char* SERIAL_START = "GL";
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
RADGigalog(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
@@ -74,6 +76,13 @@ protected:
};
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
}
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
if(!message || message->data.size() < sizeof(radgigalog_status_t))
return;
const radgigalog_status_t* status = reinterpret_cast<const radgigalog_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
};
}
@@ -86,6 +86,11 @@ typedef struct {
uint16_t network_enables_4;
RAD_REPORTING_SETTINGS reporting;
} radgigalog_settings_t;
typedef struct {
uint8_t unused[3];
uint8_t ethernetActivationLineEnabled;
} radgigalog_status_t;
#pragma pack(pop)
#ifdef __cplusplus
@@ -14,6 +14,8 @@ public:
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADGigastar;
static constexpr const char* SERIAL_START = "GS";
size_t getEthernetActivationLineCount() const override { return 1; }
protected:
RADGigastar(neodevice_t neodevice) : Device(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
@@ -78,6 +80,13 @@ protected:
};
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
}
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
if(!message || message->data.size() < sizeof(radgigastar_status_t))
return;
const radgigastar_status_t* status = reinterpret_cast<const radgigastar_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
};
}
@@ -135,6 +135,11 @@ public:
}
};
typedef struct {
uint8_t unused[3];
uint8_t ethernetActivationLineEnabled;
} radgigastar_status_t;
}
#endif // __cplusplus
@@ -76,6 +76,12 @@ typedef struct {
uint16_t pwr_man_timeout;
} valuecan4_4_2el_settings_t, valuecan4_4_settings_t, valuecan4_2el_settings_t;
typedef struct
{
uint8_t ethernetActivationLineEnabled;
uint8_t unused;
} valuecan4_4_2el_status_t, valuecan4_4_status_t, valuecan4_2el_status_t;
typedef struct {
CAN_SETTINGS can1;
CANFD_SETTINGS canfd1;
@@ -19,6 +19,15 @@ protected:
ValueCAN4_2EL(neodevice_t neodevice) : ValueCAN4(neodevice) {
getWritableNeoDevice().type = DEVICE_TYPE;
}
size_t getEthernetActivationLineCount() const override { return 1; }
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
if(!message || message->data.size() < sizeof(valuecan4_2el_status_t))
return;
const valuecan4_2el_status_t* status = reinterpret_cast<const valuecan4_2el_status_t*>(message->data.data());
ethActivationStatus = status->ethernetActivationLineEnabled;
}
};
}