wip: android driver

This commit is contained in:
Kyle Johannes
2023-11-14 14:09:56 -05:00
parent 90e1aa223d
commit b2f67f7ce1
9 changed files with 332 additions and 9 deletions
+7 -2
View File
@@ -122,6 +122,11 @@ public:
GetIfAddrsError = 0x3108,
SendToError = 0x3109,
MDIOMessageExceedsMaxLength = 0x3110,
DriverTTYPathEmpty = 0x3120,
DriverWasNotNegOne = 0x3121,
DriverTCGetAddrFail = 0x3122,
DriverTCSetAddrFail= 0x3123,
// FTD3XX
FTOK = 0x4000, // placeholder
@@ -160,8 +165,8 @@ public:
NoErrorFound = 0xFFFFFFFD,
TooManyEvents = 0xFFFFFFFE,
Unknown = 0xFFFFFFFF
};
Unknown = 0xFFFFFFFF,
};
enum class Severity : uint8_t {
Any = 0, // Used for filtering, should not appear in data
EventInfo = 0x10,
@@ -0,0 +1,56 @@
#ifndef __CDCACM_ANDROID_H_
#define __CDCACM_ANDROID_H_
#ifdef __cplusplus
#include "icsneo/communication/driver.h"
#include "icsneo/device/neodevice.h"
#include "icsneo/api/eventmanager.h"
#include <optional>
#include <chrono>
#include <sys/stat.h>
#include <stdint.h>
#include <unordered_map>
namespace icsneo {
class ANDROIDUSB : public Driver {
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();
static void Find(std::vector<FoundDevice>& found);
bool open() override;
bool isOpen() override;
bool close() override;
void modeChangeIncoming() override;
void awaitModeChangeComplete() override;
static void addSystemFD(int fd);
static void 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;
static std::string HandleToTTY(neodevice_handle_t handle);
void readTask() override;
void writeTask() override;
bool fdIsValid();
};
}
#endif // __cplusplus
#endif //LIBICSNEO_TEST_ANDROIDUSB_H