Attempt to rework the USB handling to make the GreaseWeazle work on Windows and

Mac --- we abandon autodetection for anything other that FluxEngines as libusb
is painfully inconsistent with serial devices.
This commit is contained in:
David Given
2021-05-23 18:53:25 +01:00
parent c669a9c808
commit 4f0a5e854c
11 changed files with 125 additions and 233 deletions

View File

@@ -5,8 +5,10 @@
#include "bytes.h"
#include "fmt/format.h"
#include "greaseweazle.h"
#include "usbserial.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static const char* gw_error(int e)
{
@@ -120,12 +122,11 @@ private:
}
public:
GreaseWeazleUsb(libusb_device_descriptor* descriptor)
GreaseWeazleUsb(const std::string& port)
{
_fd = openUsbSerialDevice(descriptor);
_fd = ::open(port.c_str(), O_RDWR);
if (_fd == -1)
Error() << "cannot autodetect GreaseWeazle serial device path on this platform;"
<< " please use --usb.serial=<path>";
Error() << fmt::format("cannot open GreaseWeazel serial port: {}", strerror(errno));
_version = getVersion();
if ((_version != 22) && (_version != 24))
@@ -400,9 +401,9 @@ private:
nanoseconds_t _revolutions;
};
USB* createGreaseWeazleUsb(libusb_device_descriptor* descriptor)
USB* createGreaseWeazleUsb(const std::string& port)
{
return new GreaseWeazleUsb(descriptor);
return new GreaseWeazleUsb(port);
}
// vim: sw=4 ts=4 et