View unanswered posts | View active topics It is currently Sun Dec 21, 2014 4:53 pm

Reply to topic  [ 5 posts ] 
Debugging log 
Author Message

Joined: Fri Jul 20, 2012 10:29 am
Posts: 4
Post Debugging log
how can we record the output of the debugger (including data type values)
we've identified a "trace.txt" exists that logs all information dealing with the ROBOTC's debugging process
where can we find it?

platform: windows 7
robotc version: 3.5.4

Mon Nov 12, 2012 1:09 pm
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 619
Post Re: Debugging log
You can use the writeDebugStream and writeDebugStreamLine commands (found here on our wiki) to write values to the Debug Stream debugger window; you can write messages and/or sensor values directly to the debugger window. For example:

#pragma config(Sensor, S1,     sonar,          sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
   int foo;
      foo = time100[T1]/10;
      writeDebugStreamLine("The sonar value at %d seconds is %d", foo, SensorValue[sonar]);

This program has a Sonar sensor on port 1 (aptly named 'sonar'). It also creates an integer called 'foo' that we will use as a placeholder for the elapsed time.

The first line of code, 'clearDebugStream();' clears any old values from the Debug Stream debugger window. The second line, ClearTimer(T1) clears out the timer we will be using and the while(true) loop keeps the program running indefinitely. The integer foo is then assigned the value of the timer T1, divided by 10 to give whole numbers.

The writeDebugStreamLine tells the program to make a new line that contains the text "The sonar value at", a decimal value, "seconds is ", and another decimal value (the %d means 'decimal value'; %f, for instance, stands for float. There is a full listing of the supported types on our wiki.) After the text are the parameters for the first %d value and the second %d value; in this case the variable 'foo' (which holds the value of the T1 timer) and the value of the Sonar sensor. We then wait for 1 second and loop through again.

The result result, which appears in the Debug Stream window, looks like this:
The sonar value at 0 seconds is 23
The sonar value at 1 seconds is 23
The sonar value at 2 seconds is 22
The sonar value at 3 seconds is 255
The sonar value at 4 seconds is 255
The sonar value at 5 seconds is 12
The sonar value at 6 seconds is 13
The sonar value at 7 seconds is 24
The sonar value at 8 seconds is 33

You can modify the code or use the writeDebugStream commands in custom code to display whatever you need it to. You can then copy and paste the information to another document (an Excel spreadsheet, for instance) and save it locally.

Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody

Thu Nov 15, 2012 6:08 pm
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 163
Location: California, USA
Post Re: Debugging log

string Robored = "Awesome"
~~Neil Balch~~

Fri Nov 16, 2012 5:18 pm
Profile WWW
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 163
Location: California, USA
Post Re: Debugging log
Is there someone who could explain in more detail for me?

I don't get it.

string Robored = "Awesome"
~~Neil Balch~~

Fri Nov 16, 2012 11:54 pm
Profile WWW

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post Re: Debugging log
The debug stream is a small window that appears while you are debugging a program in RobotC (after you've compiled/downloaded and started the program). You can include this code ...
#pragma DebuggerWindows("debugStream")

... to automatically display it.

The program sends formatted strings to the debug stream, which acts like a console output, or the NXT display screen. Using the writeDebugStream and writeDebugStreamLine functions, the program can display text in a window on the computer screen that may reflect sensor readings, joystick values, or any other variables the robot is dealing with. As JohnWatson said, string formatting allows you to insert variables and other non-constant elements into the display text.

writeDebugStream("I have %i burritos.", 5);

In this code, the program replaces '%i' with the argument given, 5 (so it would print "I have 5 burritos"). '%i' refers to integers, '%f' to floating point decimal numbers, '%s' to strings, etc. There's a complete list here.

Sat Nov 17, 2012 1:46 am
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.