ARDUINO MEGA Functions Miscellaneous
(Created page with "<yambe:breadcrumb>ARDUINO_MEGA_Functions_and_Variables|Functions and Variables</yambe:breadcrumb> <br /> {{tl|1|1}} <br /> == memcpy == {| style="color:black;" width="100%" ...") |
|||
| Line 88: | Line 88: | ||
<br /> | <br /> | ||
| − | == | + | == memcpy == |
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
| − | | class=" | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">memcpy</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">void </span><span class="bigCodeBasic">&pToBuffer</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">const void </span><span class="bigCodeBasic">&pFromBuffer</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">const short </span><span class="bigCodeBasic">nNumbOfBytes</span><span class="bigCodePunc">)</span> |
|- | |- | ||
| − | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types# | + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Function copies characters from <span class="codeBasic">pFromBuffer</span> to <span class="codeBasic">pToBuffer</span>. <span class="codeBasic">nBytesToCopy</span> is the number of bytes to copy. Identical to the function found in conventional C 'string.h' library. |
| + | |- | ||
| + | | | ||
| + | {| class="parameterTable" cellpadding="5%" width="100%" | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter | ||
| + | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''pToBuffer'' | ||
| + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|buffer to copy to | ||
| + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|[[Data_Types#dataType_void|void]] | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|''pFromBuffer'' | ||
| + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|buffer to copy from | ||
| + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|[[Data_Types#dataType_void|void]] | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''nNumbOfBytes'' | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|number of bytes to copy | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[Data_Types#dataType_short|short]] | ||
| + | |- | ||
| + | |} | ||
|- | |- | ||
| | | | ||
{| | {| | ||
|- | |- | ||
| − | |<syntaxhighlight lang="robotc"> | + | |<syntaxhighlight lang="robotc"> |
| + | string sTemp = "ROBOTC"; // create a string, 'sTemp' to be "ROBOTC" | ||
| + | char sArray[20]; // create a char array, 'sArray' of size 20 | ||
| + | memcpy(sArray, sTemp, sizeof(sTemp)); // copy characters from 'sTemp' to 'sArray' | ||
| + | </syntaxhighlight> | ||
|- | |- | ||
|} | |} | ||
| Line 105: | Line 129: | ||
<br /> | <br /> | ||
| − | == | + | == memset == |
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
| − | | class=" | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">memset</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">void </span><span class="bigCodeBasic">&pToBuffer</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">const short </span><span class="bigCodeBasic">nValue</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">const short </span><span class="bigCodeBasic">nNumbOfBytes</span><span class="bigCodePunc">)</span> |
|- | |- | ||
| − | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types# | + | | style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) Sets a block of memory at <span class="codeBasic">pToBuffer</span> to the value <span class="codeBasic">nValue</span>. <span class="codeBasic">nNumbOfBytes</span> is the number of bytes to set. This is a useful function for initializing the value of an array to all zeros. Identical to the function found in conventional C 'string.h' library. |
| + | |- | ||
| + | | | ||
| + | {| class="parameterTable" cellpadding="5%" width="100%" | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Parameter | ||
| + | ! width="60%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | ||
| + | ! width="20%" style="border-style: solid; border-width: 0px 0px 1px 0px"|Data Type | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''pToBuffer'' | ||
| + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|buffer to set | ||
| + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|[[Data_Types#dataType_void|void]] | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|''nValue'' | ||
| + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|value to set buffer to | ||
| + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|[[Data_Types#dataType_short|short]] | ||
| + | |- | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''nNumbOfBytes'' | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|number of bytes to set | ||
| + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[Data_Types#dataType_short|short]] | ||
| + | |- | ||
| + | |} | ||
|- | |- | ||
| | | | ||
| Line 116: | Line 160: | ||
|- | |- | ||
|<syntaxhighlight lang="robotc"> | |<syntaxhighlight lang="robotc"> | ||
| − | + | int kSendSize = 1; // we will be sending 1 byte | |
| + | ubyte BytesToSend[kSendSize]; // create a ubyte array of size 1 | ||
| + | short nMsgXmit = 0; // we will be setting them to 0 | ||
| + | memset(BytesToSend, nMsgXmit, sizeof(BytesToSend)); // set the Byte Array to 0 | ||
| + | </syntaxhighlight> | ||
|- | |- | ||
|} | |} | ||
Revision as of 18:11, 9 May 2012
ARDUINO → Functions and Variables → ARDUINO MEGA Functions Miscellaneous
|
| |||||||
memcpy
| void memcpy(void &pToBuffer, const void &pFromBuffer, const short nNumbOfBytes) | ||||||||||||
| (void) Function copies characters from pFromBuffer to pToBuffer. nBytesToCopy is the number of bytes to copy. Identical to the function found in conventional C 'string.h' library. | ||||||||||||
| ||||||||||||
|
memset
| void memset(void &pToBuffer, const short nValue, const short nNumbOfBytes) | ||||||||||||
| (void) Sets a block of memory at pToBuffer to the value nValue. nNumbOfBytes is the number of bytes to set. This is a useful function for initializing the value of an array to all zeros. Identical to the function found in conventional C 'string.h' library. | ||||||||||||
| ||||||||||||
|
memcpy
| void memcpy(void &pToBuffer, const void &pFromBuffer, const short nNumbOfBytes) | ||||||||||||
| (void) Function copies characters from pFromBuffer to pToBuffer. nBytesToCopy is the number of bytes to copy. Identical to the function found in conventional C 'string.h' library. | ||||||||||||
| ||||||||||||
|
memset
| void memset(void &pToBuffer, const short nValue, const short nNumbOfBytes) | ||||||||||||
| (void) Sets a block of memory at pToBuffer to the value nValue. nNumbOfBytes is the number of bytes to set. This is a useful function for initializing the value of an array to all zeros. Identical to the function found in conventional C 'string.h' library. | ||||||||||||
| ||||||||||||
|