mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Device: Refactor ComponentVersions
Also: - Add setGenericData() - Add ExtendedResponseFilter
This commit is contained in:
committed by
Kyle Schwarz
parent
b1e875980c
commit
7eeb1b6c38
@@ -7,8 +7,8 @@
|
||||
namespace icsneo {
|
||||
class ComponentVersion {
|
||||
public:
|
||||
ComponentVersion(uint8_t valid, uint8_t componentInfo, uint32_t identifier, uint32_t dotVersion, uint32_t commitHash) :
|
||||
valid(valid), componentInfo(componentInfo), identifier(identifier), dotVersion(dotVersion), commitHash(commitHash) {}
|
||||
ComponentVersion(uint8_t valid, uint8_t componentInfo, uint32_t identifier, uint32_t dotVersion, uint32_t commitHash, uint8_t expansionSlot) :
|
||||
valid(valid), componentInfo(componentInfo), identifier(identifier), dotVersion(dotVersion), commitHash(commitHash), expansionSlot(expansionSlot) {}
|
||||
|
||||
static ComponentVersion FromAppVersion(uint32_t identifier, uint8_t appMajor, uint8_t appMinor) {
|
||||
uint32_t dotVersion = (appMajor << 24) | (appMinor << 16);
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static_cast<uint8_t>(0u),
|
||||
identifier,
|
||||
dotVersion,
|
||||
static_cast<uint8_t>(0u),
|
||||
static_cast<uint8_t>(0u)
|
||||
);
|
||||
}
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
const uint32_t identifier;
|
||||
const uint32_t dotVersion;
|
||||
const uint32_t commitHash;
|
||||
const uint8_t expansionSlot;
|
||||
};
|
||||
|
||||
class ComponentVersionsMessage : public Message {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef __EXTENDEDRESPONSEFILTER_H_
|
||||
#define __EXTENDEDRESPONSEFILTER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/filter/messagefilter.h"
|
||||
#include "icsneo/communication/network.h"
|
||||
#include "icsneo/communication/communication.h"
|
||||
#include "icsneo/communication/command.h"
|
||||
#include "icsneo/communication/message/extendedresponsemessage.h"
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class ExtendedResponseFilter : public MessageFilter {
|
||||
public:
|
||||
ExtendedResponseFilter(icsneo::ExtendedResponse resp) : MessageFilter(Message::Type::ExtendedResponse), response(resp) {}
|
||||
|
||||
bool match(const std::shared_ptr<Message>& message) const override {
|
||||
if(!MessageFilter::match(message)) {
|
||||
return false;
|
||||
}
|
||||
const auto respMsg = std::static_pointer_cast<ExtendedResponseMessage>(message);
|
||||
return respMsg && matchResponse(respMsg->response);
|
||||
}
|
||||
|
||||
private:
|
||||
icsneo::ExtendedResponse response;
|
||||
bool matchResponse(icsneo::ExtendedResponse resp) const {
|
||||
return response == resp;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -570,6 +570,7 @@ public:
|
||||
NODISCARD("If the Lifetime is not held, disconnects will be immediately unsuppressed")
|
||||
Lifetime suppressDisconnects();
|
||||
|
||||
bool refreshComponentVersions();
|
||||
/**
|
||||
* For use by extensions only. A more stable API will be provided in the future.
|
||||
*/
|
||||
@@ -727,7 +728,9 @@ public:
|
||||
|
||||
virtual bool isOnlineSupported() const { return true; }
|
||||
|
||||
virtual bool supportsComponentVersions() const { return false; }
|
||||
virtual bool supportsComponentVersions() const {
|
||||
return !getComponentVersions().empty();
|
||||
}
|
||||
|
||||
virtual bool supportsTC10() const { return false; }
|
||||
|
||||
@@ -743,6 +746,8 @@ public:
|
||||
/* MACsec support */
|
||||
virtual bool writeMACsecConfig(const MACsecMessage& message, uint16_t binaryIndex);
|
||||
|
||||
std::shared_ptr<DeviceExtension> getExtension(const std::string& name) const;
|
||||
|
||||
protected:
|
||||
bool online = false;
|
||||
int messagePollingCallbackID = 0;
|
||||
@@ -824,12 +829,6 @@ protected:
|
||||
|
||||
virtual void setupExtensions() {}
|
||||
|
||||
// Hook for devices such as FIRE which need to inject traffic before RequestSerialNumber
|
||||
// Return false to bail
|
||||
virtual bool afterCommunicationOpen() { return true; }
|
||||
|
||||
virtual bool requiresVehiclePower() const { return true; }
|
||||
|
||||
template<typename Extension>
|
||||
std::shared_ptr<Extension> getExtension() const {
|
||||
std::shared_ptr<Extension> ret;
|
||||
@@ -841,6 +840,12 @@ protected:
|
||||
return ret;
|
||||
}
|
||||
// END Initialization Functions
|
||||
// Hook for devices such as FIRE which need to inject traffic before RequestSerialNumber
|
||||
// Return false to bail
|
||||
virtual bool afterCommunicationOpen() { return true; }
|
||||
|
||||
virtual bool requiresVehiclePower() const { return true; }
|
||||
|
||||
|
||||
void handleInternalMessage(std::shared_ptr<Message> message);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
virtual void onGoOffline() {}
|
||||
virtual void onDeviceClose() {}
|
||||
|
||||
virtual void setGenericData(void*) {}
|
||||
virtual bool providesFirmware() const { return false; }
|
||||
|
||||
virtual void handleMessage(const std::shared_ptr<Message>&) {}
|
||||
|
||||
@@ -26,8 +26,6 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
EtherBADGE(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<EtherBADGESettings>(makeDriver);
|
||||
|
||||
@@ -69,7 +69,6 @@ protected:
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
bool supportsGPTP() const override { return true; }
|
||||
|
||||
};
|
||||
|
||||
@@ -87,8 +87,6 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
NeoVIFIRE2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE2Settings, Disk::NeoMemoryDiskDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -49,9 +49,6 @@ public:
|
||||
};
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
NeoVIFIRE3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE3Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -52,8 +52,6 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
NeoVIFIRE3FlexRay(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIFIRE3FlexRaySettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -35,7 +35,6 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
bool supportsGPTP() const override { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -15,8 +15,6 @@ public:
|
||||
// USB PID is 0x0901, standard driver is FTDI
|
||||
ICSNEO_FINDABLE_DEVICE_BY_PID(NeoVIION, DeviceType::ION, 0x0901);
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
private:
|
||||
NeoVIION(neodevice_t neodevice, const driver_factory_t& makeDriver) : Plasion(neodevice) {
|
||||
initialize<NullSettings, Disk::PlasionDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -25,8 +25,6 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
RADEpsilon(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<RADEpsilonSettings, Disk::NeoMemoryDiskDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
|
||||
@@ -29,8 +29,6 @@ public:
|
||||
|
||||
bool getEthPhyRegControlSupported() const override { return true; }
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
RADJupiter(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<RADJupiterSettings>(makeDriver);
|
||||
|
||||
@@ -16,8 +16,6 @@ public:
|
||||
|
||||
uint8_t getPhyAddrOrPort() const override { return 1; }
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
bool supportsTC10() const override { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -28,8 +28,6 @@ public:
|
||||
|
||||
bool isOnlineSupported() const override { return false; }
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
bool supportsTC10() const override { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -25,8 +25,6 @@ public:
|
||||
|
||||
bool getEthPhyRegControlSupported() const override { return true; }
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
RADMoonDuo(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<RADMoonDuoSettings>(makeDriver);
|
||||
|
||||
@@ -34,8 +34,6 @@ public:
|
||||
|
||||
bool getEthPhyRegControlSupported() const override { return true; }
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
RADPluto(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<RADPlutoSettings>(makeDriver);
|
||||
|
||||
@@ -22,8 +22,6 @@ public:
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
private:
|
||||
ValueCAN3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<ValueCAN3Settings>(makeDriver);
|
||||
|
||||
@@ -11,9 +11,6 @@ namespace icsneo {
|
||||
class ValueCAN4 : public Device {
|
||||
public:
|
||||
// All ValueCAN 4 devices share a USB PID of 0x1101
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
using Device::Device;
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@ public:
|
||||
}
|
||||
|
||||
bool isOnlineSupported() const override { return false; }
|
||||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
protected:
|
||||
VividCAN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<VividCANSettings>(makeDriver);
|
||||
|
||||
Reference in New Issue
Block a user