Drivers: Decouple from devices

This allows us to better implement alternative drivers
for devices, such as for device sharing servers or
talking to CoreMini processors within the same device.
This commit is contained in:
Paul Hollinsky
2022-03-27 14:30:31 -04:00
parent 0ff12300f3
commit 781fc2c034
66 changed files with 780 additions and 1566 deletions
+9 -13
View File
@@ -4,6 +4,7 @@
#ifdef __cplusplus
#include "icsneo/device/neodevice.h"
#include "icsneo/device/founddevice.h"
#include "icsneo/communication/driver.h"
#include "icsneo/communication/ethernetpacketizer.h"
#include "icsneo/api/eventmanager.h"
@@ -14,33 +15,28 @@ namespace icsneo {
class PCAP : public Driver {
public:
class PCAPFoundDevice {
public:
neodevice_t device;
std::vector<std::vector<uint8_t>> discoveryPackets;
};
static std::vector<PCAPFoundDevice> FindAll();
static void Find(std::vector<FoundDevice>& foundDevices);
static std::string GetEthDevSerialFromMacAddress(uint8_t product, uint16_t macSerial);
static bool IsHandleValid(neodevice_handle_t handle);
PCAP(device_eventhandler_t err, neodevice_t& forDevice);
bool open();
bool isOpen();
bool close();
bool open() override;
bool isOpen() override;
bool close() override;
bool isEthernet() const override { return true; }
private:
char errbuf[PCAP_ERRBUF_SIZE] = { 0 };
neodevice_t& device;
uint8_t deviceMAC[6];
bool openable = true;
EthernetPacketizer ethPacketizer;
void readTask();
void writeTask();
void readTask() override;
void writeTask() override;
class NetworkInterface {
public:
uint8_t uuid;
uint8_t macAddress[8];
uint8_t macAddress[6];
std::string nameFromPCAP;
std::string descriptionFromPCAP;
std::string fullName;