aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device.cc8
-rw-r--r--include/device.h4
-rw-r--r--include/device_proto.h8
3 files changed, 10 insertions, 10 deletions
diff --git a/device.cc b/device.cc
index cf4b222..477884b 100644
--- a/device.cc
+++ b/device.cc
@@ -34,17 +34,17 @@ bool Device::connect() {
return mp_devhandle != NULL;
}
-CommError Device::send(const void *packet) {
+int Device::send(const void *packet) {
Log::instance()(__PRETTY_FUNCTION__, Loglevel::DEBUG_L2);
if (mp_devhandle == NULL)
throw std::runtime_error("Attempted HID send on an invalid descriptor.");
- return (CommError)(hid_send_feature_report(
+ return (hid_send_feature_report(
mp_devhandle, (const unsigned char *)(packet), HID_REPORT_SIZE));
}
-CommError Device::recv(void *packet) {
+int Device::recv(void *packet) {
// FIXME change CommError return value to int (return value of
// hid_get_feature_report)
int status;
@@ -80,7 +80,7 @@ CommError Device::recv(void *packet) {
std::this_thread::sleep_for(m_retry_timeout);
}
- return (CommError)status;
+ return status;
}
Stick10::Stick10() {
diff --git a/include/device.h b/include/device.h
index c4e2747..1c95c56 100644
--- a/include/device.h
+++ b/include/device.h
@@ -31,13 +31,13 @@ class Device {
/*
* Sends packet of HID_REPORT_SIZE.
*/
- virtual CommError send(const void *packet);
+ virtual int send(const void *packet);
/*
* Gets packet of HID_REPORT_SIZE.
* Can sleep. See below.
*/
- virtual CommError recv(void *packet);
+ virtual int recv(void *packet);
int get_retry_count() const { return m_retry_count; };
std::chrono::milliseconds get_retry_timeout() const { return m_retry_timeout; };
diff --git a/include/device_proto.h b/include/device_proto.h
index 2bbb38a..c248b10 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -168,7 +168,7 @@ class Transaction : semantics::non_constructible {
Log::instance()(__PRETTY_FUNCTION__, Loglevel::DEBUG_L2);
- CommError status;
+ int status;
OutgoingPacket outp;
ResponsePacket resp;
@@ -185,7 +185,7 @@ class Transaction : semantics::non_constructible {
if (!outp.isValid()) throw std::runtime_error("Invalid outgoing packet");
status = dev.send(&outp);
- if ((int)(status) < 0 && status != CommError::ERR_NO_ERROR)
+ if (status <= 0)
throw std::runtime_error(
std::string("Device error while sending command ") +
std::to_string((int)(status)));
@@ -204,10 +204,10 @@ class Transaction : semantics::non_constructible {
std::this_thread::sleep_for(dev.get_retry_timeout());
continue;
}
- if ((int)(status) < 0 && status != CommError::ERR_NO_ERROR)
+ if (status <= 0)
throw std::runtime_error(
std::string("Device error while executing command ") +
- std::to_string((int)(status)));
+ std::to_string(status));
Log::instance()("Incoming HID packet:", Loglevel::DEBUG);
Log::instance()((std::string)(resp), Loglevel::DEBUG);