简体   繁体   English

当数据到达Linux中的串行端口(RS232)时,是否可以向用户应用发送通知消息?

[英]Is it possible to send notification message to user app when data arrives at serial port (RS232) in Linux?

I know Linux can register udev events for USB accessories when it connects/disconnects to system, through udev apps can get notified on USB events so necessary action can be applied by applications. 我知道Linux在与系统连接/断开连接时可以为USB附件注册udev事件,通过udev应用程序可以获取USB事件的通知,因此应用程序可以应用必要的操作。

Is there any ways we can do same event notifications to user apps for serial peripherals (RS232) ? 有什么方法可以对串行外设(RS232)的用户应用程序执行相同的事件通知? Does linux support any such infrastructure which can do this? Linux是否支持任何可以做到这一点的基础架构? Basically I was read data from serial port as it arrives to serial port rather than creating a thread and waiting for data from serial port. 基本上,我是从串行端口读取数据的,因为它到达串行端口,而不是创建线程并等待串行端口的数据。

Without poll(ing)/select(ing) on the serial device with a program/daemon, you can not react if data arrives on the serial console. 如果没有使用程序/守护程序在串行设备上进行轮询/选择,则如果数据到达串行控制台,您将无法响应。

You can write a own kernel-driver, but this needs more effort. 您可以编写自己的内核驱动程序,但这需要更多的精力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM