linux rs232 无法识别,linux - 为什么在Linux上使用RS-232时CTRL + C不起作用? - 堆栈内存溢出...

嵌入式设备上的串行端口设置可能忽略中断字符,或者在收到中断时不会导致中断。 您可以通过从设备的shell(或启动脚本)运行stty程序,或使用各种ioctl()参数编写程序来更改此设置。

stty sane

可能是最好的选择。 这设置了一堆“通常”设置。 相反,如果你这样做

stty raw

在桌面Linux的shell窗口中,您可能会在嵌入式设备上看到ctrl-C打印但没有任何行为。

不带参数运行stty可能会打印出当前设置,这可能很有趣 - 特别是比较串行和telnet会话的结果。

更新:在busybox和BRKINT上进行网络搜索时发现可能相关的内容:

Date: Thu, 31 Jan 2002 13:34:34 -0800

From: Scott Anderson

Cc: linuxppc-dev at lists.linuxppc.org

Subject: Re: why is tty->pgrp set to -1 for console?

> What is the correct procedure to follow to get around this problem

> and get ctrl-c working on console?

It looks like everyone is taking a swing at this one, so I think I'll

join in. First off, the easiest way I've found to track down why

ctrl-c doesn't work is to just run "ps -j". For ctrl-c to work, you

need a controlling terminal (the TTY column) and a process group. If

you have a '?' in the TTY column, ctrl-c won't work. In the past I

have seen this happen because of this code in drivers/char/tty_io.c:

if (device == SYSCONS_DEV) {

struct console *c = console_drivers;

while(c && !c->device)

c = c->next;

if (!c)

return -ENODEV;

device = c->device(c);

filp->f_flags |= O_NONBLOCK; /* Don't let /dev/console block */

noctty = 1;

}

Note that O_NOCTTY (no controlling terminal) is forced on whenever

/dev/console is opened (noctty = 1). Possible workarounds:

1) Run getty on something other than /dev/console. For example,

if you console is on the first serial port, run getty on /dev/ttyS0.

I believe this is the "correct" answer.

2) You could also change getty to do a TIOCSCTTY ioctl explicitly after

it has opened the terminal.

3) You could remove the forcing of noctty on from tty_io.c

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值