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

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:563
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:852
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:552
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:731
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:653
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:971
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:225
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:84
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:774
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:680