mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Added error checking and removed some redundancy from device isOpen()
This commit is contained in:
@@ -18,11 +18,12 @@ using namespace icsneo;
|
||||
int Communication::messageCallbackIDCounter = 1;
|
||||
|
||||
bool Communication::open() {
|
||||
if(isOpen)
|
||||
return true;
|
||||
|
||||
if(isOpen()) {
|
||||
err(APIError::DeviceCurrentlyOpen);
|
||||
return false;
|
||||
}
|
||||
|
||||
spawnThreads();
|
||||
isOpen = true;
|
||||
return impl->open();
|
||||
}
|
||||
|
||||
@@ -38,15 +39,20 @@ void Communication::joinThreads() {
|
||||
}
|
||||
|
||||
bool Communication::close() {
|
||||
if(!isOpen)
|
||||
if(!isOpen()) {
|
||||
err(APIError::DeviceCurrentlyClosed);
|
||||
return false;
|
||||
}
|
||||
|
||||
isOpen = false;
|
||||
joinThreads();
|
||||
|
||||
return impl->close();
|
||||
}
|
||||
|
||||
bool Communication::isOpen() {
|
||||
return impl->isOpen();
|
||||
}
|
||||
|
||||
bool Communication::sendPacket(std::vector<uint8_t>& bytes) {
|
||||
// This is here so that other communication types (like multichannel) can override it
|
||||
return rawWrite(bytes);
|
||||
|
||||
Reference in New Issue
Block a user