當前位置:首頁 » 操作系統 » linux應用串口

linux應用串口

發布時間: 2022-02-22 02:04:47

1. linux 怎麼 在 驅動中 使用串口

Linux發行版自帶usb to serial驅動,以模塊方式編譯驅動,在內核源代碼目錄下運行Make MenuConfig選擇Devces
drivers-->USB seupport--> <M>USB Serial Converter support
--> <M> USB driver for GSM and CDMA modems & [*]USB Generic
Serial Driver,保存退出。運行make
moles,編譯成功後可找到usbtoserial.ko及option.ko兩個驅動(2.6以上內核版本模塊驅動用.ko表示)。

2. 請問程序中linux如何獲取可用的串口列表

dmesg | grep tty

下面是一個例子,例子中採用的是USB轉串口線(pl2303)。

插入線:
$ dmesg|grep tty
[ 0.000000] console [tty0] enabled
[ 1.248404] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 1.624590] 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 12.618301] usb 5-2: pl2303 converter now attached to ttyUSB0

拔出線:
$ dmesg|grep tty
[ 0.000000] console [tty0] enabled
[ 1.248404] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 1.624590] 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 12.618301] usb 5-2: pl2303 converter now attached to ttyUSB0
[ 375.392303] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0

這樣程序中應該不難判斷了吧。
【參考】http://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/

熱點內容
華為如何給特定軟體設置密碼 發布:2025-05-16 06:44:09 瀏覽:467
內存和緩存的區別 發布:2025-05-16 06:42:42 瀏覽:187
配電車編程 發布:2025-05-16 06:41:22 瀏覽:369
安卓微信淺色模式怎麼恢復 發布:2025-05-16 06:27:53 瀏覽:240
美嘉演算法口訣 發布:2025-05-16 06:03:15 瀏覽:953
c程序編譯連接 發布:2025-05-16 06:02:36 瀏覽:965
腳本魔獸 發布:2025-05-16 06:01:52 瀏覽:331
文件夾python 發布:2025-05-16 06:01:43 瀏覽:628
電腦我的世界伺服器游戲幣 發布:2025-05-16 05:27:25 瀏覽:491
索尼手機為什麼不能用安卓10 發布:2025-05-16 05:18:46 瀏覽:784