mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Communication uses instantiated Packetizers and Decoders now
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "device/neovifire2/include/neovifire2.h"
|
||||
#include "platform/include/pcap.h"
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
@@ -10,15 +11,24 @@ class NeoVIFIRE2ETH : public NeoVIFIRE2 {
|
||||
public:
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x0004;
|
||||
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
com = std::make_shared<Communication>(std::make_shared<PCAP>(getWritableNeoDevice()));
|
||||
auto transport = std::make_shared<PCAP>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : PCAP::FindByProduct(PRODUCT_ID))
|
||||
found.push_back(std::make_shared<NeoVIFIRE2ETH>(neodevice));
|
||||
for(auto neodevice : PCAP::FindByProduct(PRODUCT_ID)) {
|
||||
strncpy(neodevice.serial, SERIAL_FIND_ON_OPEN, sizeof(neodevice.serial));
|
||||
neodevice.serial[sizeof(neodevice.serial) - 1] = '\0';
|
||||
auto device = std::make_shared<NeoVIFIRE2ETH>(neodevice);
|
||||
if(!device->open()) // We will get the serial number on open
|
||||
continue; // If the open failed, we won't display the device as an option to connect to
|
||||
found.push_back(device);
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ class NeoVIFIRE2USB : public NeoVIFIRE2 {
|
||||
public:
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x1000;
|
||||
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
com = std::make_shared<Communication>(std::make_shared<FTDI>(getWritableNeoDevice()));
|
||||
auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user