Add USB stub, add logging using spdlog
This commit is contained in:
37
src/Usb.cpp
Normal file
37
src/Usb.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "Usb.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
namespace ptprnt::driver {
|
||||
|
||||
Usb::Usb() {
|
||||
std::cout << "Usb starting" << std::endl;
|
||||
libusb_init(NULL);
|
||||
}
|
||||
Usb::~Usb() {
|
||||
std::cout << "Usb stopping" << std::endl;
|
||||
}
|
||||
|
||||
std::vector<UsbDevice> Usb::listDevices() {
|
||||
libusb_device ** devs;
|
||||
libusb_device *dev;
|
||||
struct libusb_device_descriptor desc;
|
||||
int r,i=0;
|
||||
|
||||
libusb_get_device_list(NULL, &devs);
|
||||
|
||||
while ((dev=devs[i++]) != NULL) {
|
||||
if ((r=libusb_get_device_descriptor(dev, &desc)) < 0) {
|
||||
std::cerr << "failed to open device" << std::endl;
|
||||
libusb_free_device_list(devs, 1);
|
||||
}
|
||||
|
||||
std::cout << std::hex << std::setw(4) << desc.idVendor << ":" << desc.idProduct;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
return std::vector<UsbDevice>();
|
||||
}
|
||||
|
||||
} // namespace ptprnt::driver
|
Reference in New Issue
Block a user