Resolve merge conflicts master into devicesettings
commit
399c72e61d
|
|
@ -7,7 +7,9 @@
|
||||||
#include "device/include/device.h"
|
#include "device/include/device.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
std::vector<std::shared_ptr<Device>> FindAllDevices();
|
|
||||||
};
|
std::vector<std::shared_ptr<Device>> FindAllDevices();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -58,6 +58,6 @@ private:
|
||||||
void readTask();
|
void readTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -38,6 +38,6 @@ protected:
|
||||||
std::atomic<bool> closing{false};
|
std::atomic<bool> closing{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -98,6 +98,6 @@ private:
|
||||||
void readTask();
|
void readTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -400,6 +400,6 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
#ifndef __MESSAGECALLBACK_H_
|
#ifndef __MESSAGECALLBACK_H_
|
||||||
#define __MESSAGECALLBACK_H_
|
#define __MESSAGECALLBACK_H_
|
||||||
|
|
||||||
#include "communication/message/include/message.h"
|
#include "communication/message/include/message.h"
|
||||||
#include "communication/message/filter/include/messagefilter.h"
|
#include "communication/message/filter/include/messagefilter.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class MessageCallback {
|
class MessageCallback {
|
||||||
public:
|
public:
|
||||||
typedef std::function< void( std::shared_ptr<Message> ) > fn_messageCallback;
|
typedef std::function< void( std::shared_ptr<Message> ) > fn_messageCallback;
|
||||||
|
|
||||||
MessageCallback(fn_messageCallback cb, std::shared_ptr<MessageFilter> f) : callback(cb), filter(f) {}
|
MessageCallback(fn_messageCallback cb, std::shared_ptr<MessageFilter> f) : callback(cb), filter(f) {}
|
||||||
MessageCallback(fn_messageCallback cb, MessageFilter f = MessageFilter()) : callback(cb), filter(std::make_shared<MessageFilter>(f)) {}
|
MessageCallback(fn_messageCallback cb, MessageFilter f = MessageFilter()) : callback(cb), filter(std::make_shared<MessageFilter>(f)) {}
|
||||||
|
|
||||||
// Allow the filter to be placed first if the user wants (maybe in the case of a lambda)
|
// Allow the filter to be placed first if the user wants (maybe in the case of a lambda)
|
||||||
MessageCallback(MessageFilter f, fn_messageCallback cb) { MessageCallback(cb, f); }
|
MessageCallback(MessageFilter f, fn_messageCallback cb) { MessageCallback(cb, f); }
|
||||||
|
|
||||||
virtual bool callIfMatch(const std::shared_ptr<Message>& message) const {
|
virtual bool callIfMatch(const std::shared_ptr<Message>& message) const {
|
||||||
bool ret = filter->match(message);
|
bool ret = filter->match(message);
|
||||||
if(ret)
|
if(ret)
|
||||||
callback(message);
|
callback(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
const MessageFilter& getFilter() const { return *filter; }
|
const MessageFilter& getFilter() const { return *filter; }
|
||||||
const fn_messageCallback& getCallback() const { return callback; }
|
const fn_messageCallback& getCallback() const { return callback; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
fn_messageCallback callback;
|
fn_messageCallback callback;
|
||||||
std::shared_ptr<MessageFilter> filter;
|
std::shared_ptr<MessageFilter> filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,47 +1,47 @@
|
||||||
#ifndef __MESSAGEFILTER_H_
|
#ifndef __MESSAGEFILTER_H_
|
||||||
#define __MESSAGEFILTER_H_
|
#define __MESSAGEFILTER_H_
|
||||||
|
|
||||||
#include "communication/include/network.h"
|
#include "communication/include/network.h"
|
||||||
#include "communication/message/include/message.h"
|
#include "communication/message/include/message.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class MessageFilter {
|
class MessageFilter {
|
||||||
public:
|
public:
|
||||||
MessageFilter() : matchAny(true) {}
|
MessageFilter() : matchAny(true) {}
|
||||||
MessageFilter(Network::Type type) : type(type) {}
|
MessageFilter(Network::Type type) : type(type) {}
|
||||||
MessageFilter(Network::NetID netid) : netid(netid) {}
|
MessageFilter(Network::NetID netid) : netid(netid) {}
|
||||||
virtual ~MessageFilter() {}
|
virtual ~MessageFilter() {}
|
||||||
|
|
||||||
virtual bool match(const std::shared_ptr<Message>& message) const {
|
virtual bool match(const std::shared_ptr<Message>& message) const {
|
||||||
if(matchAny)
|
if(matchAny)
|
||||||
return true;
|
return true;
|
||||||
if(!matchType(message->network.getType()))
|
if(!matchType(message->network.getType()))
|
||||||
return false;
|
return false;
|
||||||
if(!matchNetID(message->network.getNetID()))
|
if(!matchNetID(message->network.getNetID()))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool matchAny = false;
|
bool matchAny = false;
|
||||||
|
|
||||||
Network::Type type = Network::Type::Invalid; // Matching a type of invalid will match any
|
Network::Type type = Network::Type::Invalid; // Matching a type of invalid will match any
|
||||||
bool matchType(Network::Type mtype) const {
|
bool matchType(Network::Type mtype) const {
|
||||||
if(type == Network::Type::Invalid)
|
if(type == Network::Type::Invalid)
|
||||||
return true;
|
return true;
|
||||||
return type == mtype;
|
return type == mtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::NetID netid = Network::NetID::Invalid; // Matching a netid of invalid will match any
|
Network::NetID netid = Network::NetID::Invalid; // Matching a netid of invalid will match any
|
||||||
bool matchNetID(Network::NetID mnetid) const {
|
bool matchNetID(Network::NetID mnetid) const {
|
||||||
if(netid == Network::NetID::Invalid)
|
if(netid == Network::NetID::Invalid)
|
||||||
return true;
|
return true;
|
||||||
return netid == mnetid;
|
return netid == mnetid;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -10,6 +10,6 @@ public:
|
||||||
uint32_t arbid;
|
uint32_t arbid;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -14,6 +14,6 @@ public:
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -32,8 +32,10 @@ typedef struct {
|
||||||
#include "communication/message/include/message.h"
|
#include "communication/message/include/message.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
neomessage_t CreateNeoMessage(const Message& message);
|
|
||||||
};
|
neomessage_t CreateNeoMessage(const Message& message);
|
||||||
|
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -86,7 +86,7 @@ bool Packetizer::input(const std::vector<uint8_t>& inputBytes) {
|
||||||
break;
|
break;
|
||||||
case ReadState::GetData:
|
case ReadState::GetData:
|
||||||
// We do not include the checksum in packetLength so it doesn't get copied into the payload buffer
|
// We do not include the checksum in packetLength so it doesn't get copied into the payload buffer
|
||||||
if(bytes.size() < packetLength + (checksum ? 1 : 0)) { // Read until we have the rest of the packet
|
if(bytes.size() < (size_t)(packetLength + (checksum ? 1 : 0))) { // Read until we have the rest of the packet
|
||||||
haveEnoughData = false;
|
haveEnoughData = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,6 @@ private:
|
||||||
void enforcePollingMessageLimit();
|
void enforcePollingMessageLimit();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -12,6 +12,6 @@ public:
|
||||||
static std::vector<std::shared_ptr<Device>> FindAll();
|
static std::vector<std::shared_ptr<Device>> FindAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -6,8 +6,10 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
// A forward declaration is needed as there is a circular dependency
|
// A forward declaration is needed as there is a circular dependency
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
class Device;
|
|
||||||
};
|
class Device;
|
||||||
|
|
||||||
|
}
|
||||||
typedef icsneo::Device* devicehandle_t;
|
typedef icsneo::Device* devicehandle_t;
|
||||||
#else
|
#else
|
||||||
typedef void* devicehandle_t;
|
typedef void* devicehandle_t;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -30,6 +30,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -53,6 +53,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -14,6 +14,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -40,6 +40,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -29,6 +29,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -25,6 +25,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -25,6 +25,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -17,6 +17,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -44,6 +44,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -30,6 +30,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -33,6 +33,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -29,6 +29,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -30,6 +30,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -32,6 +32,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef __DYNAMICLIB_DARWIN_H_
|
#ifndef __DYNAMICLIB_DARWIN_H_
|
||||||
#define __DYNAMICLIB_DARWIN_H_
|
#define __DYNAMICLIB_DARWIN_H_
|
||||||
|
|
||||||
#define icsneo_dynamicLibraryLoad() dlopen("/home/paulywog/Code/icsneonext/build/libicsneoc.dylib", RTLD_LAZY)
|
#define icsneo_dynamicLibraryLoad() dlopen("/Users/paulywog/Code/icsneonext/build/libicsneoc.dylib", RTLD_LAZY)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -46,6 +46,6 @@ private:
|
||||||
FTDIDevice ftdiDevice;
|
FTDIDevice ftdiDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -26,6 +26,6 @@ private:
|
||||||
void writeTask();
|
void writeTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -273,8 +273,8 @@ void STM32::writeTask() {
|
||||||
if(!writeQueue.wait_dequeue_timed(writeOp, std::chrono::milliseconds(100)))
|
if(!writeQueue.wait_dequeue_timed(writeOp, std::chrono::milliseconds(100)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto writeSize = writeOp.bytes.size();
|
const ssize_t writeSize = (ssize_t)writeOp.bytes.size();
|
||||||
int actualWritten = ::write(fd, writeOp.bytes.data(), writeSize);
|
ssize_t actualWritten = ::write(fd, writeOp.bytes.data(), writeSize);
|
||||||
if(actualWritten != writeSize)
|
if(actualWritten != writeSize)
|
||||||
std::cout << "Failure to write " << writeSize << " bytes, wrote " << actualWritten << std::endl;
|
std::cout << "Failure to write " << writeSize << " bytes, wrote " << actualWritten << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@ public:
|
||||||
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"serenum"); }
|
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"serenum"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -65,6 +65,6 @@ private:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -28,6 +28,6 @@ private:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -11,6 +11,6 @@ public:
|
||||||
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"usbser"); }
|
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"usbser"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -43,6 +43,6 @@ private:
|
||||||
void writeTask();
|
void writeTask();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4,12 +4,17 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
// Helper loader for the PCAP DLL
|
// Helper loader for the PCAP DLL
|
||||||
class PCAPDLL {
|
class PCAPDLL {
|
||||||
public:
|
public:
|
||||||
|
// The first time we use the DLL we keep it in here and it won't get freed until the user unloads us (for speed reasons)
|
||||||
|
static std::shared_ptr<PCAPDLL> lazyLoadHolder;
|
||||||
|
static bool lazyLoaded;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
typedef int(__cdecl* PCAPFINDDEVICE)(char* source, struct pcap_rmtauth* auth, pcap_if_t** alldevs, char* errbuf);
|
typedef int(__cdecl* PCAPFINDDEVICE)(char* source, struct pcap_rmtauth* auth, pcap_if_t** alldevs, char* errbuf);
|
||||||
typedef pcap_t*(__cdecl* PCAPOPEN)(const char* source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth* auth, char* errbuf);
|
typedef pcap_t*(__cdecl* PCAPOPEN)(const char* source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth* auth, char* errbuf);
|
||||||
|
|
@ -48,6 +53,6 @@ private:
|
||||||
void closeDLL();
|
void closeDLL();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2,7 +2,15 @@
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
|
std::shared_ptr<PCAPDLL> PCAPDLL::lazyLoadHolder;
|
||||||
|
bool PCAPDLL::lazyLoaded = false;
|
||||||
|
|
||||||
PCAPDLL::PCAPDLL() {
|
PCAPDLL::PCAPDLL() {
|
||||||
|
if(!lazyLoaded) {
|
||||||
|
lazyLoaded = true;
|
||||||
|
lazyLoadHolder = std::make_shared<PCAPDLL>();
|
||||||
|
}
|
||||||
|
|
||||||
dll = LoadLibrary("wpcap.dll");
|
dll = LoadLibrary("wpcap.dll");
|
||||||
|
|
||||||
if(dll == NULL) {
|
if(dll == NULL) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue