首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重定向VxWorks串行输入

重定向VxWorks串行输入
EN

Stack Overflow用户
提问于 2012-04-25 04:28:48
回答 3查看 3.2K关注 0票数 0

我正在尝试将所有串行数据重定向到VxWorks中的一个进程。使用以下代码

代码语言:javascript
复制
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外壳?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-04-28 04:05:35

在VxWorks配置和编译过程中禁用外壳程序将永久消除该问题。也可以在shell中输入exit以暂时禁用它。

票数 0
EN

Stack Overflow用户

发布于 2018-10-11 05:41:13

如果您想将所有任务的输出重定向到当前登录shell,我认为答案是:

代码语言:javascript
复制
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;
    }
}
票数 1
EN

Stack Overflow用户

发布于 2012-04-25 23:54:34

一种解决方法是使用ioGlobalStdSet将IO重定向到管道。然后,在RTP中,以读取模式打开管道。

在我的脑海中--在内核中:

代码语言:javascript
复制
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);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10305526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档