在调试嵌入式系统时如何发送"中断"?

her*_*008 2 linux embedded

所有,

在调试嵌入式系统时,我们通常会通过uart控制台与目标设备进行通信.现在我想在linux内核中测试"Magic sysrq"功能,这需要向控制台驱动程序发送"break".我发现"休息"意味着什么,似乎我需要保持TX线低电平一段时间.
我的问题是如何从APUE(unix中的高级程序)发送这个中断"字符",我必须调用函数"tcsendbreak",这意味着我必须编写一个程序.我徘徊,如果我可以使用一些特定的键发送,如^ C等.
不要使用"echo"x">/proc/sysrq-trigger"",我知道,只是在其他方式讨论:)

这是我的终端设置,我用ckermit与目标进行交谈.

stty -a < /dev/ttyUSB0 
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc 
-ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl  
echoke
Run Code Online (Sandbox Code Playgroud)

Dig*_*oss 6

文档中,它看起来Control-\ B会在C-Kermit中发送一个中断.

其他方法...

发送休息的一种方法是:

  1. 切换到较低的速度
  2. 发送Nul(0)或@(40 16) - 具有许多连续0位的字符将产生称为BREAK的帧错误.
  3. 切换回原始速度

如您所述,另一种方法是使用<termios.h>线控功能.

#include <termios.h>

int tcsendbreak(int fildes, int duration); // "duration" is ignored
Run Code Online (Sandbox Code Playgroud)