我正在尝试将所有串行数据重定向到VxWorks中的一个进程。使用以下代码
fd = open("/tyCo/0", O_RDWR,0);
ioctl(fd, FIOSETOPTIONS, OPT_TERMINAL & ~OPT_7_BIT);
read(fd, line, 100);给出正确的输入,除了输入的第一个字符没有填充,而是打印到终端。所以如果我输入"Hello","H“就会打印出来,而line=会输出”ello“。如果我没有输入任何内容并按回车键,我会从VxWorks外壳得到一个提示。
我认为VxWorks外壳正在截取数据的第一个字母。我的猜测是,我只能将STDIO重定向到新进程,但我在上面找到的所有documentation都表明要使用ioGlobalStdSet(),这在VxWorks 6.4RTP中是不可用的。如何从我的进程中重定向STDIO或终止VxWorks外壳?
发布于 2012-04-28 04:05:35
在VxWorks配置和编译过程中禁用外壳程序将永久消除该问题。也可以在shell中输入exit以暂时禁用它。
发布于 2018-10-11 05:41:13
如果您想将所有任务的输出重定向到当前登录shell,我认为答案是:
static int shellResourceReleaseHookAdd_once = 0;
void revert_out()
{
ioGlobalStdSet( 1, consoleFd ); /* redirect all output to the consoleFd */
ioGlobalStdSet( 2, consoleFd ); /* redirect all error to the consoleFd */
}
void redirect_out()
{
ioGlobalStdSet( 1, ioTaskStdGet(0,1) ); /* redirect all output to the current shell */
ioGlobalStdSet( 2, ioTaskStdGet(0,1) ); /* redirect all error to the current shell */
if (shellResourceReleaseHookAdd_once == 0) {
shellResourceReleaseHookAdd(revert_out); /* call revert_out() when current shell closes. */
shellResourceReleaseHookAdd_once = 1;
}
}发布于 2012-04-25 23:54:34
一种解决方法是使用ioGlobalStdSet将IO重定向到管道。然后,在RTP中,以读取模式打开管道。
在我的脑海中--在内核中:
dev = pipeDevCreate("/pipe/input", 10, 100);
kernFd = open("/pipe/input", O_RD, 0)
ioGlobalStdSet(1, kernFd)在RTP中:
rtpFd = open("/pipe/input",O_RD,0);read(rtpFd,行,100);
https://stackoverflow.com/questions/10305526
复制相似问题