LoginSignup
6
4

More than 5 years have passed since last update.

OS XでFlashMagicを使う場合のCOMポート番号を見つける方法

Posted at

概要

FlachMagic では、実行時にCOMポート番号を設定する必要があります。
しかし、OS XではUSB-Serialアダプターが、仮想装置名で管理していてCOMポート番号が判りません。
そこで、FlashMagicアプリでは、アプリケーション起動時に、/dev/ を調べてシリアルポートとCOM番号のシンボリックリンクをアプリケーション内のフォルダにセットするようにしているようです。
なので、一度 USB-Serialアダプターを接続した後 FlashMagicを起動して設定画面が出てきたら(最初は時間がかかります)このスクリプトを実行すると、COMポート番号に、どの装置が割り当てられているかを表示します。
(ターミナルアプリで以下のコマンドを実行しても同様ですが、いちいちターミナルを開いてコマンドを実行するよりは、一度アプリを作っておけば簡単でしょう。)
(FlashMagicアプリが「アプリケーション」フォルダ内に有る場合)
ls -l /Applications/FlashMagic.app/Contents/Resources/dosdevices/COM*

プログラムのソース

(注:FlashMagicアプリが「アプリケーション」フォルダ内に有ることを前提にしていますので、違う場所に置いてある場合は、パスを適宜修正してお使いください。)

SerchCOM_port.scpt
-- USB−Sereal アダプタが、どのCOMポートに割り当てられているか調べる

set appPath to "/Applications/FlashMagic.app/Contents/Resources/dosdevices"
set cmd to "ls -l " & appPath & "/COM*"
do shell script cmd
set serealDevice to result as text
set orgDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set aList to text items of serealDevice
set AppleScript's text item delimiters to orgDelim
set COMs to ""
repeat with txt in aList
    set pos to offset of "COM" in txt
    set COMs to COMs & characters pos thru -1 of txt & return
end repeat

display dialog COMs
6
4
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
6
4