Refactor ICommunication/Transport => Driver

This commit is contained in:
Paul Hollinsky
2020-03-09 14:09:27 -04:00
parent d8798acaa7
commit 38e24d7641
17 changed files with 47 additions and 47 deletions
+4 -4
View File
@@ -24,7 +24,7 @@ bool Communication::open() {
}
spawnThreads();
return impl->open();
return driver->open();
}
void Communication::spawnThreads() {
@@ -46,11 +46,11 @@ bool Communication::close() {
joinThreads();
return impl->close();
return driver->close();
}
bool Communication::isOpen() {
return impl->isOpen();
return driver->isOpen();
}
bool Communication::sendPacket(std::vector<uint8_t>& bytes) {
@@ -174,7 +174,7 @@ void Communication::readTask() {
while(!closing) {
readBytes.clear();
if(impl->readWait(readBytes)) {
if(driver->readWait(readBytes)) {
if(packetizer->input(readBytes)) {
for(const auto& packet : packetizer->output()) {
std::shared_ptr<Message> msg;
@@ -1,8 +1,8 @@
#include "icsneo/communication/icommunication.h"
#include "icsneo/communication/driver.h"
using namespace icsneo;
bool ICommunication::read(std::vector<uint8_t>& bytes, size_t limit) {
bool Driver::read(std::vector<uint8_t>& bytes, size_t limit) {
// A limit of zero indicates no limit
if(limit == 0)
limit = (size_t)-1;
@@ -21,7 +21,7 @@ bool ICommunication::read(std::vector<uint8_t>& bytes, size_t limit) {
return true;
}
bool ICommunication::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout, size_t limit) {
bool Driver::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout, size_t limit) {
// A limit of zero indicates no limit
if(limit == 0)
limit = (size_t)-1;
@@ -38,7 +38,7 @@ bool ICommunication::readWait(std::vector<uint8_t>& bytes, std::chrono::millisec
return actuallyRead > 0;
}
bool ICommunication::write(const std::vector<uint8_t>& bytes) {
bool Driver::write(const std::vector<uint8_t>& bytes) {
if(!isOpen()) {
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
return false;
+1 -1
View File
@@ -41,7 +41,7 @@ void MultiChannelCommunication::hidReadTask() {
while(!closing) {
if(readMore) {
readBytes.clear();
if(impl->readWait(readBytes)) {
if(driver->readWait(readBytes)) {
readMore = false;
usbReadFifo.insert(usbReadFifo.end(), std::make_move_iterator(readBytes.begin()), std::make_move_iterator(readBytes.end()));
}