📄 quickref.htm
字号:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMboxPost()</span><span
style='color:black'> returns one of two error codes:</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if the message was deposited in the mailbox.</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MBOX_FULL</span><span
style='color:black'> if the mailbox already contained a message.</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_ERR_EVENT_TYPE</span><span
style='color:black'> pevent is not pointing to a mailbox.</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'> </span></p>
<p class=Heading><a name=OSMboxQuery>OSMboxQuery</a>()</p>
<p class=MsoNormal style='line-height:11.0pt;text-autospace:none'><span
style='font-size:9.0pt;font-family:"Courier New";color:black'><b> </b></span></p>
<p class=Prototype> INT8U OSMboxQuery(OS_EVENT *pevent, OS_MBOX_DATA
*pdata);</p>
<p class=MsoNormal style='line-height:6.0pt;text-autospace:none'> </p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMboxQuery()</span><span
style='color:black'> obtains information about a message mailbox. Your
application must allocate an </span><span style='font-size:9.0pt;font-family:
"Courier New";color:black'>OS_MBOX_DATA</span><span style='color:black'> data
structure, which is used to receive data from the event control block of the message
mailbox. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxQuery()</span><span style='color:black'> allows you to
determine whether any tasks are waiting for a message at the mailbox and how
many tasks are waiting (by counting the number of 1s in the .</span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSEventTbl[]</span><span
style='color:black'> field). You can also examine the current content of the
mailbox. Note that the size of .</span><span style='font-size:9.0pt;font-family:
"Courier New";color:black'>OSEventTbl[]</span><span style='color:black'> is
established by the #define constant </span><span style='font-size:9.0pt;
font-family:"Courier New";color:black'>OS_EVENT_TBL_SIZE</span><span
style='color:black'> (see uCOS_II.H).</span></p>
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Arguments</b></span></p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>pevent</span><span
style='color:black'> is a pointer to the mailbox. This pointer is returned to
your application when the mailbox is created [see </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMboxCreate()</span><span
style='color:black'>].</span></p>
<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>pdata</span><span style='color:black'> is a pointer to a data
structure of type </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OS_MBOX_DATA</span><span style='color:black'>, which contains the
following fields:</span></p>
<pre>
void *OSMsg; /* Copy of the message stored in the mailbox */
INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* Copy of the mailbox wait list */
INT8U OSEventGrp;
</pre>
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Return Value</b></span></p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMboxQuery()</span><span
style='color:black'> returns one of two error codes:</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if the call was successful.</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_ERR_EVENT_TYPE</span><span
style='color:black'> if you didn’t pass a pointer to a message mailbox.</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'> </span></p>
<p class=Heading><a name=OSMemCreate>OSMemCreate</a>()</p>
<p class=MsoNormal style='line-height:11.0pt;text-autospace:none'><span
style='font-size:9.0pt;font-family:"Courier New";color:black'><b> </b></span></p>
<p class=Prototype> OS_MEM *OSMemCreate(void *addr, INT32U nblks, INT32U
blksize, INT8U *err);</p>
<p class=MsoNormal style='line-height:6.0pt;text-autospace:none'> </p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemCreate()</span><span
style='color:black'> creates and initializes a memory partition. A memory
partition contains a user-specified number of fixed-size memory blocks. Your
application can obtain one of these memory blocks and, when done, release the
block back to the partition.</span></p>
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Arguments</b></span></p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>addr</span><span
style='color:black'> is the address of the start of a memory area that is used
to create fixed-size memory blocks. Memory partitions can be created either
using static arrays or malloc() during startup.</span></p>
<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>nblks</span><span style='color:black'> contains the number of
memory blocks available from the specified partition. You must specify at least
two memory blocks per partition.</span></p>
<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>blksize</span><span style='color:black'> specifies the size (in
bytes) of each memory block within a partition. A memory block must be large
enough to hold at least a pointer.</span></p>
<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>err</span><span style='color:black'> is a pointer to a variable
that holds an error code. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMemCreate()</span><span style='color:black'> sets *err to</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if the memory partition was created successfully,</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MEM_INVALID_PART</span><span
style='color:black'> if a free memory partition was not available,</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MEM_INVALID_BLKS</span><span
style='color:black'> if you didn’t specify at least two memory blocks per
partition, or</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MEM_INVALID_SIZE</span><span
style='color:black'> if you didn’t specify a block size that can contain
at least a pointer variable.</span></p>
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Return Value</b></span></p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemCreate()</span><span
style='color:black'> returns a pointer to the created memory partition control
block if one is available. If no memory partition control block is available, </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemCreate()</span><span
style='color:black'> returns a NULL pointer.</span></p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='color:black'> </span></p>
<p class=Heading><a name=OSMemGet>OSMemGet</a>()</p>
<p class=MsoNormal style='line-height:11.0pt;text-autospace:none'><span
style='font-size:9.0pt;font-family:"Courier New";color:black'><b> </b></span></p>
<p class=Prototype> void *OSMemGet(OS_MEM *pmem, INT8U *err);</p>
<p class=MsoNormal style='line-height:6.0pt;text-autospace:none'> </p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemGet</span><span
style='color:black'> obtains a memory block from a memory partition. It is
assumed that your application knows the size of each memory block obtained.
Also, your application must return the memory block [using </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemPut()</span><span
style='color:black'>] when it no longer needs it. You can call </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemGet()</span><span
style='color:black'> more than once until all memory blocks are allocated.</span></p>
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Arguments</b></span></p>
<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>pmem</span><span
style='color:black'> is a pointer to the memory partition control block that is
returned to your application from the OSMemCreate() call.</span></p>
<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>err</span><span style='color:black'> is a pointer to a variable
that holds an error code. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMemGet()</span><span style='color:black'> sets *err to one of
the following:</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if a memory block was available and returned to your
application.</span></p>
<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>• </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MEM_NO_FREE_BLKS</span><span
style='color:black'> if the memory partition didn’t contain any more
memory blocks to allocate.</span></p>
<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -