mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Driver: Switch to libredxx
- no more libFTDI - no more libusb on Linux and macOS - no more FTDI repack - no more binary libs - faster D2XX on Windows (no longer uses COM)
This commit is contained in:
@@ -3,14 +3,34 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/platform/windows/vcp.h"
|
||||
#include "icsneo/communication/driver.h"
|
||||
#include "icsneo/device/founddevice.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class CDCACM : public VCP {
|
||||
class CDCACM : public Driver {
|
||||
public:
|
||||
CDCACM(const device_eventhandler_t& err, neodevice_t& forDevice) : VCP(err, forDevice) {}
|
||||
static void Find(std::vector<FoundDevice>& found) { return VCP::Find(found, { L"usbser" }); }
|
||||
CDCACM(const device_eventhandler_t& err, const std::wstring& path);
|
||||
static void Find(std::vector<FoundDevice>& found);
|
||||
bool open() override;
|
||||
bool isOpen() override;
|
||||
bool close() override;
|
||||
|
||||
private:
|
||||
void read();
|
||||
void write();
|
||||
std::wstring path;
|
||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||
std::thread readThread;
|
||||
std::thread writeThread;
|
||||
OVERLAPPED readOverlapped = {};
|
||||
OVERLAPPED writeOverlapped = {};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef __DYNAMICLIB_WINDOWS_H_
|
||||
#define __DYNAMICLIB_WINDOWS_H_
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef ICSNEOC_BUILD_STATIC
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef __FTDI_WINDOWS_H_
|
||||
#define __FTDI_WINDOWS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/platform/windows/vcp.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class FTDI : public VCP {
|
||||
public:
|
||||
FTDI(const device_eventhandler_t& err, neodevice_t& forDevice) : VCP(err, forDevice) {}
|
||||
static void Find(std::vector<FoundDevice>& found) { return VCP::Find(found, { L"serenum" /*, L"ftdibus" */ }); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <pcap.h>
|
||||
#include <memory>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef __VCP_WINDOWS_H_
|
||||
#define __VCP_WINDOWS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include "icsneo/device/neodevice.h"
|
||||
#include "icsneo/communication/driver.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
// Virtual COM Port Communication
|
||||
class VCP : public Driver {
|
||||
public:
|
||||
static void Find(std::vector<FoundDevice>& found, std::vector<std::wstring> driverName);
|
||||
static bool IsHandleValid(neodevice_handle_t handle);
|
||||
typedef void(*fn_boolCallback)(bool success);
|
||||
|
||||
VCP(const device_eventhandler_t& err, neodevice_t& forDevice);
|
||||
virtual ~VCP();
|
||||
bool open() { return open(false); }
|
||||
void openAsync(fn_boolCallback callback);
|
||||
bool close();
|
||||
bool isOpen();
|
||||
|
||||
private:
|
||||
bool open(bool fromAsync);
|
||||
bool opening = false;
|
||||
neodevice_t& device;
|
||||
|
||||
struct Detail;
|
||||
std::shared_ptr<Detail> detail;
|
||||
|
||||
std::vector<std::shared_ptr<std::thread>> threads;
|
||||
std::thread readThread, writeThread;
|
||||
void readTask();
|
||||
void writeTask();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user