Commands can now only be sent when the device is open

This commit is contained in:
EricLiu2000
2019-06-13 16:01:35 -04:00
parent 8a6073a9cf
commit dc4f96affb
+5
View File
@@ -39,6 +39,11 @@ bool ICommunication::readWait(std::vector<uint8_t>& bytes, std::chrono::millisec
} }
bool ICommunication::write(const std::vector<uint8_t>& bytes) { bool ICommunication::write(const std::vector<uint8_t>& bytes) {
if(!isOpen()) {
err(APIError::DeviceCurrentlyClosed);
return false;
}
if(writeBlocks) { if(writeBlocks) {
std::unique_lock<std::mutex> lk(writeMutex); std::unique_lock<std::mutex> lk(writeMutex);
if(writeQueue.size_approx() > writeQueueSize) { if(writeQueue.size_approx() > writeQueueSize) {