⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 嵌入式LIUNX的流媒体控制器程序哦 号可以
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include "fifo.h"#define	TOTAL_COUNT		100void proc_put(HFIFO handle){	int cnt, remain;	char buf[2048];	remain = 8;	for(cnt = 0; cnt < TOTAL_COUNT; cnt++)	{		sprintf(buf, "Count: %d", cnt);		fifo_put(handle, buf, strlen(buf), FIFO_FLG_BLOCK);		printf("[FIFO] [SEND] %s\n", buf);		remain--;		if(remain == 0)		{			fifo_tag_trigger(handle, 0);			remain = 8;		}		{			struct timespec tm;			tm.tv_sec	= 0;			tm.tv_nsec	= 1000000;			nanosleep(&tm, NULL);		}	}	fifo_tag_trigger(handle, 0);}void proc_get(){	int cnt;	HFIFO	handle;	size_t	slotsz;	int	len;	char buf[2048];	handle = fifo_find_handle("fifotest", &slotsz);	printf("We get it! Address: %p\n", handle);	for(cnt = 0; cnt < TOTAL_COUNT; )	{		if(fifo_tag_check(handle, 0))		{			while((len=fifo_get(handle, buf, 2048, FIFO_FLG_BLOCK)) >= 0)			{				buf[len] = 0;				printf("[FIFO] [RECV] %s\n", buf);				cnt++;			}		}		else		{			struct timespec tm;			tm.tv_sec	= 0;			tm.tv_nsec	= 1000000;			nanosleep(&tm, NULL);		}	}}main(){	HFIFO handle;	/* Create FIFO */	handle = fifo_create("fifotest", 128, 1460);	if(!fork())	{		proc_get();		sleep(1);	}	else	{		proc_put(handle);		sleep(10);		fifo_destroy(handle);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -