2012年9月4日 星期二

VMWare: 使用 Host 的 Serial Port

要怎麼設定 VMware 讓 virtual machine 可以使用 host computer 的 serial port 呢?底下是設定的步驟,我用的是 Windows 系統,所以底下將以 Windows 的設定為例說明:

首先,先關閉 Virtual Machine,然後在 VMWare Player 選擇指定的 Virtual Machine 後 (例如 Ubuntu),按右鍵點擊 "Virtual Machine Settings…":

image

按下 Add 鈕:

image

選擇 "Serial Port",然後按下 Next 鈕:

image

選擇 "Use physical serial port on the host":

image

接著選擇 Physical Serial port (也就是實際存在的 Serial Port):

image

按下 "Finish" 關閉設定畫面,然後重新啟動 Virtual Machine 就可以了。

Serial Port 的對應關係

設定好後,那麼 Serial Port 會對應到 Linux  /dev/ 底下的哪個 device 呢?簡單說明一下:VMware 對 Serial Port Mapping 的處理方式是這樣,假如你有 COM1 和 COM2 兩個 Serial Port,那麼 COM1 會對應成 /dev/ttyS0,而 COM2 則是 /dev/ttyS1。假如你有 COM1 和 COM7 兩個 Serial Port (假設 COM7 是 USB to Serial port),那麼 COM1 一樣是 /dev/ttyS0,而 COM7 則會對應成 /dev/ttyS1。

Serial Port 測試

話說回來,我們用 Serial Port 要幹嘛?嗯...,你也許可以用 Serial Port 接 Modem,也許也可以用 Serial Port 接 Arduino 做一些監控的應用。假設你對 Arduino 有基本的了解,那麼可以照底下的方法測試 Serial Port 通不通:

1. 點選 VMware Player 選單的 "Removable Devices > Serial Port x > Disconnect" 先暫時停用 Virtual Machine 的 Serial Port:

2012-09-04_00h17_23

2. 上傳 File > Examples > 01.Basics > AnalogReadSerial 到 Arduino 板子上

3. 點選 VMware Player 選單的 "Removable Devices > Serial Port x > Connect" 啟用 Virtual Machine 的 Serial Port

4. 執行 sudo cat /dev/ttySx (x 是你的 Serial Port number)

如下圖所示,假如一切順利,就會看到 Arduino 傳過來的 Analog 讀值囉!

image 

參考資料

0 意見: