📄 rnglib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/rngLib.html - generated by refgen from rngLib.c --> <title> rngLib </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>rngLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngLib</strong> - ring buffer subroutine library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./rngLib.html#rngCreate">rngCreate</a>( )</b> - create an empty ring buffer<br><b><a href="./rngLib.html#rngDelete">rngDelete</a>( )</b> - delete a ring buffer<br><b><a href="./rngLib.html#rngFlush">rngFlush</a>( )</b> - make a ring buffer empty<br><b><a href="./rngLib.html#rngBufGet">rngBufGet</a>( )</b> - get characters from a ring buffer<br><b><a href="./rngLib.html#rngBufPut">rngBufPut</a>( )</b> - put bytes into a ring buffer<br><b><a href="./rngLib.html#rngIsEmpty">rngIsEmpty</a>( )</b> - test if a ring buffer is empty<br><b><a href="./rngLib.html#rngIsFull">rngIsFull</a>( )</b> - test if a ring buffer is full (no more room)<br><b><a href="./rngLib.html#rngFreeBytes">rngFreeBytes</a>( )</b> - determine the number of free bytes in a ring buffer<br><b><a href="./rngLib.html#rngNBytes">rngNBytes</a>( )</b> - determine the number of bytes in a ring buffer<br><b><a href="./rngLib.html#rngPutAhead">rngPutAhead</a>( )</b> - put a byte ahead in a ring buffer without moving ring pointers<br><b><a href="./rngLib.html#rngMoveAhead">rngMoveAhead</a>( )</b> - advance a ring pointer by <i>n</i> bytes<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides routines for creating and using ring buffers, whichare first-in-first-out circular buffers. The routines simply manipulatethe ring buffer data structure; no kernel functions are invoked. Inparticular, ring buffers by themselves provide no task synchronization ormutual exclusion.<p>However, the ring buffer pointers are manipulated in such a way that areader task (invoking <b><a href="./rngLib.html#rngBufGet">rngBufGet</a>( )</b>) and a writer task (invoking<b><a href="./rngLib.html#rngBufPut">rngBufPut</a>( )</b>) can access a ring simultaneously without requiring mutualexclusion. This is because readers only affect a <i>read</i> pointer andwriters only affect a <i>write</i> pointer in a ring buffer data structure.However, access by multiple readers or writers <i>must</i> be interlockedthrough a mutual exclusion mechanism (i.e., a mutual-exclusion semaphoreguarding a ring buffer).<p>This library also supplies two macros, <b>RNG_ELEM_PUT</b> and <b>RNG_ELEM_GET</b>,for putting and getting single bytes from a ring buffer. They are definedin <b>rngLib.h</b>.<pre> int RNG_ELEM_GET (ringId, pch, fromP) int RNG_ELEM_PUT (ringId, ch, toP)</pre>Both macros require a temporary variable <i>fromP</i> or <i>toP</i>, whichshould be declared as <b>register int</b> for maximum efficiency. <b>RNG_ELEM_GET</b>returns 1 if there was a character available in the buffer; it returns 0otherwise. <b>RNG_ELEM_PUT</b> returns 1 if there was room in the buffer; it returns0 otherwise. These are somewhat faster than <b><a href="./rngLib.html#rngBufPut">rngBufPut</a>( )</b> and <b><a href="./rngLib.html#rngBufGet">rngBufGet</a>( )</b>,which can put and get multi-byte buffers.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>rngLib.h</b><hr><a name="rngCreate"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngCreate( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngCreate( )</strong> - create an empty ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>RING_ID rngCreate ( int nbytes /* number of bytes in ring buffer */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a ring buffer of size <i>nbytes</i>, and initializesit. Memory for the buffer is allocated from the system memory partition.<p></blockquote><h4>RETURNS</h4><blockquote><p>The ID of the ring buffer, or NULL if memory cannot be allocated.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngDelete"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngDelete( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngDelete( )</strong> - delete a ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void rngDelete ( RING_ID ringId /* ring buffer to delete */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine deletes a specified ring buffer.Any data currently in the buffer will be lost.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngFlush"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngFlush( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngFlush( )</strong> - make a ring buffer empty</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void rngFlush ( RING_ID ringId /* ring buffer to initialize */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initializes a specified ring buffer to be empty.Any data currently in the buffer will be lost.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngBufGet"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngBufGet( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngBufGet( )</strong> - get characters from a ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int rngBufGet ( RING_ID rngId, /* ring buffer to get data from */ char * buffer, /* pointer to buffer to receive data */ int maxbytes /* maximum number of bytes to get */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine copies bytes from the ring buffer <i>rngId</i> into <i>buffer</i>.It copies as many bytes as are available in the ring, up to <i>maxbytes</i>.The bytes copied will be removed from the ring.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>The number of bytes actually received from the ring buffer;it may be zero if the ring buffer is empty at the time of the call.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngBufPut"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngBufPut( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngBufPut( )</strong> - put bytes into a ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int rngBufPut ( RING_ID rngId, /* ring buffer to put data into */ char * buffer, /* buffer to get data from */ int nbytes /* number of bytes to try to put */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine puts bytes from <i>buffer</i> into ring buffer <i>ringId</i>. Thespecified number of bytes will be put into the ring, up to the number ofbytes available in the ring.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>The number of bytes actually put into the ring buffer;it may be less than number requested, even zero,if there is insufficient room in the ring buffer at the time of the call.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngIsEmpty"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngIsEmpty( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngIsEmpty( )</strong> - test if a ring buffer is empty</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>BOOL rngIsEmpty ( RING_ID ringId /* ring buffer to test */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine determines if a specified ring buffer is empty.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>TRUE if empty, FALSE if not.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngIsFull"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngIsFull( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngIsFull( )</strong> - test if a ring buffer is full (no more room)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>BOOL rngIsFull ( RING_ID ringId /* ring buffer to test */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine determines if a specified ring buffer is completely full.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>TRUE if full, FALSE if not.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngFreeBytes"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngFreeBytes( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngFreeBytes( )</strong> - determine the number of free bytes in a ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int rngFreeBytes ( RING_ID ringId /* ring buffer to examine */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine determines the number of bytes currently unused in a specifiedring buffer.<p></blockquote><h4>RETURNS</h4><blockquote><p>The number of unused bytes in the ring buffer.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngNBytes"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngNBytes( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngNBytes( )</strong> - determine the number of bytes in a ring buffer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int rngNBytes ( RING_ID ringId /* ring buffer to be enumerated */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine determines the number of bytes currently in a specifiedring buffer.<p></blockquote><h4>RETURNS</h4><blockquote><p>The number of bytes filled in the ring buffer.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngPutAhead"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngPutAhead( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngPutAhead( )</strong> - put a byte ahead in a ring buffer without moving ring pointers</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void rngPutAhead ( RING_ID ringId, /* ring buffer to put byte in */ char byte, /* byte to be put in ring */ int offset /* offset beyond next input byte where to */ /* put byte */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine writes a byte into the ring, but does not move the ring bufferpointers. Thus the byte will not yet be available to <b><a href="./rngLib.html#rngBufGet">rngBufGet</a>( )</b> calls.The byte is written <i>offset</i> bytes ahead of the next input location in thering. Thus, an offset of 0 puts the byte in the same position as would<b>RNG_ELEM_PUT</b> would put a byte, except that the input pointer is not updated.<p>Bytes written ahead in the ring buffer with this routine can be made availableall at once by subsequently moving the ring buffer pointers with the routine<b><a href="./rngLib.html#rngMoveAhead">rngMoveAhead</a>( )</b>.<p>Before calling <b><a href="./rngLib.html#rngPutAhead">rngPutAhead</a>( )</b>, the caller must verify that at least<i>offset</i> + 1 bytes are available in the ring buffer.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b><hr><a name="rngMoveAhead"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>rngMoveAhead( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rngMoveAhead( )</strong> - advance a ring pointer by <i>n</i> bytes</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void rngMoveAhead ( RING_ID ringId, /* ring buffer to be advanced */ int n /* number of bytes ahead to move input pointer */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine advances the ring buffer input pointer by <i>n</i> bytes. This makes<i>n</i> bytes available in the ring buffer, after having been written ahead inthe ring buffer with <b><a href="./rngLib.html#rngPutAhead">rngPutAhead</a>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./rngLib.html#top">rngLib</a></b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -