关闭

Linux环境中USB转串口的应用(minicom)

597人阅读 评论(0) 收藏 举报

看到网上很多人写的都是PL2303驱动,甚至还有人上传了原代码。

自己也准备下载编译一下。

突然发现

jerry@ubuntu:~/tmp$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 004: ID 1a86:7523 Unknown HL-340 USB-Serial adapter
Bus 006 Device 002: ID 046d:c52f Logitech, Inc.
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 003: ID 17ef:4808 Lenovo
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
jerry@ubuntu:~/tmp$ 
我使用的是HL-340 USB,虽然是Unknow adapter, 但是

jerry@ubuntu:~$ dmesg | tail
[ 2428.736594] usb 6-1: configuration #1 chosen from 1 choice
[ 2428.739491] ch341 6-1:1.0: ch341-uart converter detected
[ 2428.752572] usb 6-1: ch341-uart converter now attached to ttyUSB0
[ 3101.732162] usb 6-1: USB disconnect, address 4
[ 3101.732432] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 3101.732460] ch341 6-1:1.0: device disconnected
[ 3104.376321] usb 6-1: new full speed USB device using uhci_hcd and address 5
[ 3104.538928] usb 6-1: configuration #1 chosen from 1 choice
[ 3104.541585] ch341 6-1:1.0: ch341-uart converter detected
[ 3104.554698] usb 6-1: ch341-uart converter now attached to ttyUSB0
看上去好像可用。

于是开始设备,minicom

(1) $ sudo apt-get install minicom

(2) $ su -

(3) # 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        |
            +--------------------------+
(4) set "Serial port setup" as follow:
    +-----------------------------------------------------------------------+
    | 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?                                              |
    +-----------------------------------------------------------------------+
(5)  set "Modem and dialing" as follow:
 +--------------------[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)                        |
 +----------------------------------------------------------------------------+
ps: delete A, B and K

(6) save setup as dfl, save as default settings.

            +-----[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        |
            +--------------------------+
(7) exit minicom and exit root user

(8) $ minicom

可以正常使用minicom了。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:17206次
    • 积分:323
    • 等级:
    • 排名:千里之外
    • 原创:16篇
    • 转载:1篇
    • 译文:0篇
    • 评论:0条
    文章分类