Skip to content

C# 版から失われていた挙動を戻す(Auto Connect、CR 改行、Show CR/LF など) - #9

Merged
771-8bit merged 11 commits into
devfrom
fix/csharp-parity
Nov 5, 2026
Merged

771-8bit merged 11 commits into
devfrom
fix/csharp-parity

Conversation

@771-8bit

@771-8bit 771-8bit commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Summary

Restores behavior of the C# version (v0.0.8) that the Tauri/Rust rewrite had lost, found by checking the blog post and the C# source against the current app. Based on dev, so after this is merged, #8 carries everything and beta.2 is released once. One commit per item:

  • A lone CR ends a line (CRLF = one break, LF CR = two), also across chunk boundaries
  • Port names no longer read USB Serial Port (COM5) (COM5)
  • Hex send accepts the C# separators and one-digit bytes (0A-0B, 1,2,3, 0x41). Before, 12 3 4 was silently sent as 12 34. Invalid bytes are named under the input, not in a blocking dialog
  • Line-break-only input is not added to the send history
  • Larger font in the Send box than in the receive view
  • Show CR/LF / Show NUL in the ASCII view (default off; hidden CR/LF still copy as line breaks)
  • Timestamps in the Hex view, and in Hex-mode Copy (Hex-mode Save stays raw bytes)
  • "Copied" / "Saved" / "Nothing to copy" toast
  • Auto Reconnect → Auto Connect as in C#: connects to the selected port whenever it is available (startup, plug-in, after reset). Disconnect / Cancel turns it off. Shows why when the port is in use and backs off to 1 s. 200 ms retries. New setting key, off by default
  • Defaults: DTR and RTS off, so connecting resets neither an Uno (DTR) nor an ESP32 (RTS). A ? next to DtrEnable / RtsEnable explains the Arduino cases on hover. Other defaults follow C#: no line ending, Send with Enter on, Line Wrap off, separator >
  • README and CHANGELOG (folded into the beta.2 section)

Owner decisions: no "User's Note" field; parity / stop bits / flow control stay as the serialport crate supports them; DTR off by default. Designs were reviewed before implementation.

Verification

  • Every commit checked on its own: tsc / eslint / prettier / vitest, cargo fmt / clippy / test. Final state: frontend 233 tests, Rust 441 tests, Node MCP smoke test.
  • In the app (com0com COM15/COM16):
    • CR-only, CRLF, NUL, TAB and LF CR data, with Show CR/LF / Show NUL off and on
    • Drag-selection copy keeps the line breaks while CR/LF are hidden
    • Hex view timestamps and Hex Copy with timestamps; the Copied toast
    • Auto Connect: turning it on while idle, connecting at startup after a restart, Disconnect turning it off, and a port held by another program (message, then connects once it is released)
    • The ? hover note
  • Not verified on real boards: whether an Uno / ESP32 is actually reset by the defaults, or how native-USB boards behave with DTR off. The reasoning is the boards' auto-reset circuits, not a measurement.

🤖 Generated with Claude Code

771-8bit and others added 11 commits November 5, 2026 14:38
C# 版は CR だけの改行も改行として表示していたが、行索引が LF しか見ておらず、
CR で行を終える機器の出力が 1 行に繋がっていた。

- LF・CR・CRLF をそれぞれ 1 つの改行とする(CRLF は 1 つ、LF CR と CR CR は 2 つ)
- CR の次が LF かはチャンクをまたいで判定する。チャンク末尾の CR は次のバイトまで
  保留し、索引が縮むことはない
- ResumeBoundary を LineIndexer にまとめ、保留中の CR も持たせる。切断で保留が
  失われても再開位置が行頭として入る

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows の USB 機器はフレンドリ名がすでに " (COM5)" で終わるため、一覧が
"USB Serial Port (COM5) (COM5)" になっていた。製品名の末尾がそのポート名の
括弧書きなら取り除いてから "製品名 (COM5)" にする。形式は変えないので、
portPath / extract_port_path の解釈と MCP の ports もそのまま。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版は '-' ' ' ',' '.' '/' で区切り、各トークンを 1 バイト(1〜2 桁)として
読んでいた。新版は空白だけを無視して 2 桁ずつ組にしていたため、`0A-0B` は
エラーになり、`12 3 4` は黙って 0x12 0x34 を送っていた(誤送信)。

- 空白・, - . / : で区切り、1〜2 桁のトークンを 1 バイトとする。0x 接頭辞も可
- 3 桁以上の偶数桁のトークンは 2 桁ずつ(`48656C6C6F` は従来どおり)
- それ以外(`123` のような奇数桁、16 進でない文字)は推測せずにエラー。どの
  トークンかを入力欄の下に表示し、その間は Send を押せない(ブロックする
  alert をやめた)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版の規則どおり、CR/LF を除くと空になる入力は送信はするが履歴に入れない。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版は入力ミスを防ぐため送信欄を 16pt(受信欄 12pt)にしていた。
