diff --git a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp index 37bbb03b97..80cd7f50cd 100644 --- a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp +++ b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp @@ -172,6 +172,12 @@ public: */ virtual uavcan::uint64_t getErrorCount() const; + /** + * Returns number of frames pending in the RX queue. + * This is intended for debug use only. + */ + unsigned getRxQueueLength() const; + /** * Returns last hardware error code (LEC field in the register ESR) */ diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp index 2b8351dacf..0a145a0898 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp @@ -518,6 +518,12 @@ uavcan::uint64_t CanIface::getErrorCount() const return error_cnt_ + rx_queue_.getOverflowCount(); } +unsigned CanIface::getRxQueueLength() const +{ + CriticalSectionLocker lock; + return rx_queue_.getLength(); +} + uavcan::uint8_t CanIface::yieldLastHardwareErrorCode() { CriticalSectionLocker lock; diff --git a/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp b/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp index 8e9202f29f..558f3d77a4 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp +++ b/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp @@ -124,7 +124,16 @@ public: { lowsyslog("Spin failure: %i\n", spin_res); } + lowsyslog("Time sync master: %u\n", unsigned(time_sync_slave.getMasterNodeID().get())); + + lowsyslog("Memory usage: used=%u free=%u\n", + node.getAllocator().getNumUsedBlocks(), node.getAllocator().getNumFreeBlocks()); + + lowsyslog("RX queues: %u %u\n", + can.driver.getIface(0)->getRxQueueLength(), + can.driver.getIface(1)->getRxQueueLength()); + node.logInfo("app", "UTC %* sec, %* corr, %* jumps", uavcan_stm32::clock::getUtc().toMSec() / 1000, uavcan_stm32::clock::getUtcSpeedCorrectionPPM(),