mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
5
Makefile
5
Makefile
@@ -30,6 +30,11 @@ ifeq ($(shell uname),Darwin)
|
||||
-framework Foundation
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname),FreeBSD)
|
||||
PLATFORM = FreeBSD
|
||||
CFLAGS += -I/usr/local/include
|
||||
endif
|
||||
|
||||
#Check the Make version.
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ LIBUSBP_SRCS += \
|
||||
dep/libusbp/src/mac/list_mac.c \
|
||||
dep/libusbp/src/mac/serial_port_mac.c \
|
||||
|
||||
else
|
||||
else ifeq ($(shell uname),Linux)
|
||||
|
||||
LIBUSBP_CFLAGS += $(shell pkg-config --cflags libudev)
|
||||
LIBUSBP_LDFLAGS += $(shell pkg-config --libs libudev)
|
||||
@@ -48,6 +48,11 @@ LIBUSBP_SRCS += \
|
||||
dep/libusbp/src/linux/udev_linux.c \
|
||||
dep/libusbp/src/linux/usbfd_linux.c \
|
||||
|
||||
else
|
||||
|
||||
LIBUSBP_SRCS += \
|
||||
dep/libusbp/src/dummy.c
|
||||
|
||||
endif
|
||||
|
||||
LIBUSBP_OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(LIBUSBP_SRCS))
|
||||
|
||||
103
dep/libusbp/src/dummy.c
Normal file
103
dep/libusbp/src/dummy.c
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
// This file contains failing place-holders to make things compile
|
||||
// on otherwise unsupported platforms.
|
||||
|
||||
#include <libusbp_internal.h>
|
||||
|
||||
struct libusbp_device
|
||||
{
|
||||
char* syspath;
|
||||
char* serial_number; // may be NULL
|
||||
uint16_t product_id;
|
||||
uint16_t vendor_id;
|
||||
uint16_t revision;
|
||||
};
|
||||
|
||||
static libusbp_error* fail()
|
||||
{
|
||||
return error_create("USB hardware is not supported on this platform");
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_device_copy(
|
||||
const libusbp_device* source, libusbp_device** dest)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_generic_interface_create(const libusbp_device* device,
|
||||
uint8_t interface_number,
|
||||
bool composite __attribute__((unused)),
|
||||
libusbp_generic_interface** gi)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_generic_handle_open(
|
||||
const libusbp_generic_interface* gi, libusbp_generic_handle** handle)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
void libusbp_device_free(libusbp_device* device) {}
|
||||
|
||||
void libusbp_generic_handle_close(libusbp_generic_handle* handle) {}
|
||||
|
||||
void libusbp_generic_interface_free(libusbp_generic_interface* gi) {}
|
||||
|
||||
libusbp_error* libusbp_device_get_vendor_id(
|
||||
const libusbp_device* device, uint16_t* vendor_id)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_device_get_product_id(
|
||||
const libusbp_device* device, uint16_t* product_id)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_device_get_serial_number(
|
||||
const libusbp_device* device, char** serial_number)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_write_pipe(libusbp_generic_handle* handle,
|
||||
uint8_t pipe_id,
|
||||
const void* data,
|
||||
size_t size,
|
||||
size_t* transferred)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_read_pipe(libusbp_generic_handle* handle,
|
||||
uint8_t pipe_id,
|
||||
void* data,
|
||||
size_t size,
|
||||
size_t* transferred)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_serial_port_create(const libusbp_device* device,
|
||||
uint8_t interface_number,
|
||||
bool composite,
|
||||
libusbp_serial_port** port)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
libusbp_error* libusbp_serial_port_get_name(
|
||||
const libusbp_serial_port* port, char** name)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
|
||||
void libusbp_serial_port_free(libusbp_serial_port* port) {}
|
||||
|
||||
libusbp_error* libusbp_list_connected_devices(
|
||||
libusbp_device*** device_list, size_t* device_count)
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
@@ -26,32 +26,39 @@ static const std::string get_serial_number(const libusbp::device& device)
|
||||
|
||||
std::vector<std::shared_ptr<CandidateDevice>> findUsbDevices()
|
||||
{
|
||||
std::vector<std::shared_ptr<CandidateDevice>> candidates;
|
||||
for (const auto& it : libusbp::list_connected_devices())
|
||||
try
|
||||
{
|
||||
auto candidate = std::make_unique<CandidateDevice>();
|
||||
candidate->device = it;
|
||||
|
||||
uint32_t id = (it.get_vendor_id() << 16) | it.get_product_id();
|
||||
if (VALID_DEVICES.find(id) != VALID_DEVICES.end())
|
||||
std::vector<std::shared_ptr<CandidateDevice>> candidates;
|
||||
for (const auto& it : libusbp::list_connected_devices())
|
||||
{
|
||||
candidate->id = id;
|
||||
candidate->serial = get_serial_number(it);
|
||||
auto candidate = std::make_unique<CandidateDevice>();
|
||||
candidate->device = it;
|
||||
|
||||
if (id == GREASEWEAZLE_ID)
|
||||
uint32_t id = (it.get_vendor_id() << 16) | it.get_product_id();
|
||||
if (VALID_DEVICES.find(id) != VALID_DEVICES.end())
|
||||
{
|
||||
libusbp::serial_port port(candidate->device);
|
||||
candidate->serialPort = port.get_name();
|
||||
candidate->type = DEVICE_GREASEWEAZLE;
|
||||
candidate->id = id;
|
||||
candidate->serial = get_serial_number(it);
|
||||
|
||||
if (id == GREASEWEAZLE_ID)
|
||||
{
|
||||
libusbp::serial_port port(candidate->device);
|
||||
candidate->serialPort = port.get_name();
|
||||
candidate->type = DEVICE_GREASEWEAZLE;
|
||||
}
|
||||
else if (id == FLUXENGINE_ID)
|
||||
candidate->type = DEVICE_FLUXENGINE;
|
||||
|
||||
candidates.push_back(std::move(candidate));
|
||||
}
|
||||
else if (id == FLUXENGINE_ID)
|
||||
candidate->type = DEVICE_FLUXENGINE;
|
||||
|
||||
candidates.push_back(std::move(candidate));
|
||||
}
|
||||
}
|
||||
|
||||
return candidates;
|
||||
return candidates;
|
||||
}
|
||||
catch (const libusbp::error& e)
|
||||
{
|
||||
error("USB error: {}", e.message());
|
||||
}
|
||||
}
|
||||
|
||||
std::string getDeviceName(DeviceType type)
|
||||
|
||||
Reference in New Issue
Block a user