Driver: DXX: Fix ION, FIRE, ValueCAN3, & VividCAN

This commit is contained in:
Kyle Schwarz
2025-09-10 10:11:08 -04:00
parent fbdab1e998
commit 8b7e2556a0
12 changed files with 42 additions and 36 deletions
+2 -10
View File
@@ -38,18 +38,10 @@ bool Driver::waitForRx(std::function<bool()> predicate, std::chrono::millisecond
}
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;
if(limit > (readBuffer.size() + 4))
limit = (readBuffer.size() + 4);
// wait until we have enough data, or the timout occurs
// wait until we have enough data, or the timeout occurs
waitForRx(limit, timeout);
size_t actuallyRead = std::min(readBuffer.size(), limit);
size_t actuallyRead = readBuffer.size();
bytes.resize(actuallyRead);
readBuffer.read(bytes.data(), 0, actuallyRead);
@@ -24,6 +24,7 @@ void MultiChannelCommunication::spawnThreads() {
void MultiChannelCommunication::joinThreads() {
closing = true;
ringBufCV.notify_all();
if(hidReadThread.joinable())
hidReadThread.join();
for(auto& thread : vnetThreads) {
@@ -179,6 +180,9 @@ void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
while(!closing) {
std::unique_lock lk(ringBufMutex);
ringBufCV.wait(lk);
if(closing) {
break;
}
if(vnetPacketizer->input(packetRB)) {
for(const auto& packet : vnetPacketizer->output()) {
std::shared_ptr<Message> msg;