UnderAutomation
Eine Frage?

[email protected]

Kontakt
UnderAutomation
⌘Q
Diese Seite ist nur auf Englisch verfügbar.

Debug: breakpoints and step mode

Add and remove breakpoints, switch the step mode and continue a stopped program, for the controller or for one task, with robot.Debug. Brand support table, C# and Python examples.

  • Prerequisites
  • Brand support
  • Example
  • Breakpoints
  • Step mode
  • One task
  • Reference
  • Methods of IDebugService
  • Errors
  • What to read next

robot.Debug debugs the programs of a robot controller from a PC: breakpoints, step mode and continue, for the whole controller or for one task. The support is partial and depends on the brand: some brands have a route for a few of these methods only, and some have none. See the table below.

Prerequisites

  • A connected RobotController. See Connect to your robot.
  • The license of the brand of the controller, or the 30 day trial. See Licensing.
  • A program that runs or that you start with Program. A program is named with its native name, as the controller names it. Lines are counted from 1.

Brand support

Each cell gives the protocol that the method uses on this brand, in the default order. The page Routing explains how the library chooses it. The table is generated from the route data of the library. (manual) marks a route that you enable yourself. "n of m" is the number of methods of the service that have a route on this brand.

Debug
MethodFanucYaskawaUniversal RobotsABBStäubli
Debug.AddBreakpointCGTP (CgtpKcl), TelnetNot availablePrimary Interface (Primary)Robot Web ServicesNot available
Debug.RemoveBreakpointCGTP (CgtpKcl), TelnetNot availablePrimary Interface (Primary)Not availableNot available
Debug.ReadBreakpointsCGTP (CgtpKcl), TelnetNot availableNot availableRobot Web ServicesNot available
Debug.SetStepModeCGTP (CgtpKcl), TelnetHigh Speed Ethernet Server, Ethernet ServerPrimary Interface (Primary)Robot Web ServicesNot available
Debug.ContinueCGTP (CgtpKcl), TelnetHigh Speed Ethernet Server, Ethernet ServerPrimary Interface (Primary)Robot Web ServicesNot available
Debug.SetTaskStepModeCGTP (CgtpKcl), TelnetNot availableNot availableNot availableNot available
Debug.ContinueTaskCGTP (CgtpKcl), TelnetNot availableNot availableNot availableNot available
Debug7 of 72 of 74 of 74 of 70 of 7

A brand that has no route for a method throws FeatureNotSupportedException (see Errors). Ask robot.Debug.IsAvailable(DebugFeature.AddBreakpoint) before the call.

Example

Breakpoints

AddBreakpoint adds a breakpoint at a line of a program, RemoveBreakpoint removes it and ReadBreakpoints returns the lines of the breakpoints of a program.

RobotController robot = new RobotController();
robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));
robot.Debug.AddBreakpoint("MAIN", 12);
foreach (int line in robot.Debug.ReadBreakpoints("MAIN"))
Console.WriteLine($"Breakpoint at line {line}");
robot.Debug.RemoveBreakpoint("MAIN", 12);
robot.Disconnect();
}
Click to see the full code

Step mode

In step mode, the program stops after each instruction and Continue runs the next one. Use these two methods for a debug session. Depending on the brand, SetStepMode sets the cycle mode of the controller (as Program.SetCycleMode with CycleMode.Step) or only changes how Continue runs. SetStepMode(false) goes back to the continuous execution.

A program paused by Program.Pause or Program.Hold continues with Program.Resume, not with Continue.

RobotController robot = new RobotController();
robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));
robot.Debug.SetStepMode(true);
// A program stopped on a breakpoint or in step mode goes to the next line
robot.Debug.Continue();
robot.Debug.SetStepMode(false);
robot.Disconnect();
}
Click to see the full code

One task

SetTaskStepMode and ContinueTask only have a route on Fanuc today: see the table. On a controller with several tasks, SetTaskStepMode switches the step mode of one task and the other tasks keep their mode. ContinueTask runs the next instruction of this task, and the other paused tasks stay paused. A brand can refuse SetTaskStepMode(task, false) with an ArgumentException when its controller turns the step mode off for every task only: use SetStepMode(false) then. Check IsAvailable(DebugFeature.SetTaskStepMode) first.

Reference

In Python, the names are in snake_case: robot.debug.add_breakpoint(...), robot.debug.read_breakpoints(...), robot.debug.set_step_mode(True), robot.debug.set_task_step_mode(...), robot.debug.continue_task(...). continue is a reserved word of Python: the method is robot.debug.continue_(). The enum members keep their names.

Methods of IDebugService

Interface
IDebugService
C#Python

Debug service of a robot controller: breakpoints and step mode. The library implements this interface. A minor version of the library can add members to it: a class of the application that implements it, for example a test double, then needs the new methods. Errors of the methods other than IsAvailable: FeatureNotSupportedException when the brand has no route for the method, RouteUnavailableException when the method has routes but none of them can be used, ControllerRefusedException when the controller received the command and refused it, RobotControllerException when the route failed (the inner exception is the exception of the brand SDK), and ArgumentException or a derived exception for an invalid argument. IsAvailable only throws ArgumentOutOfRangeException, for a value that is not in the enum. Results: a text and an array are empty when there is no value, never null. The only null values are the Native properties when there is no object of the brand SDK, and Position when the variable is not a position.

MemberTypeDescription
AddBreakpoint(string, int)
Method
void
Adds a breakpoint
  • program : Native name of the program
  • line : Line of the program, from 1
Continue()
Method
void
Continues the program stopped on a breakpoint or in step mode. A program paused by Pause or Hold continues with Resume.
ContinueTask(string)
Method
void
Continues one task stopped on a breakpoint or in step mode. The other paused tasks stay paused.
  • task : Native name of the task
IsAvailable(DebugFeature)
Method
bool
Returns true when the method can be called on the connected controller. The answer depends on the brand, on the routing settings and on the protocols that answered at the connection, not on the state of the controller.
  • feature : Method of the service
ReadBreakpoints(string)
Method
int[]
Returns the lines of the breakpoints of a program
  • program : Native name of the program
RemoveBreakpoint(string, int)
Method
void
Removes a breakpoint
  • program : Native name of the program
  • line : Line of the program, from 1
SetStepMode(bool)
Method
void
Switches the step mode on or off. In step mode, the program stops after each instruction and Continue runs the next one. Use it for a debug session. Depending on the brand, it sets the cycle mode of the controller (as SetCycleMode(CycleMode) with Step) or only changes how Continue runs. False goes back to the continuous execution.
  • on : True for step mode, false for continuous execution
SetTaskStepMode(string, bool)
Method
void
Switches the step mode of one task on or off. The other tasks keep their mode. ContinueTask(string) runs the next instruction of the task. A brand can refuse "off" with an ArgumentException when its controller turns the step mode off for every task only: use SetStepMode(bool) then.
  • task : Native name of the task
  • on : True for step mode, false for continuous execution

Errors

The page Errors explains each exception and how to avoid it.

  • FeatureNotSupportedException: the brand has no route for the method.
  • RouteUnavailableException: the method has routes, but none of them can be used, for example because the protocol did not answer at the connection.
  • ControllerRefusedException: the controller received the command and refused it.
  • RobotControllerException: the route failed. Its inner exception is the exception of the brand SDK.
  • ArgumentException: an invalid argument, for example a task step mode that the controller refuses.

IsAvailable only throws ArgumentOutOfRangeException, for a value that is not in the enum.

What to read next

  • Program: start, pause, resume and read the execution state, with the call stack.
  • State: operating mode and servo power.
  • Alarm: read the alarms of the controller.