-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:コードチェック機能の実装 #362
base: main
Are you sure you want to change the base?
feat:コードチェック機能の実装 #362
Conversation
Deploying kaniwriter with Cloudflare Pages
|
@@ -23,7 +24,7 @@ const enterWriteModeKeyword: Record<Target, RegExp> = { | |||
} as const; | |||
|
|||
const exitWriteModeKeyword: Record<Target, RegExp> = { | |||
ESP32: /mrubyc-esp32: End mrbwrite mode/, | |||
ESP32: /mruby\/c v\d(.\d+)* start/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
意図が分かりづらいので何かしらのコメントが欲しいです。
@@ -262,7 +263,11 @@ export class MrubyWriterConnector { | |||
await this.sendCommand("execute"); | |||
} | |||
|
|||
return Success.value(null); | |||
const crc = crc8Calculator(binary); | |||
const crcRes = writeRes.value.split("+OK")[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
意図が分かりづらいので、"".match(//)
を使って正規表現で取得するのがよさそうです。
const crcRes = writeRes.value.split("+OK")[1]; | |
const crcRes = writeRes.value.match(/^\+OK (?<hash>[0-9a-zA-Z]+)$/)?.groups?.hash; |
のような感じでしょうか?(テキトーに書いたのでちゃんと検証していません)
if (crc !== undefined && crcRes !== undefined) | ||
this.verify(crc, parseInt(crcRes, 16)); | ||
return Success.value(writeRes.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crcRes
がundefined
でないこともそうですが、parseInt(crcRes, 16)
がNaN
でないことも検証するべきでしょう。crcRes
が常に数値に変換できるとは限らないからです。
async verify(culcHash: number, retHash: number) { | ||
if (culcHash === retHash) { | ||
this.handleText("\r\n Verify Success\r\n"); | ||
return true; | ||
} else { | ||
this.handleText("\r\n Verify Failed\r\n"); | ||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify
に持たせる機能が少なすぎると思います。バイナリからハッシュ値を作って、verify
コマンドを送信して結果を受けとって検証する一連の流れを抽象化すべきです。
@@ -2,6 +2,7 @@ import { | |||
CheckCircleRounded as CheckCircleRoundedIcon, | |||
Edit as EditIcon, | |||
Flag as FlagIcon, | |||
Plagiarism, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
流石にPlagiarism(=盗作)はよくない気がします。Document SearchやData Checkはどうでしょうか?
close #295
ページに検証というボタンを追加
押すとverifyをマイコン側へ送信する
書き込み終了時の+DONEを+OK [ハッシュ値]に変更しているマイコンに対しては、書き込んだ時に合わせてコードチェックをするようにした