- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在 TCL 脚本和 C 代码之间建立连接。
这是TCL脚本
set fs[open "./fifo_server" "w"]
puts $fs "level_3"
flush $fs
这是C代码
if ((fs = fopen ("./fifo_server", "r"))== NULL)
perror ("error occured while opening FIFO_SERVER");
else {
fs1 = fileno(fs);
read(fs1, in_data, sizeof(in_data));
}
printf ("in_data = %s\n", in_data);
输出如下:
in_data = level_3
(some garbage stuff 5 spaces which contains Question marks, Squares,
Characters etc.)
我不明白,垃圾行可能是什么原因???
感谢您准确和早期的帮助。
感谢和问候,
最佳答案
首先,正如 Jerry 指出的那样,您需要在变量 fs
和方括号之间留一个空格:
set fs [open "./fifo_server" "w"]
我不知道您为什么以如此低级的方式读取文件(即使用文件编号,而不是 FILE* 句柄)。但是,您需要自己终止字符串,因为 read()
不会自动这样做:
int chars_read; /* How many chars read from a file */
if ((fs = fopen ("./fifo_server", "r")) == NULL)
perror ("error occured while opening FIFO_SERVER");
else {
fs1 = fileno(fs);
chars_read = read(fs1, in_data, sizeof(in_data));
in_data[chars_read] = '\0'; /* terminate your string */
}
printf ("in_data = %s\n", in_data);
关于c - TCL 和 C 中的读/写 FIFO,垃圾输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21705396/
Chisel 是否支持设计中的多个时钟?如果我想实现一个异步 fifo,如何在 Chisel 中实现呢? 最佳答案 是的,Chisel 支持设计中的多个时钟。如果你想使用异步fifo,你可以导入模块C
当在单个进程上使用 FIFO 时,看起来两端都打开然后关闭,不可能重用 FIFO。任何重新打开封闭端的尝试都会失败,或者返回的文件描述符无用。 是否有可能解决此问题,还是我们必须保持 FIFO 的两端
考虑以下场景: 名为 test 的 FIFO被 build 。在一个终端窗口 (A) 中,我运行 cat test 。现在可以在窗口 B 中写入并在窗口 A 中获取输出。也可以终止进程 A 并重新启动
是否有某种方法可用于在真正的 FIFO 中使用 Amazon SQS 消息?我尝试从配置延迟消息传递,但这没有帮助。 最佳答案 亚马逊SQS刚刚获得FIFO Queues with Exactly-O
我有一个非常简单的基本程序,它有两个进程,第一个是parent,第二个是child。 子进程应该向 FIFO 写入一些内容。在所有写作工作完成后(在 child 被终止后)。然后父进程应该读取所有
在 C 中使用 epoll,有什么方法可以让从 FIFO 读取的程序检测到写入同一 FIFO 的程序已将其关闭? 我以为这会生成一个 EPOLLHUP 事件,但显然它不会。 例子:我有一个读者和一个作
在 bash 脚本中,我使用管道将命令的输出传递给另一个命令的输入: $ output_com | input_com output_com 比 input_com 慢。在我的脚本中,在input_c
我试图在 3.12 内核中自己实现 FIFO 调度程序,我无法找到 FIFO 文件的位置...就像 rt.c 位于/kernel/sched/rt.c 最佳答案 您在寻找哪个调度程序? Linux 有
这个问题在这里已经有了答案: Implementing FIFO using LIFO (2 个答案) 关闭 6 年前。 我了解使 Push 操作昂贵或 pop 操作昂贵的传统方法。 如何让push
我正在学习 Linux 中的管道编程,但无法理解管道/FIFO 管理。 我写了一个小程序来打开我创建的 FIFO(在执行程序之前,我在终端中执行了 mkfifo newfifo)。然后我反复读取并转储
我有一个写入标准输出的进程,我希望能够在运行 tail -f 时通过 grepping 查找各种字符串来监视输出。执行此操作的一种方法是写入一个普通文件,然后对文件进行尾部搜索一个字符串,然后对另一个
我想将一些数据输出到管道并让其他进程逐行处理数据。这是一个玩具示例: mkfifo pipe cat pipe& cat >pipe 现在我可以输入我想要的任何内容,按下回车后我立即看到同一行。但是如
我正在尝试开发一个程序来播放和录制一些 rtmp 流。该程序是在Qt中开发的。 我正在使用 rtmpdump 和 mplayer。因为两者都在单独的进程中运行,所以我使用 fifo 将流从 rtmpd
所以我开始构建我的本地 iOS 设备环境。我已经完全设置并运行了我的模拟器环境。我已经通过 iOS 开发人员为应用程序正确设置了我的分发和配置文件。在尝试运行该应用程序时,我遵循以下步骤:使用 USB
S3-FIFO 本文作为下一篇缓存文章的预备知识。 背景 基于LRU和FIFO的驱逐 FIFO和LRU都是经典的缓存驱逐算法,在过去几十年中也出现了很多追求更高效率的驱逐算法,如ARC, 2Q
我可以为单向通信创建一个 FIFO。但我该如何进行双向沟通呢?我可以创建一个可以充当发送方的 C 文件,并打开另一个充当接收方的终端。但如何建立双向通信呢?谢谢! 最佳答案 你不能。尝试一个套接字。考
考虑下表: Id Verb Qty Price `1 Buy 6 10.0 `2 Sell 5 11.0 `3 Buy 4 10.0 `4 Sell 3 11.0 `5 Sell 8 9.0 `6
我有两个进程(“发送者”和“接收者”)需要通过 transient 单向 FIFO 通信管道在单台机器上本地进行通信。这是我想要发生的事情(使用更接近 Unix 域套接字的语言): 发送者在已知地址“
好的,所以我正在使用 FIFO,并且我正在尝试构建一个小型库以在 future 的程序中使用。 它应该能够创建一个命名管道,读取它并在其中写入。 我能够完成所有这些功能,但它没有正确读取。问题如下:
数组有循环缓冲区版本吗?假设一次最大推送元素的数量已知,我是否必须派生自己的 FIFO 队列来提高性能? 这是我尝试过的: 循环实现: function CBuf(n) { var ctrPu
我是一名优秀的程序员,十分优秀!