mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
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:
@@ -26,14 +26,14 @@ namespace icsneo {
|
||||
|
||||
class Communication {
|
||||
public:
|
||||
// Note that the Packetizer is not created by the constructor,
|
||||
// and should be done once the Communication module is in place.
|
||||
Communication(
|
||||
device_eventhandler_t report,
|
||||
std::unique_ptr<Driver>&& driver,
|
||||
std::function<std::unique_ptr<Packetizer>()> makeConfiguredPacketizer,
|
||||
std::unique_ptr<Encoder>&& e,
|
||||
std::unique_ptr<Decoder>&& md) : makeConfiguredPacketizer(makeConfiguredPacketizer), encoder(std::move(e)), decoder(std::move(md)), report(report), driver(std::move(driver)) {
|
||||
packetizer = makeConfiguredPacketizer();
|
||||
}
|
||||
std::unique_ptr<Decoder>&& md) : makeConfiguredPacketizer(makeConfiguredPacketizer), encoder(std::move(e)), decoder(std::move(md)), driver(std::move(driver)), report(report) {}
|
||||
virtual ~Communication();
|
||||
|
||||
bool open();
|
||||
@@ -77,10 +77,10 @@ public:
|
||||
std::unique_ptr<Packetizer> packetizer;
|
||||
std::unique_ptr<Encoder> encoder;
|
||||
std::unique_ptr<Decoder> decoder;
|
||||
std::unique_ptr<Driver> driver;
|
||||
device_eventhandler_t report;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Driver> driver;
|
||||
static int messageCallbackIDCounter;
|
||||
std::mutex messageCallbacksLock;
|
||||
std::map<int, MessageCallback> messageCallbacks;
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
virtual bool read(std::vector<uint8_t>& bytes, size_t limit = 0);
|
||||
virtual bool readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout = std::chrono::milliseconds(100), size_t limit = 0);
|
||||
virtual bool write(const std::vector<uint8_t>& bytes);
|
||||
virtual bool isEthernet() const { return false; }
|
||||
|
||||
device_eventhandler_t report;
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
|
||||
uint8_t hostMAC[6] = { 0x00, 0xFC, 0x70, 0xFF, 0xFF, 0xFF };
|
||||
uint8_t deviceMAC[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
bool allowInPacketsFromAnyMAC = false; // Used when discovering devices
|
||||
|
||||
private:
|
||||
bool reassembling = false;
|
||||
|
||||
Reference in New Issue
Block a user