Debugging & breakpoints
Add, remove, and manage breakpoints on TP and Karel programs. Step through code line by line using Telnet KCL.
The Fanuc SDK lets you add, remove, and manage breakpoints on TP and Karel programs. You can also step through code line by line, making it a powerful tool for remote debugging and prototyping a custom TP editor.
Breakpoints
parameters.Telnet.TelnetKclPassword = "TELNET_PASS";robot.Connect(parameters);// Add a breakpoint at line 10robot.Telnet.AddBreakpoint("MyProgram", 10);// List breakpointsBreakpointsResult result = robot.Telnet.GetBreakpoints("MyProgram");foreach (Breakpoint bp in result.Breakpoints){Console.WriteLine($"Breakpoint at line {bp.Line}");}// Remove a single breakpointrobot.Telnet.RemoveBreakpoint("MyProgram", 10);// Remove all breakpoints of a programrobot.Telnet.RemoveAllBreakpoints("MyProgram");}}
Click to see the full code
Step-by-step execution and task info
When step mode is enabled, the program pauses after each line execution, allowing you to inspect state between instructions.
parameters.Telnet.TelnetKclPassword = "TELNET_PASS";robot.Connect(parameters);// Enable step mode for a taskrobot.Telnet.StepOn("MyProgram");// Disable step moderobot.Telnet.StepOff();// Get task information (current line, status, etc.)TaskInformationResult info = robot.Telnet.GetTaskInformation("MyProgram");}}
Click to see the full code
Complete example
using UnderAutomation.Fanuc;using UnderAutomation.Fanuc.Telnet;public class TelnetDebugging{static void Main(){FanucRobot robot = new FanucRobot();ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");parameters.Telnet.Enable = true;parameters.Telnet.TelnetKclPassword = "TELNET_PASS";robot.Connect(parameters);// Add a breakpoint at line 10 of MyProgramrobot.Telnet.AddBreakpoint("MyProgram", 10);// List all breakpointsBreakpointsResult result = robot.Telnet.GetBreakpoints("MyProgram");foreach (Breakpoint bp in result.Breakpoints){Console.WriteLine($"Breakpoint at line {bp.Line}");}// Remove a single breakpointrobot.Telnet.RemoveBreakpoint("MyProgram", 10);// Remove all breakpointsrobot.Telnet.RemoveAllBreakpoints("MyProgram");// Enable step-by-step executionrobot.Telnet.StepOn("MyProgram");// Disable step moderobot.Telnet.StepOff();}}
See also
- TP editor with breakpoints : Build a custom TP editor with syntax highlighting and breakpoints
API reference
Result containing the breakpoints of a task.
| Member | Type | Description |
|---|---|---|
BreakpointsResult() Constructor | ||
Breakpoints Property read only | Breakpoint[] | Gets the breakpoints set on the task. |
EndReceive() Method | void | Indicates that responses have been completed and received |
FromResult(string) Method | bool | During implementation, return true if it is assumed that the frame has finished being received. |
ShouldCompleteOnEmptyAnswer() Method | bool | Controls whether the result should be finalized when an empty answer is received (i.e. a frame consisting only of VT100 escape sequences and whitespace). Override and return false until meaningful data has been accumulated, to prevent premature finalization caused by intermediate display-update frames. Default is true (backward compatible: finalize immediately on empty answer). |
Represents a breakpoint set on a task line.
| Member | Type | Description |
|---|---|---|
Breakpoint() Constructor | ||
Line Property read only | int | Gets the line number where the breakpoint is set. |
Equals(object) Method | bool | |
GetHashCode() Method | int | |
ToString() Method | string |
Result of adding a breakpoint.
| Member | Type | Description |
|---|---|---|
AddBreakpointResult() Constructor | ||
FromResult(string) Method | bool | During implementation, return true if it is assumed that the frame has finished being received. |
Result of removing a breakpoint.
| Member | Type | Description |
|---|---|---|
RemoveBreakpointResult() Constructor | ||
FromResult(string) Method | bool | During implementation, return true if it is assumed that the frame has finished being received. |
Result of the step on command.
| Member | Type | Description |
|---|---|---|
StepOnResult() Constructor | ||
FromResult(string) Method | bool | During implementation, return true if it is assumed that the frame has finished being received. |
Result of the show task command containing task properties.
| Member | Type | Description |
|---|---|---|
TaskInformationResult() Constructor | ||
CurrentLine Property read only | int | Gets the current line number. |
HoldConditions Property read only | string | Gets the hold conditions. |
InvisibleTask Property read only | bool | Gets a value indicating whether the task is invisible. |
ProgramType Property read only | ProgramType | Gets the type of the program. |
RoutineName Property read only | string | Gets the name of the routine. |
SystemTask Property read only | bool | Gets a value indicating whether the task is a system task. |
TaskName Property read only | string | Gets the name of the task. |
TaskNumber Property read only | int | Gets the task number. |
TaskStatus Property read only | TaskStatus | Gets the task status. |
TaskStatusStr Property read only | string | Gets the task status as a string. |
FromResult(string) Method | bool | Parses the result data and populates the properties of the class.
|
ToString() Method | string |