mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 19:13:33 +08:00
STM32: NuttX driver fixed
This commit is contained in:
@@ -232,6 +232,11 @@ public:
|
||||
*/
|
||||
uavcan::CanSelectMasks makeSelectMasks(const uavcan::CanFrame* (& pending_tx)[uavcan::MaxCanIfaces]) const;
|
||||
|
||||
/**
|
||||
* Whether there's at least one interface where receive() would return a frame.
|
||||
*/
|
||||
bool hasReadableInterfaces() const;
|
||||
|
||||
/**
|
||||
* Returns zero if OK.
|
||||
* Returns negative value if failed (e.g. invalid bitrate).
|
||||
|
||||
@@ -706,6 +706,17 @@ uavcan::CanSelectMasks CanDriver::makeSelectMasks(const uavcan::CanFrame* (& pen
|
||||
return msk;
|
||||
}
|
||||
|
||||
bool CanDriver::hasReadableInterfaces() const
|
||||
{
|
||||
#if UAVCAN_STM32_NUM_IFACES == 1
|
||||
return !if0_.isRxBufferEmpty();
|
||||
#elif UAVCAN_STM32_NUM_IFACES == 2
|
||||
return !if0_.isRxBufferEmpty() || !if1_.isRxBufferEmpty();
|
||||
#else
|
||||
# error UAVCAN_STM32_NUM_IFACES
|
||||
#endif
|
||||
}
|
||||
|
||||
uavcan::int16_t CanDriver::select(uavcan::CanSelectMasks& inout_masks,
|
||||
const uavcan::CanFrame* (& pending_tx)[uavcan::MaxCanIfaces],
|
||||
const uavcan::MonotonicTime blocking_deadline)
|
||||
|
||||
@@ -105,7 +105,7 @@ int BusEvent::poll(::file* filp, ::pollfd* fds, bool setup)
|
||||
* - Transmission complete. This event is edge-triggered.
|
||||
* FIXME Since TX event is edge-triggered, it can be lost between poll() calls.
|
||||
*/
|
||||
fds->revents |= fds->events & ((can_driver_.makeSelectMasks().read == 0) ? 0 : POLLIN);
|
||||
fds->revents |= fds->events & (can_driver_.hasReadableInterfaces() ? 0 : POLLIN);
|
||||
if (fds->revents != 0)
|
||||
{
|
||||
(void)sem_post(fds->sem);
|
||||
|
||||
Reference in New Issue
Block a user