generated from thinkode/modelRepository
renaming Finders and Peripherals to Providers and Endpoints
This commit is contained in:
@@ -8,11 +8,11 @@ typedef struct {
|
||||
char* serialNumber;
|
||||
char* description;
|
||||
int isOpen;
|
||||
} FTDIPeripheralC;
|
||||
} FTDIEndpointC;
|
||||
|
||||
int get_peripherals_number();
|
||||
void get_ftdi_devices(FTDIPeripheralC* devices, int count);
|
||||
void free_ftdi_device(FTDIPeripheralC* device);
|
||||
int get_endpoints_number();
|
||||
void get_ftdi_devices(FTDIEndpointC* devices, int count);
|
||||
void free_ftdi_device(FTDIEndpointC* device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
int getFTDIPeripheralsNumber() {
|
||||
int getFTDIEndpointsNumber() {
|
||||
DWORD numDevs = 0;
|
||||
if (FT_CreateDeviceInfoList(&numDevs) != FT_OK) {
|
||||
std::cerr << "Unable to get FTDI devices: create list error\n";
|
||||
@@ -13,7 +13,7 @@ int getFTDIPeripheralsNumber() {
|
||||
return numDevs;
|
||||
}
|
||||
|
||||
std::vector<FTDIPeripheral> scanFTDIPeripherals() {
|
||||
std::vector<FTDIEndpoint> scanFTDIEndpoints() {
|
||||
DWORD numDevs = 0;
|
||||
if (FT_CreateDeviceInfoList(&numDevs) != FT_OK) {
|
||||
std::cerr << "Unable to get FTDI devices: create list error\n";
|
||||
@@ -30,12 +30,12 @@ std::vector<FTDIPeripheral> scanFTDIPeripherals() {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<FTDIPeripheral> peripherals;
|
||||
peripherals.reserve(numDevs);
|
||||
std::vector<FTDIEndpoint> endpoints;
|
||||
endpoints.reserve(numDevs);
|
||||
|
||||
for (const auto& info : devInfo) {
|
||||
if (info.SerialNumber[0] != '\0') {
|
||||
peripherals.push_back({
|
||||
endpoints.push_back({
|
||||
info.SerialNumber,
|
||||
info.Description,
|
||||
static_cast<bool>(info.Flags & FT_FLAGS_OPENED)
|
||||
@@ -43,21 +43,21 @@ std::vector<FTDIPeripheral> scanFTDIPeripherals() {
|
||||
}
|
||||
}
|
||||
|
||||
return peripherals;
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int get_peripherals_number() {
|
||||
return getFTDIPeripheralsNumber();
|
||||
int get_endpoints_number() {
|
||||
return getFTDIEndpointsNumber();
|
||||
}
|
||||
|
||||
void get_ftdi_devices(FTDIPeripheralC* devices, int count) {
|
||||
void get_ftdi_devices(FTDIEndpointC* devices, int count) {
|
||||
if (!devices || count <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto list = scanFTDIPeripherals();
|
||||
auto list = scanFTDIEndpoints();
|
||||
int n = std::min(count, static_cast<int>(list.size()));
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
@@ -74,7 +74,7 @@ void get_ftdi_devices(FTDIPeripheralC* devices, int count) {
|
||||
}
|
||||
}
|
||||
|
||||
void free_ftdi_device(FTDIPeripheralC* device) {
|
||||
void free_ftdi_device(FTDIEndpointC* device) {
|
||||
if (!device) return;
|
||||
|
||||
if (device->serialNumber) {
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct FTDIPeripheral {
|
||||
struct FTDIEndpoint {
|
||||
std::string serialNumber;
|
||||
std::string description;
|
||||
bool isOpen;
|
||||
};
|
||||
|
||||
int getFTDIPeripheralsNumber();
|
||||
std::vector<FTDIPeripheral> scanFTDIPeripherals();
|
||||
int getFTDIEndpointsNumber();
|
||||
std::vector<FTDIEndpoint> scanFTDIEndpoints();
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void resetChannels();
|
||||
|
||||
private:
|
||||
FT_STATUS ftStatus; // FTDI peripheral status
|
||||
FT_STATUS ftStatus; // FTDI endpoint status
|
||||
FT_HANDLE ftHandle = nullptr; // FTDI object
|
||||
std::atomic<uint8_t> dmxData[DMX_CHANNELS + 1]; // For storing dynamically the DMX data
|
||||
std::atomic<bool> isOutputActivated = false; // Boolean to start/stop the DMX flow
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include <iostream>
|
||||
|
||||
int main(){
|
||||
int peripheralsNumber = getFTDIPeripheralsNumber();
|
||||
int endpointsNumber = getFTDIEndpointsNumber();
|
||||
|
||||
|
||||
std::vector<FTDIPeripheral> peripherals = scanFTDIPeripherals();
|
||||
std::vector<FTDIEndpoint> endpoints = scanFTDIEndpoints();
|
||||
|
||||
// for (const auto& peripheral : peripherals) {
|
||||
// std::cout << peripheral.serialNumber << " (" << peripheral.description << ") -> IS OPEN: " << peripheral.isOpen << std::endl;
|
||||
// for (const auto& endpoint : endpoints) {
|
||||
// std::cout << endpoint.serialNumber << " (" << endpoint.description << ") -> IS OPEN: " << endpoint.isOpen << std::endl;
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user