fifo

Can't write to FIFO file mouted via NFS

不问归期 提交于 2019-12-05 22:49:50
问题 I'm trying to write to FIFO file locate on NFS mount and it blocks. What could be the problem? My /etc/export: /tmp/test/ 10.0.0.0/24(rw,no_root_squash,async) ls /tmp/test on NFS server and client is the same prw--w--w- 1 root root 0 2009-06-24 17:28 ui-input and I'm writing as root Thanks. 回答1: A FIFO is meant to be an inter-process communication mechanism. By trying to export the FIFO via NFS, you are asking the kernel to treat the local inter-process communication as more of a network

wk2124 在 rk3288 上的适配与调试

若如初见. 提交于 2019-12-05 14:37:56
2019-11-25 关键字:linux驱动开发、arm驱动适配、kernel开发、SPI转串口 WK2124 是一款 SPI 接口的 4 通道 UART 芯片。说白了就是一款通过 SPI 协议与 CPU 通信并对外表现出具备 4 个 232 串口功能的扩展芯片。它适用于 CPU 引脚资源不够或紧缺的情况,它的最高通信速率能达到 10Mbps。 本篇文章记述的是 WK2124 芯片在软件上的适配过程,属于软件开发范畴。但其实大家都知道,干到驱动这一层,对硬件电路一窍不通的话那是真干不下去。就拿这块芯片的软件层适配来说,我们需要的官方文档有: 1、芯片datasheet; 2、参考驱动程序; 3、参考原理图。 这些文件一般芯片厂商会提供,笔者这里也准备好了一份文件,有需要的可以直接下载: https://pan.baidu.com/s/1tpjTmRO5xgQXF-w7YsUqdA 提取码: juz1 首先来看看 WK2124 的引脚封装,如下图所示: 对于我们来说,在适配阶段需要关心的脚就 5 个,如上图标红框处所示。这些引脚的功用,datasheet 上都已有很详尽的说明: SPI 通信引脚在笔者的 3288 样机上所连接的 CPU 引脚是 SPI2,如下图所示: IRQ 脚在笔者的 3288 样机上所连接的 CPU 引脚是 GPIO7_A2,如下图所示: 然后,还有一个最重要的

Write/Read to/from FIFO files - linux

为君一笑 提交于 2019-12-05 11:01:53
I've been trying to wrap my head around FIFO, and came up with a simple program of server and client. I'm not trying to do anything fancy, just to have one process that will play a role of 'server', this process will 'listen' to any messages delivered by another process; the client. Here's what I wrote: server.c #include<stdio.h> #include <fcntl.h> #include <stdlib.h> #define INGOING "clientToServer.fifo" #define BUFFER 200 int main(int argc, char *argv[]) { char in[BUFFER]; mkfifo(INGOING, 0666); printf("Welcome to server.\n"); printf("channel for sending messages to server is %s\n", INGOING)

Python and FIFOs

柔情痞子 提交于 2019-12-05 08:00:50
I was trying to understand FIFOs using Python under linux and I found a strange behavior i don't understand. The following is fifoserver.py import sys import time def readline(f): s = f.readline() while s == "": time.sleep(0.0001) s = f.readline() return s while True: f = open(sys.argv[1], "r") x = float(readline(f)) g = open(sys.argv[2], "w") g.write(str(x**2) + "\n") g.close() f.close() sys.stdout.write("Processed " + repr(x) + "\n") and this is fifoclient.py import sys import time def readline(f): s = f.readline() while s == "": time.sleep(0.0001) s = f.readline() return s def req(x): f =

Getting readline to block on a FIFO

て烟熏妆下的殇ゞ 提交于 2019-12-05 05:54:15
I create a fifo: mkfifo tofetch I run this python code: fetchlistfile = file("tofetch", "r") while 1: nextfetch = fetchlistfile.readline() print nextfetch It stalls on readline, as I would hope. I run: echo "test" > tofetch And my program doesn't stall anymore. It reads the line, and then continues looping forever. Why won't it stall again when there's no new data? I also tried looking on "not fetchlistfile.closed", I wouldn't mind reopening it after every write, but Python thinks the fifo is still open. According to the documentation for readline , it returns the empty string if and only if

Implementing a FIFO queue in C

