Resolve merge conflicts master into devicesettings
commit
399c72e61d
|
|
@ -7,7 +7,9 @@
|
|||
#include "device/include/device.h"
|
||||
|
||||
namespace icsneo {
|
||||
std::vector<std::shared_ptr<Device>> FindAllDevices();
|
||||
};
|
||||
|
||||
std::vector<std::shared_ptr<Device>> FindAllDevices();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -58,6 +58,6 @@ private:
|
|||
void readTask();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -38,6 +38,6 @@ protected:
|
|||
std::atomic<bool> closing{false};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -98,6 +98,6 @@ private:
|
|||
void readTask();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -400,6 +400,6 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +1,37 @@
|
|||
#ifndef __MESSAGECALLBACK_H_
|
||||
#define __MESSAGECALLBACK_H_
|
||||
|
||||
#include "communication/message/include/message.h"
|
||||
#include "communication/message/filter/include/messagefilter.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class MessageCallback {
|
||||
public:
|
||||
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, 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)
|
||||
MessageCallback(MessageFilter f, fn_messageCallback cb) { MessageCallback(cb, f); }
|
||||
|
||||
virtual bool callIfMatch(const std::shared_ptr<Message>& message) const {
|
||||
bool ret = filter->match(message);
|
||||
if(ret)
|
||||
callback(message);
|
||||
return ret;
|
||||
}
|
||||
const MessageFilter& getFilter() const { return *filter; }
|
||||
const fn_messageCallback& getCallback() const { return callback; }
|
||||
|
||||
protected:
|
||||
fn_messageCallback callback;
|
||||
std::shared_ptr<MessageFilter> filter;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#ifndef __MESSAGECALLBACK_H_
|
||||
#define __MESSAGECALLBACK_H_
|
||||
|
||||
#include "communication/message/include/message.h"
|
||||
#include "communication/message/filter/include/messagefilter.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class MessageCallback {
|
||||
public:
|
||||
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, 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)
|
||||
MessageCallback(MessageFilter f, fn_messageCallback cb) { MessageCallback(cb, f); }
|
||||
|
||||
virtual bool callIfMatch(const std::shared_ptr<Message>& message) const {
|
||||
bool ret = filter->match(message);
|
||||
if(ret)
|
||||
callback(message);
|
||||
return ret;
|
||||
}
|
||||
const MessageFilter& getFilter() const { return *filter; }
|
||||
const fn_messageCallback& getCallback() const { return callback; }
|
||||
|
||||
protected:
|
||||
fn_messageCallback callback;
|
||||
std::shared_ptr<MessageFilter> filter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,47 +1,47 @@
|
|||
#ifndef __MESSAGEFILTER_H_
|
||||
#define __MESSAGEFILTER_H_
|
||||
|
||||
#include "communication/include/network.h"
|
||||
#include "communication/message/include/message.h"
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class MessageFilter {
|
||||
public:
|
||||
MessageFilter() : matchAny(true) {}
|
||||
MessageFilter(Network::Type type) : type(type) {}
|
||||
MessageFilter(Network::NetID netid) : netid(netid) {}
|
||||
virtual ~MessageFilter() {}
|
||||
|
||||
virtual bool match(const std::shared_ptr<Message>& message) const {
|
||||
if(matchAny)
|
||||
return true;
|
||||
if(!matchType(message->network.getType()))
|
||||
return false;
|
||||
if(!matchNetID(message->network.getNetID()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool matchAny = false;
|
||||
|
||||
Network::Type type = Network::Type::Invalid; // Matching a type of invalid will match any
|
||||
bool matchType(Network::Type mtype) const {
|
||||
if(type == Network::Type::Invalid)
|
||||
return true;
|
||||
return type == mtype;
|
||||
}
|
||||
|
||||
Network::NetID netid = Network::NetID::Invalid; // Matching a netid of invalid will match any
|
||||
bool matchNetID(Network::NetID mnetid) const {
|
||||
if(netid == Network::NetID::Invalid)
|
||||
return true;
|
||||
return netid == mnetid;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#ifndef __MESSAGEFILTER_H_
|
||||
#define __MESSAGEFILTER_H_
|
||||
|
||||
#include "communication/include/network.h"
|
||||
#include "communication/message/include/message.h"
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class MessageFilter {
|
||||
public:
|
||||
MessageFilter() : matchAny(true) {}
|
||||
MessageFilter(Network::Type type) : type(type) {}
|
||||
MessageFilter(Network::NetID netid) : netid(netid) {}
|
||||
virtual ~MessageFilter() {}
|
||||
|
||||
virtual bool match(const std::shared_ptr<Message>& message) const {
|
||||
if(matchAny)
|
||||
return true;
|
||||
if(!matchType(message->network.getType()))
|
||||
return false;
|
||||
if(!matchNetID(message->network.getNetID()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool matchAny = false;
|
||||
|
||||
Network::Type type = Network::Type::Invalid; // Matching a type of invalid will match any
|
||||
bool matchType(Network::Type mtype) const {
|
||||
if(type == Network::Type::Invalid)
|
||||
return true;
|
||||
return type == mtype;
|
||||
}
|
||||
|
||||
Network::NetID netid = Network::NetID::Invalid; // Matching a netid of invalid will match any
|
||||
bool matchNetID(Network::NetID mnetid) const {
|
||||
if(netid == Network::NetID::Invalid)
|
||||
return true;
|
||||
return netid == mnetid;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -10,6 +10,6 @@ public:
|
|||
uint32_t arbid;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -14,6 +14,6 @@ public:
|
|||
uint64_t timestamp;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -32,8 +32,10 @@ typedef struct {
|
|||
#include "communication/message/include/message.h"
|
||||
|
||||
namespace icsneo {
|
||||
neomessage_t CreateNeoMessage(const Message& message);
|
||||
};
|
||||
|
||||
neomessage_t CreateNeoMessage(const Message& message);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -86,7 +86,7 @@ bool Packetizer::input(const std::vector<uint8_t>& inputBytes) {
|
|||
break;
|
||||
case ReadState::GetData:
|
||||
// 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;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,6 @@ private:
|
|||
void enforcePollingMessageLimit();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -12,6 +12,6 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> FindAll();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -6,8 +6,10 @@
|
|||
#ifdef __cplusplus
|
||||
// A forward declaration is needed as there is a circular dependency
|
||||
namespace icsneo {
|
||||
class Device;
|
||||
};
|
||||
|
||||
class Device;
|
||||
|
||||
}
|
||||
typedef icsneo::Device* devicehandle_t;
|
||||
#else
|
||||
typedef void* devicehandle_t;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -30,6 +30,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -53,6 +53,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -14,6 +14,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -40,6 +40,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -29,6 +29,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -25,6 +25,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -25,6 +25,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -17,6 +17,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -44,6 +44,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -30,6 +30,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -33,6 +33,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -29,6 +29,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -30,6 +30,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -32,6 +32,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __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
|
||||
|
|
@ -46,6 +46,6 @@ private:
|
|||
FTDIDevice ftdiDevice;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -26,6 +26,6 @@ private:
|
|||
void writeTask();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -273,8 +273,8 @@ void STM32::writeTask() {
|
|||
if(!writeQueue.wait_dequeue_timed(writeOp, std::chrono::milliseconds(100)))
|
||||
continue;
|
||||
|
||||
const auto writeSize = writeOp.bytes.size();
|
||||
int actualWritten = ::write(fd, writeOp.bytes.data(), writeSize);
|
||||
const ssize_t writeSize = (ssize_t)writeOp.bytes.size();
|
||||
ssize_t actualWritten = ::write(fd, writeOp.bytes.data(), writeSize);
|
||||
if(actualWritten != writeSize)
|
||||
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"); }
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -65,6 +65,6 @@ private:
|
|||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -28,6 +28,6 @@ private:
|
|||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -11,6 +11,6 @@ public:
|
|||
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"usbser"); }
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -43,6 +43,6 @@ private:
|
|||
void writeTask();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -4,12 +4,17 @@
|
|||
#include <Windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <pcap.h>
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
// Helper loader for the PCAP DLL
|
||||
class PCAPDLL {
|
||||
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
|
||||
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);
|
||||
|
|
@ -48,6 +53,6 @@ private:
|
|||
void closeDLL();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -2,7 +2,15 @@
|
|||
|
||||
using namespace icsneo;
|
||||
|
||||
std::shared_ptr<PCAPDLL> PCAPDLL::lazyLoadHolder;
|
||||
bool PCAPDLL::lazyLoaded = false;
|
||||
|
||||
PCAPDLL::PCAPDLL() {
|
||||
if(!lazyLoaded) {
|
||||
lazyLoaded = true;
|
||||
lazyLoadHolder = std::make_shared<PCAPDLL>();
|
||||
}
|
||||
|
||||
dll = LoadLibrary("wpcap.dll");
|
||||
|
||||
if(dll == NULL) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue