当前位置:首页 » 操作系统 » 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-02-13 01:51:53 浏览:460
linux2个ftp服务器 发布:2025-02-13 01:44:31 浏览:14
戴尔r730网络配置后如何保存 发布:2025-02-13 01:38:27 浏览:344
php用什么编译 发布:2025-02-13 01:37:12 浏览:703
手机缓存的文件路径是在哪 发布:2025-02-13 01:34:58 浏览:563
oppo手机密码哪里设置 发布:2025-02-13 01:30:38 浏览:683
android网易 发布:2025-02-13 01:30:37 浏览:488
不联网怎么看自己的配置 发布:2025-02-13 01:00:38 浏览:858
饥荒联机版独立服务器有什么用 发布:2025-02-13 01:00:38 浏览:637
高级语言都有与之对应的编译程序或解释程序 发布:2025-02-13 00:54:46 浏览:571