STM32: NuttX driver fixed

This commit is contained in:
Pavel Kirienko
2015-07-08 02:15:57 +03:00
parent e36d276e1f
commit 4f79527860
3 changed files with 17 additions and 1 deletions
@@ -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);