看起来你被TTY的线路规则所困扰(请记住,rfcomm不会创建一个fifo,而是一个tty).
您可以尝试将TTY更改为原始模式,即没有任何魔法.最简单的方法是使用stty –file< tty>生的.我不知道rfcomm是否会在其命令行中接受多个命令,但您可以轻松地使用脚本:
command_raw
#!/bin/bash
stty --file "$1" raw
"$COMMAND" "$1"
然后运行:
sdptool add --channel 1 SP
rfcomm watch hci0 1 ./command_raw {}
如果您有要运行的命令的源,您也可以在C中轻松更改它:
#include
#include
//WARNING: error checking left as an exercise to the reader!
void make_raw(int fd)
{
struct termios ios;
//Not a TTY: nothing to do
if (!isatty(fd))
return;
tcgetattr(fd,&ios);
cfmakeraw(&ios);
tcsetattr(fd,TCSANOW,&ios);
}