歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux系統中Usb轉串口的使用方法(Ubuntu 10.10)

Linux系統中Usb轉串口的使用方法(Ubuntu 10.10)

日期:2017/2/28 16:27:28   编辑:Linux教程
首先,安裝minicom:sudo apt-get install minicom
在安裝好minicom之後對minicom進行配置,在此,需要注意的一點是在Linux環境下不許要裝Usb轉串口的驅動,在此,使用lsmod命令
z75993971@Ubuntu:~$ lsmod
Module Size Used by
pl2303 13696 0
usbserial 39507 1 pl2303
binfmt_misc 7984 1
可見,linux可以自動識別2303設備
之後在終端中輸入dmesg | grep usb命令
z75993971@ubuntu:~$ dmesg | grep usb
[ 0.497563] usbcore: registered new interface driver usbfs
[ 0.497574] usbcore: registered new interface driver hub
[ 0.497601] usbcore: registered new device driver usb
[ 1.001716] usb 2-3: new high speed USB device using ehci_hcd and address 2
[ 18.178144] input: USB 2.0 Camera as /devices/pci0000:00/0000:00:1d.7/usb2/2-3/2-3:1.0/input/input5
[ 18.178198] usbcore: registered new interface driver uvcvideo
[ 64.090038] usb 6-1: new full speed USB device using uhci_hcd and address 2
[ 64.328761] usbcore: registered new interface driver usbserial
[ 64.328807] usbcore: registered new interface driver usbserial_generic
[ 64.328810] usbserial: USB Serial Driver core
[ 64.362942] usb 6-1: pl2303 converter now attached to ttyUSB0
[ 64.362970] usbcore: registered new interface driver pl2303
注意上面加紅的地方,他指明了設備號為:ttyUSB0
之後,就可以進行mimicom的配置了 http://www.linuxidc.com

在終端中輸入:minicom -s,選擇
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+--------------------------+
配置成如下方式:
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyUSB0 |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : No |
| G - Software Flow Control : No |
| |
| Change which setting? |
+--------------------------------------------------------------------
完成後退出,退出後進入 Modem and dialing 配置成如下方式:
(原因:我們使用的是串口,而不Modem)
+--------------------[Modem and dialing parameter setup]---------------------+
| |
| A - Init string ......... |
| B - Reset string ........ |
| C - Dialing prefix #1.... ATDT |
| D - Dialing suffix #1.... ^M |
| E - Dialing prefix #2.... ATDP |
| F - Dialing suffix #2.... ^M |
| G - Dialing prefix #3.... ATX1DT |
| H - Dialing suffix #3.... ;X4D^M |
| I - Connect string ...... CONNECT |
| J - No connect strings .. NO CARRIER BUSY |
| NO DIALTONE VOICE |
| K - Hang-up string ...... |
| L - Dial cancel string .. ^M |
| |
| M - Dial time ........... 45 Q - Auto bps detect ..... No |
| N - Delay before redial . 2 R - Modem has DCD line .. Yes |
| O - Number of tries ..... 10 S - Status line shows ... DTE speed |
| P - DTR drop time (0=no). 1 T - Multi-line untag .... No |
| |
| Change which setting? (Return or Esc to exit) |
+----------------------------------------------------------------------------+
配置完成後推出,在退出時一定要選擇Save setup as dfl
到此,Minicom的配置完成,連上串口線,打開開發板電源即可看到串口輸出的打印信息

===== 三.Minicom的使用 =====

1.minicom的執行
用指令"rpm -qa | grep minicom"來確認是否安裝了minicom,回車後會顯示minicom 的版本信息.
第一次 啟動時:
即輸入 minicom提示 錯誤。則 需: minicom -s
啟動
出現配置菜單:選serial port setup
進入串口配置
輸入A配置串口驅動為/dev/ttyS0
輸入E配置速率為115200 8N1
輸入F將 Hardware Flow Control 設 為 NO
回車 退出
由於我們使用minicom作為超級終端控制路由器等設 備, 而不是控制modem, 所以需要修改Modem and dialing, 將Init string, Reset string, Hang-up string設置為空. 設置完成後選擇Save setup as dfl將當前設置保存為默認設置.
在配置菜單 選Save setup as df1保存(一定要記得這一步)
選Exit退出

下次在輸入minicon 即可直接進入。
命令minicom是進入串口超級終端畫面,而minicom -s為配置minicom
說明/dev/ttyS0 對應為串口0 為你連接開發板的端口。

注意:非正常關閉minicom,會在/var/lock下創建幾個文件LCK*,這幾個文件阻止了minicom的運行,將它們刪除後即可恢復
Copyright © Linux教程網 All Rights Reserved