Fanuc SDK documentation
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
// 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");
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.
// 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");
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
Members of Common.Kcl.BreakpointsResult :public class BreakpointsResult : Result {public BreakpointsResult()// Gets the breakpoints set on the task.public Breakpoint[] Breakpoints { get; }// Indicates that responses have been completed and receivedprotected override void EndReceive()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)// 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).protected override bool ShouldCompleteOnEmptyAnswer()}
public class Breakpoint {public Breakpoint()public override bool Equals(object obj)public override int GetHashCode()// Gets the line number where the breakpoint is set.public int Line { get; }public override string ToString()}
public class AddBreakpointResult : Result {public AddBreakpointResult()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)}
public class RemoveBreakpointResult : Result {public RemoveBreakpointResult()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)}
public class StepOnResult : Result {public StepOnResult()// During implementation, return true if it is assumed that the frame has finished being received.protected override bool FromResult(string data)}
public class TaskInformationResult : Result {public TaskInformationResult()// Gets the current line number.public int CurrentLine { get; }// Parses the result data and populates the properties of the class.protected override bool FromResult(string data)// Gets the hold conditions.public string HoldConditions { get; }// Gets a value indicating whether the task is invisible.public bool InvisibleTask { get; }// Gets the type of the program.public ProgramType ProgramType { get; }// Gets the name of the routine.public string RoutineName { get; }// Gets a value indicating whether the task is a system task.public bool SystemTask { get; }// Gets the name of the task.public string TaskName { get; }// Gets the task number.public int TaskNumber { get; }// Gets the task status.public TaskStatus TaskStatus { get; }// Gets the task status as a string.public string TaskStatusStr { get; }public override string ToString()}