∥☆過路亽.° 提交于 2019-12-05 01:52:10
问题 For an embedded application, I am trying to implement a first-in, first-out (FIFO) queue of structs using ANSI C. The most straightforward way to do this seems to be by implementing a linked-list, so that each structure contains a pointer to the next in the queue. Hence I define the struct itself as: typedef enum { LED_on, LED_off, etc } Action; typedef struct Queued_Action QueuedAction; struct Queued_Action { Action action; int value; QueuedAction *nextAction; }; So far so good. If I define

C语言控制mplayer

梦想的初衷 提交于 2019-12-05 01:37:58
最近使用树莓派的音频播放音频文件(需要外接声卡),自己在网上找一些alsa编程的代码用起来比较复杂,可以是自己设置的原因把,播放时有时会出现杂音。不过这两天看到了一个开源软件mplayer,它的slave模式,可以让你在通过FIFO文件控制它的播放停止和其他功能。这样你就可以通过程序控制mplayer了,甚至可以在它的基础上开发新的软件。这里用的是C语言。今天先立个搞,明天再更。 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include <fcntl.h> #define FIFO "/tmp/myfifo" int main() { char * path = "./test.mp3"; if(mkfifo("/tmp/myfifo",0777)) printf("fifo create error\n"); if(!fork()) { system("mplayer -slave -quiet -input file=/tmp/myfifo ./test.mp3"); exit(0); } else { sleep(10); int fd = open(FIFO, O

Unix FIFO in go?

此生再无相见时 提交于 2019-12-05 01:20:56
Is there any way to create a unix FIFO with Go language? There is no Mkfifo , nor Mknod in os package, though I expected named FIFOs are largely used in posix OS's. In fact, there is a function for creating an unnamed FIFO (pipe), but no function for creating named pipes. Am I the only one who needs them? In order to get it to work on Linux, I simply did a syscall.Mknod(fullPath, syscall.S_IFIFO|0666, 0) It seemed to do the trick. Here is a reference for the underlying mknod() call There is a Mkfifo , but it's in the syscall -package :) Searching through the source gives me the feeling it's

nc 命令

天大地大妈咪最大 提交于 2019-12-04 23:17:08
目录 nc 命令 一、简介 二、案例 1、端口扫描 2、聊天 3、文件传输 4、目录传输 5、加密网络发送的数据 6、流视频 7、克隆一个设备 8、打开一个shell 9、反向shell 10、指定端口 11、指定源地址 三、man手册 nc 命令 一、简介 netcat所做的就是在两台电脑之间建立链接并返回两个数据流,在这之后所能做的事就看你的想像力了。你能建立一个服务器,传输文件,与朋友聊天,传输流媒体或者用它作为其它协议的独立客户端。 二、案例 1、端口扫描 端口扫描经常被系统管理员和黑客用来发现在一些机器上开放的端口,帮助他们识别系统中的漏洞。 $nc -z -v -n 172.31.100.7 21-25 可以运行在TCP或者UDP模式,默认是TCP,-u参数调整为udp. z 参数告诉netcat使用0 IO,连接成功后立即关闭连接, 不进行数据交换(谢谢@jxing 指点) v 参数指使用冗余选项(译者注:即详细输出) n 参数告诉netcat 不要使用DNS反向查询IP地址的域名 这个命令会打印21到25 所有开放的端口。Banner是一个文本,Banner是一个你连接的服务发送给你的文本信息。当你试图鉴别漏洞或者服务的类型和版本的时候,Banner信息是非常有用的。但是,并不是所有的服务都会发送banner。 一旦你发现开放的端口,你可以容易的使用netcat

Write and read from a fifo from two different script

寵の児 提交于 2019-12-04 19:04:03
问题 I have two bash script. One script write in a fifo. The second one read from the fifo, but AFTER the first one end to write. But something does not work. I do not understand where the problem is. Here the code. The first script is (the writer): #!/bin/bash fifo_name="myfifo"; # Se non esiste, crea la fifo; [ -p $fifo_name ] || mkfifo $fifo_name; exec 3<> $fifo_name; echo "foo" > $fifo_name; echo "bar" > $fifo_name; The second script is (the reader): #!/bin/bash fifo_name="myfifo"; while true