fix(crane_robot_receiver): フィードバック受信のチェックサム検証を有効化#1396
Open
HansRobo wants to merge 1 commit into
Open
Conversation
Member
Author
|
チェックサムの計算方法が多分違う |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
crane_robot_receiverのフィードバック受信パイプラインにおいて、実装済みでありながら呼び出されていなかったチェックサム検証を有効化します。これにより、ペイロードが破損したパケットを正しく不正パケットとして弾けるようになります。問題
robot_receiver_node.cppのonReceiveは、受信パケットに対してサイズ検証と SYNC バイト検証のみを行っており、protocol::validatePacket/protocol::computeChecksumといった実装済みのチェックサム検証 API を一切呼び出していませんでした。その結果、SYNC バイトは一致するもののペイロードが破損したパケットも valid として受理され、誤ったフィードバックデータが下流へ流れていました。また、
checksum_error_count_がインクリメントされないため、診断値が常に 0 となり、チェックサム異常を検知できない状態でした。原因
受信パイプライン (
onReceive) にチェックサム検証ステップが組み込まれておらず、SYNC チェック通過後ただちにparseBufferへ進んでいたためです。修正内容
onReceiveの SYNC バイト検証直後に、チェックサム検証ステップを追加しました。protocol::offset::CHECKSUM(オフセット 2)に格納された受信チェックサム値をprotocol::readRawByteで取得。protocol::computeChecksum(COUNTERバイト以降からPACKET_SIZEまでの総和の下位 8 bit)と比較。++checksum_error_count_および++invalid_packet_count_を行い、parseBuffer/valid_packet_count_をスキップしてreturn。サイズ検証が既に通過しているため、
computeChecksumの走査範囲はバッファ境界内に収まります。修正は当該検証ロジックの追加のみに限定しています。検証
cwm の独立オーバーレイ worktree 上で、対象パッケージ
crane_robot_receiverを colcon build(--no-rdeps)でコンパイルし、ビルドが正常完了することを確認しました("Build complete."、ビルドエラーなし)。レビュー観点
offset::CHECKSUM= 2)と算出方法(computeChecksum:COUNTER以降の総和下位 8 bit)の使い方が protocol API と整合しているか。checksum_error_count_とinvalid_packet_count_の両方をインクリメントし、valid_packet_count_/parseBufferをスキップしているか。本PRはソースコード監査ワークフローで検出・敵対的検証されたバグに対する単一修正です。