mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 00:03:33 +08:00
CAN IO flags
This commit is contained in:
@@ -94,6 +94,12 @@ struct CanSelectMasks
|
||||
{ }
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CanIOFlagLoopback = 1 ///< Send the frame back to RX with true TX timestamps
|
||||
};
|
||||
typedef uint16_t CanIOFlags;
|
||||
|
||||
/**
|
||||
* Single non-blocking CAN interface.
|
||||
*/
|
||||
@@ -107,7 +113,7 @@ public:
|
||||
* If the frame wasn't transmitted upon TX deadline, the driver should discard it.
|
||||
* @return 1 = one frame transmitted, 0 = TX buffer full, negative for error.
|
||||
*/
|
||||
virtual int send(const CanFrame& frame, MonotonicTime tx_deadline) = 0;
|
||||
virtual int send(const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags) = 0;
|
||||
|
||||
/**
|
||||
* Non-blocking reception.
|
||||
@@ -121,7 +127,8 @@ public:
|
||||
* @param [out] out_ts_utc UTC timestamp, optional, zero if unknown.
|
||||
* @return 1 = one frame received, 0 = RX buffer empty, negative for error.
|
||||
*/
|
||||
virtual int receive(CanFrame& out_frame, MonotonicTime& out_ts_monotonic, UtcTime& out_ts_utc) = 0;
|
||||
virtual int receive(CanFrame& out_frame, MonotonicTime& out_ts_monotonic, UtcTime& out_ts_utc,
|
||||
CanIOFlags& out_flags) = 0;
|
||||
|
||||
/**
|
||||
* Configure the hardware CAN filters. @ref CanFilterConfig.
|
||||
|
||||
@@ -42,11 +42,13 @@ public:
|
||||
MonotonicTime deadline;
|
||||
CanFrame frame;
|
||||
uint8_t qos;
|
||||
CanIOFlags flags;
|
||||
|
||||
Entry(const CanFrame& frame, MonotonicTime deadline, Qos qos)
|
||||
Entry(const CanFrame& frame, MonotonicTime deadline, Qos qos, CanIOFlags flags)
|
||||
: deadline(deadline)
|
||||
, frame(frame)
|
||||
, qos(uint8_t(qos))
|
||||
, flags(flags)
|
||||
{
|
||||
assert(qos == Volatile || qos == Persistent);
|
||||
IsDynamicallyAllocatable<Entry>::check();
|
||||
@@ -99,7 +101,7 @@ public:
|
||||
|
||||
~CanTxQueue();
|
||||
|
||||
void push(const CanFrame& frame, MonotonicTime tx_deadline, Qos qos);
|
||||
void push(const CanFrame& frame, MonotonicTime tx_deadline, Qos qos, CanIOFlags flags);
|
||||
|
||||
Entry* peek(); // Modifier
|
||||
void remove(Entry*& entry);
|
||||
@@ -127,7 +129,7 @@ private:
|
||||
CanIOManager(CanIOManager&);
|
||||
CanIOManager& operator=(CanIOManager&);
|
||||
|
||||
int sendToIface(int iface_index, const CanFrame& frame, MonotonicTime tx_deadline);
|
||||
int sendToIface(int iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags);
|
||||
int sendFromTxQueue(int iface_index);
|
||||
int makePendingTxMask() const;
|
||||
|
||||
@@ -156,8 +158,8 @@ public:
|
||||
* negative - failure
|
||||
*/
|
||||
int send(const CanFrame& frame, MonotonicTime tx_deadline, MonotonicTime blocking_deadline,
|
||||
int iface_mask, CanTxQueue::Qos qos);
|
||||
int receive(CanRxFrame& frame, MonotonicTime blocking_deadline);
|
||||
int iface_mask, CanTxQueue::Qos qos, CanIOFlags flags);
|
||||
int receive(CanRxFrame& out_frame, MonotonicTime blocking_deadline, CanIOFlags& out_flags);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ public:
|
||||
/**
|
||||
* Refer to CanIOManager::send() for the parameter description
|
||||
*/
|
||||
int send(const Frame& frame, MonotonicTime tx_deadline, MonotonicTime blocking_deadline, CanTxQueue::Qos qos);
|
||||
int send(const Frame& frame, MonotonicTime tx_deadline, MonotonicTime blocking_deadline, CanTxQueue::Qos qos,
|
||||
CanIOFlags flags);
|
||||
|
||||
void cleanup(MonotonicTime ts);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ class TransferSender
|
||||
const DataTypeDescriptor& data_type_;
|
||||
const CanTxQueue::Qos qos_;
|
||||
const TransferCRC crc_base_;
|
||||
CanIOFlags flags_;
|
||||
|
||||
Dispatcher& dispatcher_;
|
||||
|
||||
@@ -35,9 +36,13 @@ public:
|
||||
, data_type_(data_type)
|
||||
, qos_(qos)
|
||||
, crc_base_(data_type.getSignature().toTransferCRC())
|
||||
, flags_(CanIOFlags(0))
|
||||
, dispatcher_(dispatcher)
|
||||
{ }
|
||||
|
||||
CanIOFlags getCanIOFlags() const { return flags_; }
|
||||
void setCanIOFlags(CanIOFlags flags) { flags_ = flags; }
|
||||
|
||||
/**
|
||||
* Send with explicit Transfer ID.
|
||||
* Should be used only for service responses, where response TID should match request TID.
|
||||
|
||||
Reference in New Issue
Block a user