mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
wip: native libusb can fetch product ID, serial, and android system FDs can be wrapped
This commit is contained in:
@@ -125,7 +125,7 @@ public:
|
||||
DriverTTYPathEmpty = 0x3120,
|
||||
DriverWasNotNegOne = 0x3121,
|
||||
DriverTCGetAddrFail = 0x3122,
|
||||
DriverTCSetAddrFail= 0x3123,
|
||||
DriverTCSetAddrFail = 0x3123,
|
||||
|
||||
|
||||
// FTD3XX
|
||||
@@ -163,10 +163,15 @@ public:
|
||||
FTIncorrectDevicePath = FTOK + 31,
|
||||
FTOtherError = FTOK + 32,
|
||||
|
||||
// Android USB
|
||||
AndroidUSBLibusbInitFailed = 0x5000,
|
||||
AndroidUSBFDWrapFailed = 0x5001,
|
||||
|
||||
NoErrorFound = 0xFFFFFFFD,
|
||||
TooManyEvents = 0xFFFFFFFE,
|
||||
Unknown = 0xFFFFFFFF,
|
||||
};
|
||||
};
|
||||
|
||||
enum class Severity : uint8_t {
|
||||
Any = 0, // Used for filtering, should not appear in data
|
||||
EventInfo = 0x10,
|
||||
|
||||
@@ -837,6 +837,11 @@ extern bool icsneo_getRTC(const neodevice_t* device, uint64_t* output);
|
||||
*/
|
||||
extern bool icsneo_setRTC(const neodevice_t* device, uint64_t input);
|
||||
|
||||
#ifdef ICSNEO_ENABLE_ANDROIDUSB
|
||||
extern bool icsneo_addSysFileDescriptor(int sysFd);
|
||||
extern bool icsneo_removeSysFileDescriptor(int sysFd);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#ifndef __CDCACM_ANDROID_H_
|
||||
#define __CDCACM_ANDROID_H_
|
||||
#ifndef __ANDROIDUSB_H_
|
||||
#define __ANDROIDUSB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/driver.h"
|
||||
#include "icsneo/device/neodevice.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include "libusb.h"
|
||||
#include <optional>
|
||||
#include <chrono>
|
||||
#include <sys/stat.h>
|
||||
@@ -19,7 +20,11 @@ public:
|
||||
/**
|
||||
* Note: This is a driver for all devices which use Android CDC_ACM
|
||||
*/
|
||||
ANDROIDUSB(const device_eventhandler_t& err, neodevice_t& forDevice) : Driver(err), device(forDevice) {}
|
||||
ANDROIDUSB(const device_eventhandler_t& err, neodevice_t& forDevice)
|
||||
: Driver(err), device(forDevice) {
|
||||
if(auto key = systemFDs.find(device.handle); key != systemFDs.end())
|
||||
libusbDeviceHandle = key->second;
|
||||
}
|
||||
~ANDROIDUSB();
|
||||
static void Find(std::vector<FoundDevice>& found);
|
||||
|
||||
@@ -27,22 +32,15 @@ public:
|
||||
bool isOpen() override;
|
||||
bool close() override;
|
||||
|
||||
void modeChangeIncoming() override;
|
||||
void awaitModeChangeComplete() override;
|
||||
|
||||
static void addSystemFD(int fd);
|
||||
static void removeSystemFD(int fd);
|
||||
static bool addSystemFD(int fd);
|
||||
static bool removeSystemFD(int fd);
|
||||
|
||||
private:
|
||||
neodevice_t& device;
|
||||
static std::unordered_map<int,FoundDevice> systemFDs;
|
||||
std::optional<ino_t> disallowedInode;
|
||||
std::atomic<bool> modeChanging{false};
|
||||
std::thread modeChangeThread;
|
||||
std::mutex modeChangeMutex;
|
||||
std::condition_variable modeChangeCV;
|
||||
libusb_context *ctx = nullptr;
|
||||
libusb_device_handle *libusbDeviceHandle = nullptr;
|
||||
|
||||
static std::string HandleToTTY(neodevice_handle_t handle);
|
||||
inline static std::unordered_map<int,libusb_device_handle*> systemFDs; //android FD, libusb handle
|
||||
|
||||
void readTask() override;
|
||||
void writeTask() override;
|
||||
|
||||
Reference in New Issue
Block a user