當前位置:首頁 » 操作系統 » 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-07-05 16:10:30 瀏覽:525
微博資料庫設計 發布:2025-07-05 15:30:55 瀏覽:24
linux485 發布:2025-07-05 14:38:28 瀏覽:304
php用的軟體 發布:2025-07-05 14:06:22 瀏覽:754
沒有許可權訪問計算機 發布:2025-07-05 13:29:11 瀏覽:430
javaweb開發教程視頻教程 發布:2025-07-05 13:24:41 瀏覽:695
康師傅控流腳本破解 發布:2025-07-05 13:17:27 瀏覽:239
java的開發流程 發布:2025-07-05 12:45:11 瀏覽:684
怎麼看內存卡配置 發布:2025-07-05 12:29:19 瀏覽:282
訪問學者英文個人簡歷 發布:2025-07-05 12:29:17 瀏覽:833