linux_module_learn/my_first_module/test/test_myfifo_r.c

28 lines
351 B
C
Raw Permalink Normal View History

2023-07-22 13:42:32 +08:00
#include<stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include<string.h>
int main()
{
int fd = 0;
int i = 20;
char r_buff[64] = {0};
fd = open("/dev/myfifo",O_RDWR);
while(i)
{
memset(r_buff,0,64);
read(fd,r_buff,64);
printf("%s",r_buff);
i--;
}
return 0;
}