mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Tidy reporting of USB errors.
This commit is contained in:
2
Makefile
2
Makefile
@@ -32,8 +32,6 @@ endif
|
||||
|
||||
ifeq ($(shell uname),FreeBSD)
|
||||
PLATFORM = FreeBSD
|
||||
#WX_CONFIG=/usr/local/bin/wxgtk3u-3.2-config
|
||||
#WX_CONFIG=/usr/local/bin/wxgtk3u-3.0-config
|
||||
CFLAGS += -I/usr/local/include
|
||||
endif
|
||||
|
||||
|
||||
@@ -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