使用TTY驱动中断驱动?

发布于 2024-09-11 23:46:14 字数 311 浏览 3 评论 0原文

我是开发 Linux 驱动程序的新手......我正在开发一个 SMS 驱动程序(通过串行端口到调制解调器的 AT 命令),使用 TTY 访问串行端口。驱动程序用 C 语言编写。

在设计中,从调制解调器到驱动程序的消息可由两个事件触发:

1) 响应驱动程序发出的 AT 命令的状态(即预期消息)

2) 新 SMS 指示(即意外消息)

I我计划使用两个线程 - 一个用于写入 TTY,另一个用于从 TTY 读取。是否可以配置 TTY 以便我的读取线程在传入字符上唤醒(即读取线程是事件触发的而不是基于轮询)?

此致, 维泰克

I am a newbie to developing drivers for Linux ... . I am developing a SMS-driver (AT commands over serial port to modem) using TTY for accessing the serial port. The driver is written in C.

In the design messages from modem to driver can be triggered by two events:

1) Status as respond to AT commands issued by driver (i.e. expected messages)

2) Indication of new SMS (i.e. unexpected messages)

I am planning on two threads - one for writing to TTY and one for reading from TTY. Is it possible to configure TTY so that my read-thread wakes-up on incoming chars (i.e. read-thread is event-triggered and not based on polling)?

Best Regards,
Witek

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风柔一江水 2024-09-18 23:46:14

我不认为你真的想要两个线程。典型的程序流程(写入 AT 命令、检查响应等...)将更容易在单线程程序中编写和调试。

可以通过 select() 调用来等待字符。 tty层主要是通过配置
tcsetattr、tcgetattr 和类似的系统调用。通过此调用,您可以配置是否要在新行或每个字符上中断。请参阅 man termios 的联机帮助页。两个大的选择是您是否希望 EOF、EOL Ctrl-C 等特殊字符被处理为数据(原始模式)或由 tty 层解释(规范模式)。

请参阅串行编程指南中有关 select 的部分,或查看 select 联机帮助页以获取更多信息

I don't think you really want two threads. Typical program flow (write AT command, check response etc ...) will be easier to write and debug in a monothreaded program.

Waiting for chars can be made with select() call. The tty layer is mostly configured through
the tcsetattr, tcgetattr and friends system call. With this call you can configure wether you want to be interrupted on new line or on each char for example. See man termios for the manpage. The two big options are wether you want the special characters like EOF, EOL Ctrl-C etc... to be treated has data (raw mode) or be interpreted by the tty layer (canonical mode).

See the part on select in the serial programming guide, or the select manpage for more info

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文