Tests for Noolite::sendCommand was added
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
void openDevice(uint16_t vendorId, uint16_t productId) override;
|
||||
void close() override;
|
||||
bool sendDataToDevice(unsigned char *data, uint16_t length, std::chrono::milliseconds timeout = std::chrono::seconds(1)) override;
|
||||
bool sendDataToDevice(const Data &data, std::chrono::milliseconds timeout = std::chrono::seconds(1)) override;
|
||||
|
||||
private:
|
||||
libusb_context *m_context = nullptr;
|
||||
|
||||
@@ -25,5 +25,14 @@ Noolite::~Noolite()
|
||||
delete m_device;
|
||||
}
|
||||
|
||||
bool Noolite::sendCommand(int channel, Command command, Params params)
|
||||
{
|
||||
(void) channel;
|
||||
(void) command;
|
||||
(void) params;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef NOOLITE_H
|
||||
#define NOOLITE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "interfaces/iusbdevice.h"
|
||||
|
||||
namespace noolitelib
|
||||
@@ -27,12 +29,16 @@ enum Command
|
||||
EffectSpeed
|
||||
};
|
||||
|
||||
using Params = std::vector<int>;
|
||||
|
||||
class Noolite
|
||||
{
|
||||
public:
|
||||
Noolite(IUsbDevice *device = nullptr);
|
||||
~Noolite();
|
||||
|
||||
bool sendCommand(int channel, Command command, Params params = Params());
|
||||
|
||||
private:
|
||||
IUsbDevice *m_device;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user