當前位置:首頁 » 操作系統 » 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-09-18 14:53:43 瀏覽:674
sql頁面 發布:2025-09-18 14:51:08 瀏覽:944
無法訪問移動硬碟參數錯誤 發布:2025-09-18 14:50:15 瀏覽:540
exist資料庫 發布:2025-09-18 14:42:36 瀏覽:653
白百何訪問 發布:2025-09-18 14:20:14 瀏覽:454
人人貸源碼 發布:2025-09-18 14:11:02 瀏覽:993
pythonlist刪除list 發布:2025-09-18 14:03:29 瀏覽:245
我的世界伺服器手機版新手 發布:2025-09-18 13:51:33 瀏覽:834
php從入門到精通下載 發布:2025-09-18 13:36:44 瀏覽:162
抖音使用腳本 發布:2025-09-18 13:29:36 瀏覽:810