diff --git a/libuavcan_drivers/linux/apps/test_socket.cpp b/libuavcan_drivers/linux/apps/test_socket.cpp index 4beee75cc3..a8a39a09f9 100644 --- a/libuavcan_drivers/linux/apps/test_socket.cpp +++ b/libuavcan_drivers/linux/apps/test_socket.cpp @@ -51,7 +51,7 @@ static void testSocketRxTx(const std::string& iface_name) if1.poll(true, true); if1.poll(true, true); ENFORCE(0 == if1.getErrorCount()); - ENFORCE(!if1.hasPendingTx()); + ENFORCE(!if1.hasReadyTx()); ENFORCE(if1.hasReadyRx()); // Second loopback /* @@ -63,7 +63,7 @@ static void testSocketRxTx(const std::string& iface_name) if2.poll(true, true); if2.poll(true, true); ENFORCE(1 == if2.getErrorCount()); // One timed out - ENFORCE(!if2.hasPendingTx()); + ENFORCE(!if2.hasReadyTx()); ENFORCE(if2.hasReadyRx()); /* @@ -101,7 +101,7 @@ static void testSocketRxTx(const std::string& iface_name) ENFORCE((clock.getUtc() - ts_utc).getAbs().toMSec() < 10); ENFORCE(0 == if1.receive(frame, ts_mono, ts_utc, flags)); - ENFORCE(!if1.hasPendingTx()); + ENFORCE(!if1.hasReadyTx()); ENFORCE(!if1.hasReadyRx()); /* @@ -126,7 +126,7 @@ static void testSocketRxTx(const std::string& iface_name) ENFORCE((clock.getUtc() - ts_utc).getAbs().toMSec() < 10); ENFORCE(0 == if2.receive(frame, ts_mono, ts_utc, flags)); - ENFORCE(!if2.hasPendingTx()); + ENFORCE(!if2.hasReadyTx()); ENFORCE(!if2.hasReadyRx()); } @@ -182,7 +182,7 @@ static void testSocketFilters(const std::string& iface_name) if1.poll(true, true); if2.poll(true, false); } - ENFORCE(!if1.hasPendingTx()); + ENFORCE(!if1.hasReadyTx()); ENFORCE(!if1.hasReadyRx()); ENFORCE(0 == if1.getErrorCount()); ENFORCE(if2.hasReadyRx()); @@ -290,7 +290,7 @@ static void testDriver(const std::vector& iface_names) ENFORCE((clock.getMonotonic() - ts_mono).getAbs().toMSec() < 10); ENFORCE((clock.getUtc() - ts_utc).getAbs().toMSec() < 10); - ENFORCE(!driver.getIface(i)->hasPendingTx()); + ENFORCE(!driver.getIface(i)->hasReadyTx()); ENFORCE(!driver.getIface(i)->hasReadyRx()); } diff --git a/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp b/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp index 5b0c2dbb26..6aa0504696 100644 --- a/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp +++ b/libuavcan_drivers/linux/include/uavcan_linux/socketcan.hpp @@ -268,7 +268,7 @@ class SocketCanIface : public uavcan::ICanIface void pollWrite() { - while (!tx_queue_.empty() && (frames_in_socket_tx_queue_ < max_frames_in_socket_tx_queue_)) + while (hasReadyTx()) { const TxItem tx = tx_queue_.top(); @@ -437,8 +437,11 @@ public: } } - bool hasPendingTx() const { return !tx_queue_.empty(); } - bool hasReadyRx() const { return !rx_queue_.empty(); } + bool hasReadyRx() const { return !rx_queue_.empty(); } + bool hasReadyTx() const + { + return !tx_queue_.empty() && (frames_in_socket_tx_queue_ < max_frames_in_socket_tx_queue_); + } std::int16_t configureFilters(const uavcan::CanFilterConfig* const filter_configs, const std::uint16_t num_configs) override @@ -618,7 +621,7 @@ public: for (unsigned i = 0; i < num_ifaces_; i++) { pollfds_[i].events = POLLIN; - if (ifaces_[i]->hasPendingTx() || (inout_masks.write & (1 << i))) + if (ifaces_[i]->hasReadyTx() || (inout_masks.write & (1 << i))) { pollfds_[i].events |= POLLOUT; }