在linux系統上同樣可以配置串口,使用串口來與其他設備進行通信。
在配置串口前,我們有取得linux系統的root權限,這個很重要。否則無法完成下面步驟。
1.切換到root用戶.
[root@localhost ~]#su root
2. 查找有效的串設備.
[root@localhost ~]#cat /proc/devices
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS (這個是串口設備)
5 /dev/tty
5 /dev/console
5 /dev/ptmx
6 lp
7 vcs
10 misc
13 input
21 sg
29 fb
128 ptm
136 pts
180 usb
189 usb_device
253 usb_endpoint
254 pcmcia
如果是普通串口設備, 設備名前綴爲ttyS, 第一串口爲ttyS0, 第二串口爲ttyS1,依次類推.
3. 配置ttyS設備
[root@localhost ~]#minicom -s ttyS0
會出現一個configuration窗口,
┌──[configuration]────┐
│ Filenames and paths │
│ File transfer protocols │
│ Serial port setup │ (串口配置選項)
│ Modem and dialing │
│ Screen and keyboard │
│ Save setup as ttyS0 │
│ Save setup as.. │
│ Exit │
│ Exit from Minicom │
└───────────────┘
選擇Serial port setup配置. 會出現如下窗口:
┌────────────────────────────────────────────┐
│ A - Serial Device : /dev/ttyS0 (設備名稱)
│ B - Lockfile Location : /var/lock
│ C - Callin Program :
│ D - Callout Program :
│ E - Bps/Par/Bits : 9600 8N1 (波特率和數據位設置)
│ F - Hardware Flow Control : No (數據流控制設置選項)
│ G - Software Flow Control : No
│ │
│ Change which setting? │
└───────────────────────────────────────────┘
我的設置如上所示, 設置完成後,按esc鍵,返回到 Change which setting?項上按回車退出當前窗口, 回到前一窗口.
選中Save setup as ttyS0,回車保存設置. 再按Exit from Minicom退出Minicom,返回控制檯.
4. 啓動minicom
[root@localhost ~]#minicom
這裏默認就會連接已經配置好的串口了