當前位置:首頁 » 操作系統 » 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/

熱點內容
優酷上傳ts 發布:2024-09-20 19:55:58 瀏覽:273
minecraft怎麼開伺服器地址 發布:2024-09-20 19:52:14 瀏覽:651
android彈出布局 發布:2024-09-20 19:14:29 瀏覽:981
預演算法包括 發布:2024-09-20 18:52:07 瀏覽:764
什麼數字後面跟著密碼 發布:2024-09-20 18:52:07 瀏覽:878
訂座源碼 發布:2024-09-20 18:52:06 瀏覽:383
手機mud源碼 發布:2024-09-20 18:51:28 瀏覽:940
3k我的使命腳本 發布:2024-09-20 18:11:43 瀏覽:691
建設銀行密碼怎麼設置 發布:2024-09-20 18:11:04 瀏覽:96
聚合腳本平台 發布:2024-09-20 17:51:55 瀏覽:182