LoginSignup
2
3

More than 3 years have passed since last update.

シリアルポートがない場合の試験方法についての提案

Last updated at Posted at 2020-01-17

試験環境がない方のための解決策を提示いたします。

提案

Null-modem(com0com)を使用した仮想シリアルポートでの試験を提案いたします。

事例

組み込み機器等、対向機が存在しない環境において、試験を効率的に進める手順を案内いたします。
事前に試験ができるため、品質の高いプログラムにできることがあります。
対向機をシミュレーションするプログラムを書き、試験を実施することが可能になります。

動作環境

  • Windows 10 (3.xを使用してください)
    • 有志により公式署名済みドライバを内包されています
  • Windows 10より前

注意事項

ペアとなるシリアルポートを開いていない場合、Writeが完了しません。
通常、シリアルポートは、非同期書き込みであるため、機器が接続されていなくても書き込まれます。
仮想シリアルポートでは対象のポートが開いていない場合はブロックされます。

免責

本内容はWTFPL2で、無保証です。
ただし、com0comに由来する画面や文言はGPL2のようです。

手順

ソフトウェアをダウンロード

https://sourceforge.net/projects/com0com/
2020/01/18時点でv3.0.0.0が最新の模様。

セットアップ

image.png
image.png
image.png
※初期設定でペアを追加するかどうかの設定です。手順上、どちらか必ずチェックしてください。
image.png
image.png
※最大2回表示されますので、インストールしてください。
image.png
※ひとまず、セットアップは完了
image.png

セットアップ確認

スタートimage.pngで右クリックしてデバイスマネージャを起動します。
image.png
com0comのアイコンに警告マークが出ていないことを確認してください。
トラブルシューティング:
配布されているバージョンによっては警告が出ている状態となります。
対象のデバイスを右クリックし、ドライバの更新を実施してください。(なぜかWindows update経由で最新のドライバが入ります)

初期設定

image.png
.NET Framework 3.5が必要のようです。
image.png
このまま.NET 3.5をインストールするか、ソースコードを取得して.NET 4.5(VC++)でビルドしましょう(白目)。
setupg.exe ←.NET 4.5版、カスタムビルドなので、自己責任で。ファイル名はsetupg.exeへ変更してセットアップディレクトリに配置してください。(SHA256: 752BAC7C40CE28F56C75C63DF07C2E51F4B1CA7BA097AE8833F9F2E2883E96BF)。

設定画面

image.png

まずはボタンの説明:

名称(英語) 説明 ツールチップ(英語)
Add Pair ペアを追加 Add a new port pair with default parameters.
Remove ペアを削除 Remove the selected port pair.
Reset リセット Reload the current parameters and redraw the form.
Apply 適用(青色の変更箇所を反映) Apply the changed parameters (highlighted with blue color).

各種チェックボックスの説明:

名称(英語) 説明 ツールチップ(英語)
use Ports class 自動で番号を採用 Allow Ports class installer to set the real port name. The Ports class installer selects the COM port number and sets the real port name to COM, where is the selected port number. Thereafter you will be able to change port number.
emulate baud rate 速度をエミュレート(推奨) Enable/disable baud rate emulation in the direction to the paired port.
enable buffer overrun バッファオーバーランを受信可否 Enable/disable receive buffer overrun.
enable plug-in mode ペア側が閉じているとき非表示 Enable/disable plug-in mode. The plug-in mode port is hidden and can't be open if the paired port is not open.
enable exclusive mode ポートが使用中のとき非表示 Enable/disable exclusive mode. The exclusive mode port is hidden if it is open.
enable hidden mode ポート一覧から非表示にする Enable/disable hidden mode. The hidden mode port is hidden as it is possible for port enumerators.

※上記設定で、emulate baud rateにチェックを入れることを推奨します。チェックがない場合、ボーレート以上のスピードで通信します。

下段の図:
なにこれ凄い。知らなかった。
One green pin can be wired to one red pin.
1つの緑のピンは1つの赤いピンへつなぐことができる。
One red pin can be wired to multiple green pins.
1つの赤いピンは複数の緑のピンへつなぐことができる。
Double click a green pin to add/remove inverter.
ダブルクリックすると反転回路を入れることができる。

名称(英語) 説明 ツールチップ(英語)
RX 受信 RX - receive data.
TX 送信 TX - transmit data.
DTR - DTR - data terminal ready.
DSR - DSR - data set ready.
DCD - DCD - data carrier detect.
RTS - RTS - request to send.
CTS - CTS - clear to send.
RI RI - ring indicator.
OUT1 OUT1 - auxiliary output 1.
OUT2 OUT2 - auxiliary output 2.
OPEN OPEN - logical ON if the port is open.
ON ON - logical ON.

tips

Teratermで仮想シリアルポートが表示されない場合:
名称がCOMnnとなっていない可能性があります。
use Ports classのチェックを入れる又は、COMnnとなるように名称を変更しましょう。

参考文献

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3