您现在的位置: 主页 > 嵌入式操作系统 > VxWorks > 管道:ioLib.h vxWorks编程指南_VxWorks编程常用函数说明(10)
本文所属标签:
为本文创立个标签吧:

管道:ioLib.h vxWorks编程指南_VxWorks编程常用函数说明(10)

来源: 网络用户发布,如有版权联系网管删除 2016-06-03 

管道:ioLib.h vxWorks编程指南_VxWorks编程常用函数说明(10) 2)管道:ioLib.h,系统默认包含了pipe驱动组件
pipeDevCreate( ) - 创建管道
pipeDevDelete( ) - 删除管道
由于管道属于IO,所以可以使用Select监听,消息队列不是IO,不能使用Select
Init() {
/* 创建管道 */
if (pipeDevCreate("/pipe/mypipe", 8, 1) != OK) {
printf("/pipe/mypipe create fialed!n");
}
/* 创建互斥信号量 */
if ((semMID = semMCreate(SEM_Q_FIFO)) == NULL)
{
printf("Mutex semaphore create failed!n");
}
}
taskSend() {
int pd; /* pipe的描述符 */
if ((pd = open("/pipe/mypipe", O_WRONLY, 0644)) == ERROR) {
printf("Open pipe failed!");
}
if (semTake(semMID, NO_WAIT) == ERROR) {
printf("Pipe in use!");
}
write(pd, "a", 1);
semGive(semMID);
close(pd);
}
taskReceive() {
int pd; /* pipe的描述符 */
uchar_t ch;
if ((pd = open("/pipe/mypipe", O_RDONLY, 0644)) == ERROR) {
printf("Open pipe failed!");
}
if (read(pd, &ch, 1)>0) { /* 这里任务会阻塞 */
printf("Received from pipe: %c", ch);
}
}


              查看评论 回复



嵌入式交流网主页 > 嵌入式操作系统 > VxWorks > 管道:ioLib.h vxWorks编程指南_VxWorks编程常用函数说明(10)
 

"管道:ioLib.h vxWorks编程指南_VxWorks编程常用函数说明(10)"的相关文章

网站地图

围观()