mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 06:33:33 +08:00
Simplified Frame::parse()
This commit is contained in:
@@ -89,18 +89,6 @@ bool Frame::parse(const CanFrame& can_frame)
|
||||
transfer_type_ = TransferType(bitunpack<17, 2>(id));
|
||||
data_type_id_ = bitunpack<19, 10>(id);
|
||||
|
||||
/*
|
||||
* Validation
|
||||
*/
|
||||
if (frame_index_ > FRAME_INDEX_MAX)
|
||||
return false;
|
||||
|
||||
if ((frame_index_ == FRAME_INDEX_MAX) && !last_frame_) // Unterminated transfer
|
||||
return false;
|
||||
|
||||
if (!src_node_id_.isUnicast())
|
||||
return false;
|
||||
|
||||
/*
|
||||
* CAN payload parsing
|
||||
*/
|
||||
@@ -119,11 +107,7 @@ bool Frame::parse(const CanFrame& can_frame)
|
||||
return false;
|
||||
if (can_frame.data[0] & 0x80) // RESERVED, must be zero
|
||||
return false;
|
||||
|
||||
dst_node_id_ = can_frame.data[0] & 0x7F;
|
||||
if (!dst_node_id_.isUnicast() || (dst_node_id_ == src_node_id_))
|
||||
return false;
|
||||
|
||||
payload_len_ = can_frame.dlc - 1;
|
||||
std::copy(can_frame.data + 1, can_frame.data + can_frame.dlc, payload_);
|
||||
break;
|
||||
@@ -131,7 +115,8 @@ bool Frame::parse(const CanFrame& can_frame)
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return isValid();
|
||||
}
|
||||
|
||||
template <int OFFSET, int WIDTH>
|
||||
|
||||
Reference in New Issue
Block a user