Tests for Noolite::sendCommand was added

This commit is contained in:
2024-05-29 08:51:38 +02:00
parent d5973cd0ee
commit 7055206fb1
7 changed files with 261 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ void LibUsbDevice::close()
}
}
bool LibUsbDevice::sendDataToDevice(unsigned char *data, uint16_t length, std::chrono::milliseconds timeout)
bool LibUsbDevice::sendDataToDevice(const Data &data, std::chrono::milliseconds timeout)
{
if (!m_device) {
std::cout << "Device not opened" << std::endl;
@@ -42,7 +42,10 @@ bool LibUsbDevice::sendDataToDevice(unsigned char *data, uint16_t length, std::c
auto requestType = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE;
auto request = LIBUSB_REQUEST_SET_CONFIGURATION;
auto status = libusb_control_transfer(m_device, requestType, request, 0, 0, data, length, timeout.count());
unsigned char package[data.size()];
std::copy(data.begin(), data.end(), package);
auto status = libusb_control_transfer(m_device, requestType, request, 0, 0, package, data.size(), timeout.count());
if (status) {
std::cout << "Sending data error: " << libusb_strerror(status) << std::endl;