mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 07:13:34 +08:00
Modified CAN driver API: Passing the next pending TX frames into the select() call to facilitate proper prioritization in the driver
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
/**
|
||||
* This limit is defined by the specification.
|
||||
*/
|
||||
enum { MaxCanIfaces = 3 };
|
||||
|
||||
/**
|
||||
* Raw CAN frame, as passed to/from the CAN driver.
|
||||
*/
|
||||
@@ -137,6 +142,9 @@ public:
|
||||
/**
|
||||
* Non-blocking transmission.
|
||||
* If the frame wasn't transmitted upon TX deadline, the driver should discard it.
|
||||
* Note that it is LIKELY that the library will want to send the frames that were passed into the select()
|
||||
* method as the next ones to transmit, but it is NOT guaranteed. The library can replace those with new
|
||||
* frames between the calls.
|
||||
* @return 1 = one frame transmitted, 0 = TX buffer full, negative for error.
|
||||
*/
|
||||
virtual int16_t send(const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags) = 0;
|
||||
@@ -202,12 +210,15 @@ public:
|
||||
* Iface masks will be modified by the driver to indicate which exactly interfaces are available for IO.
|
||||
* Bit position in the masks defines interface index.
|
||||
* Note that it is allowed to return from this method even if no requested events actually happened, or if
|
||||
* there are events that were not requested by the lirary.
|
||||
* there are events that were not requested by the library.
|
||||
* @param [in,out] inout_masks Masks indicating which interfaces are needed/available for IO.
|
||||
* @param [in] pending_tx Array of frames, per interface, that are likely to be transmitted next.
|
||||
* @param [in] blocking_deadline Zero means non-blocking operation.
|
||||
* @return Positive number of ready interfaces or negative error code.
|
||||
*/
|
||||
virtual int16_t select(CanSelectMasks& inout_masks, MonotonicTime blocking_deadline) = 0;
|
||||
virtual int16_t select(CanSelectMasks& inout_masks,
|
||||
const CanFrame* (& pending_tx)[MaxCanIfaces],
|
||||
MonotonicTime blocking_deadline) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
enum { MaxCanIfaces = 3 };
|
||||
|
||||
struct UAVCAN_EXPORT CanRxFrame : public CanFrame
|
||||
{
|
||||
MonotonicTime ts_mono;
|
||||
@@ -108,7 +106,9 @@ public:
|
||||
|
||||
Entry* peek(); // Modifier
|
||||
void remove(Entry*& entry);
|
||||
const CanFrame* getTopPriorityPendingFrame() const;
|
||||
|
||||
/// The 'or equal' condition is necessary to avoid frame reordering.
|
||||
bool topPriorityHigherOrEqual(const CanFrame& rhs_frame) const;
|
||||
|
||||
uint32_t getRejectedFrameCount() const { return rejected_frames_cnt_; }
|
||||
@@ -154,7 +154,8 @@ class UAVCAN_EXPORT CanIOManager : Noncopyable
|
||||
|
||||
int sendToIface(uint8_t iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags);
|
||||
int sendFromTxQueue(uint8_t iface_index);
|
||||
int callSelect(CanSelectMasks& inout_masks, MonotonicTime blocking_deadline);
|
||||
int callSelect(CanSelectMasks& inout_masks, const CanFrame* (& pending_tx)[MaxCanIfaces],
|
||||
MonotonicTime blocking_deadline);
|
||||
|
||||
public:
|
||||
CanIOManager(ICanDriver& driver, IPoolAllocator& allocator, ISystemClock& sysclock,
|
||||
|
||||
Reference in New Issue
Block a user