📄 pipedrv.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/pipeDrv.html - generated by refgen from pipeDrv.c --> <title> pipeDrv </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>pipeDrv</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>pipeDrv</strong> - pipe I/O driver </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./pipeDrv.html#pipeDrv">pipeDrv</a>( )</b> - initialize the pipe driver<br><b><a href="./pipeDrv.html#pipeDevCreate">pipeDevCreate</a>( )</b> - create a pipe device<br><b><a href="./pipeDrv.html#pipeDevDelete">pipeDevDelete</a>( )</b> - delete a pipe device<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>The pipe driver provides a mechanism that lets tasks communicate with each other through the standard I/O interface. Pipes can be read and written withnormal <b><a href="./ioLib.html#read">read</a>( )</b> and <b><a href="./ioLib.html#write">write</a>( )</b> calls. The pipe driver is initialized with<b><a href="./pipeDrv.html#pipeDrv">pipeDrv</a>( )</b>. Pipe devices are created with <b><a href="./pipeDrv.html#pipeDevCreate">pipeDevCreate</a>( )</b>.<p>The pipe driver uses the VxWorks message queue facility to do the actualbuffering and delivering of messages. The pipe driver simply providesaccess to the message queue facility through the I/O system. The maindifferences between using pipes and using message queues directly are:<ul><li></li>pipes are named (with I/O device names).<li></li>pipes use the standard I/O functions -- <b><a href="./ioLib.html#open">open</a>( )</b>, <b><a href="./ioLib.html#close">close</a>( )</b>, <b><a href="./ioLib.html#read">read</a>( )</b>,<b><a href="./ioLib.html#write">write</a>( )</b> -- while message queues use the functions <b><a href="./msgQLib.html#msgQSend">msgQSend</a>( )</b> and <b><a href="./msgQLib.html#msgQReceive">msgQReceive</a>( )</b>.<li></li>pipes respond to standard <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> functions.<li></li>pipes can be used in a <b><a href="./selectLib.html#select">select</a>( )</b> call.<li></li>message queues have more flexible options for timeouts and messagepriorities.<li></li>pipes are less efficient than message queues because of the additionaloverhead of the I/O system.</ul><p></blockquote><h4>INSTALLING THE DRIVER</h4><blockquote><p>Before using the driver, it must be initialized and installed by calling<b><a href="./pipeDrv.html#pipeDrv">pipeDrv</a>( )</b>. This routine must be called before any pipes are created.It is called automatically by the root task, <b><a href="./usrConfig.html#usrRoot">usrRoot</a>( )</b>, in <b>usrConfig.c</b> whenthe configuration macro <b>INCLUDE_PIPES</b> is defined.<p></blockquote><h4>CREATING PIPES</h4><blockquote><p>Before a pipe can be used, it must be created with <b><a href="./pipeDrv.html#pipeDevCreate">pipeDevCreate</a>( )</b>.For example, to create a device pipe "/pipe/demo" with up to 10 messagesof size 100 bytes, the proper call is:<pre> pipeDevCreate ("/pipe/demo", 10, 100);</pre></blockquote><h4>USING PIPES</h4><blockquote><p>Once a pipe has been created it can be opened, closed, read, and writtenjust like any other I/O device. Often the data that is read and writtento a pipe is a structure of some type. Thus, the following example writesto a pipe and reads back the same data:<p><pre> { int fd; struct msg outMsg; struct msg inMsg; int len; fd = open ("/pipe/demo", O_RDWR); write (fd, &outMsg, sizeof (struct msg)); len = read (fd, &inMsg, sizeof (struct msg)); close (fd); }</pre>The data written to a pipe is kept as a single message and will beread all at once in a single read. If <b><a href="./ioLib.html#read">read</a>( )</b> is called with a bufferthat is smaller than the message being read, the remainder of the messagewill be discarded. Thus, pipe I/O is "message oriented" rather than"stream oriented." In this respect, VxWorks pipes differ significantly from UNIX pipes which are stream oriented and do not preserve message boundaries.<p></blockquote><h4>WRITING TO PIPES FROM INTERRUPT SERVICE ROUTINES</h4><blockquote><p>Interrupt service routines (ISR) can write to pipes, providing one of severalways in which ISRs can communicate with tasks. For example, an interruptservice routine may handle the time-critical interrupt response and thensend a message on a pipe to a task that will continue with the lesscritical aspects. However, the use of pipes to communicate from an ISR toa task is now discouraged in favor of the direct message queue facility,which offers lower overhead (see the manual entry for <b><a href="./msgQLib.html#top">msgQLib</a></b> for moreinformation).<p></blockquote><h4>SELECT CALLS</h4><blockquote><p>An important feature of pipes is their ability to be used in a <b><a href="./selectLib.html#select">select</a>( )</b>call. The <b><a href="./selectLib.html#select">select</a>( )</b> routine allows a task to wait for input from any of aselected set of I/O devices. A task can use <b><a href="./selectLib.html#select">select</a>( )</b> to wait for inputfrom any combination of pipes, sockets, or serial devices. See the manualentry for <b><a href="./selectLib.html#select">select</a>( )</b>.<p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>Pipe devices respond to the following <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> functions.These functions are defined in the header file <b>ioLib.h</b>.<p><dl><dt><b>FIOGETNAME</b><dd>Gets the file name of fd and copies it to the buffer referenced by <i>nameBuf</i>:<pre> status = ioctl (fd, FIOGETNAME, &nameBuf);</pre><dt><b>FIONREAD</b><dd>Copies to <i>nBytesUnread</i> the number of bytes remaining in the first messagein the pipe:<pre> status = ioctl (fd, FIONREAD, &nBytesUnread);</pre><dt><b>FIONMSGS</b><dd>Copies to <i>nMessages</i> the number of discrete messages remaining in the pipe:<pre> status = ioctl (fd, FIONMSGS, &nMessages);</pre><dt><b>FIOFLUSH</b><dd>Discards all messages in the pipe and releases the memory block that containedthem:<pre> status = ioctl (fd, FIOFLUSH, 0);</pre> </dl></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>ioLib.h</b>, <b>pipeDrv.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./selectLib.html#select">select</a>( )</b>, <b><a href="./msgQLib.html#top">msgQLib</a></b>,<i>VxWorks Programmer's Guide: I/O System </i><hr><a name="pipeDrv"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>pipeDrv( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>pipeDrv( )</strong> - initialize the pipe driver</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS pipeDrv (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes and installs the driver. It must be calledbefore any pipes are created. It is called automatically by the roottask, <b><a href="./usrConfig.html#usrRoot">usrRoot</a>( )</b>, in <b>usrConfig.c</b> when the configuration macro <b>INCLUDE_PIPES</b>is defined.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the driver installation fails.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./pipeDrv.html#top">pipeDrv</a></b><hr><a name="pipeDevCreate"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>pipeDevCreate( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>pipeDevCreate( )</strong> - create a pipe device</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS pipeDevCreate ( char * name, /* name of pipe to be created */ int nMessages, /* max. number of messages in pipe */ int nBytes /* size of each message */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a pipe device. It cannot be called from an interruptservice routine.It allocates memory for the necessary structures and initializes the device.The pipe device will have a maximum of <i>nMessages</i> messages of up to<i>nBytes</i> each in the pipe at once. When the pipe is full, a task attemptingto write to the pipe will be suspended until a message has been read.Messages are lost if written to a full pipe at interrupt level.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the call fails.<p></blockquote><h4>ERRNO</h4><blockquote><p><b>S_ioLib_NO_DRIVER</b> - driver not initialized<b>S_intLib_NOT_ISR_CALLABLE</b> - cannot be called from an ISR</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./pipeDrv.html#top">pipeDrv</a></b><hr><a name="pipeDevDelete"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>pipeDevDelete( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>pipeDevDelete( )</strong> - delete a pipe device</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS pipeDevDelete ( char * name, /* name of pipe to be deleted */ BOOL force /* if TRUE, force pipe deletion */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine deletes a pipe device of a given name. The name must matchthat passed to <b><a href="./pipeDrv.html#pipeDevCreate">pipeDevCreate</a>( )</b> else ERROR will be returned. This routinefrees memory for the necessary structures and deletes the device. It cannotbe called from an interrupt service routine.<p>A pipe device cannot be deleted until its number of open requests has beenreduced to zero by an equal number of close requests and there are no taskspending in its select list. If the optional force flag is asserted, theabove restrictions are ignored, resulting in forced deletion of any selectlist and freeing of pipe resources.<p></blockquote><h4>CAVEAT</h4><blockquote><p>Forced pipe deletion can have catastrophic results if usedindescriminately. Use only as a last resort.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the call fails.<p></blockquote><h4>ERRNO</h4><blockquote><p><b>S_ioLib_NO_DRIVER</b> - driver not initialized<b>S_intLib_NOT_ISR_CALLABLE</b> - cannot be called from an ISREMFILE - pipe still has other openingsEBUSY - pipe is selected by at least one pending task</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./pipeDrv.html#top">pipeDrv</a></b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -