Difference between revisions of "ARDUINO MEGA Functions Debug"

From ROBOTC API Guide
Jump to: navigation, search
(writeDebugStream)
(writeDebugStream)
Line 8: Line 8:
 
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
|-
 
|-
| class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">writeDebugStream</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">const string</span><span class="bigCodeBasic">sFormatString</span><span class="bigCodePunc">)</span>
+
| class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">writeDebugStream</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">const string </span><span class="bigCodeBasic">sFormatString</span><span class="bigCodePunc">, </span><span class="bigCodeBasic">...</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#dataType_void|void]]) The Debug Stream functionality allow the user to output formatted text to a debug terminal, similar to a printf statement in a command line terminal window.
+
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|([[Data_Types#dataType_void|void]]) The Debug Stream functionality allow the user to output formatted text to a debug terminal. This command works similar to a print to LCD command, but displays the information to a ROBOTC debugger window. You can open this debugger window from the "Robot -> Debugger Windows -> Debug Stream" window when in Expert or Super User mode.
 
|-
 
|-
 
|
 
|
Line 19: Line 19:
 
   |-
 
   |-
 
   | style="border-style: solid; border-width: 1px 0px 1px 0px"|''sFormatString''  
 
   | style="border-style: solid; border-width: 1px 0px 1px 0px"|''sFormatString''  
   | style="border-style: solid; border-width: 1px 0px 1px 0px"|A formatted String
+
   | style="border-style: solid; border-width: 1px 0px 1px 0px"|A formatted string following standard C-Style convention for showing data inline.
 
   | style="border-style: solid; border-width: 1px 0px 1px 0px"|[[Data_Types#dataType_void|void]]
 
   | style="border-style: solid; border-width: 1px 0px 1px 0px"|[[Data_Types#dataType_void|void]]
 
   |-
 
   |-
Line 28: Line 28:
 
   |-
 
   |-
 
   |<syntaxhighlight lang="robotc">
 
   |<syntaxhighlight lang="robotc">
string sTemp = "ROBOTC";               // create a string, 'sTemp' to be "ROBOTC"
+
  int fooBarVar = 503;                       //Create a Variable to Display
char sArray[20];                      // create a char array, 'sArray' of size 20
+
  writeDebugStream("Value: %d", fooBarVar);  //Write the string "Value: 503" to the Debug Stream
memcpy(sArray, sTemp, sizeof(sTemp));  // copy characters from 'sTemp' to 'sArray'
+
 
</syntaxhighlight>
 
</syntaxhighlight>
 
   |-
 
   |-

Revision as of 00:34, 10 May 2012

ARDUINOFunctions and Variables → ARDUINO MEGA Functions Debug


Color Key
Function:
Variable:


writeDebugStream

void writeDebugStream(const string sFormatString, ...)
(void) The Debug Stream functionality allow the user to output formatted text to a debug terminal. This command works similar to a print to LCD command, but displays the information to a ROBOTC debugger window. You can open this debugger window from the "Robot -> Debugger Windows -> Debug Stream" window when in Expert or Super User mode.
Parameter Explanation Data Type
sFormatString A formatted string following standard C-Style convention for showing data inline. void
  int fooBarVar = 503;                       //Create a Variable to Display
  writeDebugStream("Value: %d", fooBarVar);  //Write the string "Value: 503" to the Debug Stream


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.
Parameter Explanation Data Type
pToBuffer buffer to set void
nValue value to set buffer to short
nNumbOfBytes number of bytes to set short
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


nVexMasterVersion

const word nVexMasterVersion
(word) Variable contains the firmware version for the VEX master CPU.
int MasterFirmwareVer = nVexMasterVersion; // stores the value of the Master Firmware to a variable


version

const word version
(word) Contains the firmware version number.
displayNextLCDNumber(version);  // display the current firmware version on the LCD