送信欄を 13px から 17px にする。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版には Show [CRLF] / Show [NUL](既定 OFF)があり、OFF では改行を普通の改行
として、NUL を消して表示していた。新版は常に制御文字を記号で出すため、全行の
末尾に CR LF の記号が並んでいた。

- ASCII 表示に Show CR/LF と Show NUL(既定 OFF、設定は保存)を追加
- Show CR/LF が OFF のとき CR・LF を隠し、TAB は実際のタブで表示する。隠した
  CR・LF は大きさ 0 の span に残すので、選択範囲のコピーでも改行は消えない
  (display:none では選択に含まれず、コピー処理が改行を失う)
- Show NUL が OFF のとき NUL を表示しない(コピーにも含めない。C# 版と同じ)
- 表示の切り替えだけで、受信データ・Save・Copy の全体出力は変わらない

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版はバイナリ表示でも受信のまとまりごとに時刻を付けていた。新版は Hex 表示で
Timestamp を選べなかった。

- Hex 表示でも Timestamp を選べるようにし、16 バイトの行ごとに先頭バイトの受信
  時刻を出す(get_display_rows に show_timestamp、行に timestamp)
- 切り替えたら行を取り直す(取得済みの行には時刻が無い/有る)
- Timestamp ON の Copy は各行に時刻と区切りを付ける。Save は Hex 表示では常に
  受信したバイトのまま(handleExport で ASCII 表示に限定)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版は Copy・Save のあとに自動で閉じるメッセージ("Copied" など)を出し、空の
ときは警告していた。新版は成功しても何も出ず、空の Copy は無反応だった。

- "Copied" / "Saved" / "Nothing to copy" / "Nothing to save" を 1.5 秒の
  トーストで出す(role=status、クリックを妨げない)
- 空の Save の alert もトーストにした(alert は JS を止め、再接続の照合も止まる)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C# 版の Auto Connect は、ポートが開いていなければ選択中のポートを 200 ms ごとに
開こうとしていた(起動時やデバイスを初めて挿したときも接続し、Disconnect で
OFF になる)。新版の Auto Reconnect は、接続中に失ったデバイスが戻ったときしか
開かなかった。

- ON の間、ポートが開いていなければ選択中のポートが開け次第開く(起動時・挿した
  とき・ON にしたとき・ポートを選び直したとき)。起動時は前回のポートを、無くても
  選択したまま "(not present)" で待つ
- 自動で開くときは常に reopen_port(同じキャプチャに追記)。新しいセッションに
  するのは Connect ボタンだけ(SYS-F-803)
- Disconnect と待機中の Cancel で OFF にする(C# 版と同じ。OFF にしないと
  即座に開き直す)
- 一覧にあるのに開けない(他のプログラムが使用中など)ときは 5 回失敗した後
  1 s 間隔に落とし、"(cannot open the port)" と理由(ツールチップ)を出す
- 照合間隔を 500 ms から C# 版と同じ 200 ms に
- 設定は新しいキー autoConnect(既定 OFF)。起動時にポートを開くようになったので
  旧 Auto Reconnect の ON は引き継がない
- 表示は "Connected automatically …"。ブリッジ / MCP の reconnecting の説明も
  自動接続の待機を含む文言に(プロトコルの名前は変えない)
- docs 21 SYS-F-807 / 23 / 24 / 27、FT232H 治具の説明を更新

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ポートを開いただけでボードがリセットされないよう、DTR と RTS を既定 OFF にする。
DTR ON は Arduino Uno 型(CH340 互換機を含む)をリセットし、DTR OFF のままの
RTS ON は ESP32 系の自動リセット回路でチップをリセット状態に保つ。

- DtrEnable / RtsEnable の横に "?" を置き、ホバー(キーボードのフォーカスでも)で
  注記を出す。DTR は Uno 型がリセットされること、USB 直結のボード(Leonardo、
  Pico、ESP32-S2/S3/C3)は DTR ON にしないと送ってこない場合があること。RTS は
  ESP32 系で DTR OFF のまま ON にするとリセット状態になること
- ポートを開いた直後は DTR を RTS より先に設定する(逆順だと ESP32 系で一瞬
  RTS だけが ON になりリセットがかかる)。順序をコメントで固定
- そのほかの既定値は C# 版に合わせる: 送信の改行なし(LF だった)、Send with
  Enter ON、Line Wrap OFF、タイムスタンプの区切り " > "(選択肢に追加)
- 保存済みの設定はそのまま使う(変わるのは新規インストールだけ)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
beta.2 と同じリリースで出すので、CHANGELOG は beta.2 の節に追記する。README の
機能一覧(Auto Connect、Show CR/LF・NUL、両表示のタイムスタンプ、Hex 送信の書き方)
と、DTR/RTS の既定値と Arduino での注意を更新。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@771-8bit
771-8bit merged commit 7cffced into dev Nov 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant