UnderAutomation
Any question?

[email protected]

Contact us
UnderAutomation
โŒ˜Q
Fanuc SDK documentation
Reading & Writing Registers
Documentation home

TP editor with breakpoints

Discover how to use breakpoints with Fanuc robots using the Fanuc SDK! Learn to debug TP and Karel programs, prototype your own TP Editor, and explore Telnet & FTP features with step-by-step examples and a video demo.

๐ŸŽ‰ Introduction

The Fanuc SDK unlocks a hidden gem in Fanuc robots: the ability to set breakpoints! ๐Ÿ›‘๐Ÿค–

Although this feature has been natively supported on Fanuc controllers for decades, it's remained in the shadows because it's not integrated into the TP Editor (TPE) of ROBOGUIDE or Teach Pendant. ๐Ÿ˜ด

This feature is a game-changer for developers who want to edit programs , or at the very least , pause execution at specific lines without building complicated synchronization mechanisms using flags. ๐Ÿโœจ

Fanuc TP Editor with breakpoints

โ“ What's a Breakpoint?

A breakpoint is a pause point in a program ๐Ÿง˜โ€โ™‚๏ธ. It lets you halt execution at a specific line to inspect what's going on , super handy for debugging!

You can add multiple breakpoints across your codebase , whether it's a TP program or even a Karel one! ๐Ÿ’ฅ๐Ÿ“œ

๐Ÿ”ง How to Add or Remove a Breakpoint?

The Telnet protocol natively supports breakpoint manipulation. ๐Ÿ’ป๐Ÿ”Œ
Here are the available commands:

  • FanucRobot.Telnet.AddBreakpoint: Add a breakpoint at a specific line ๐ŸŽฏ
  • FanucRobot.Telnet.GetBreakpoints: Retrieve the list of active breakpoints ๐Ÿ“‹
  • FanucRobot.Telnet.RemoveAllBreakpoints: Remove all current breakpoints ๐Ÿงน

โš ๏ธ Note: Breakpoints are automatically removed when a task is aborted.

๐Ÿงช Example

using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Telnet;
public class Breakpoints
{
static void Main()
{
// Create a new Fanuc robot instance
FanucRobot robot = new FanucRobot();
// Set connection parameters
ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
parameters.Telnet.Enable = true;
parameters.Telnet.TelnetKclPassword = "TELNET_PASS";
// Connect to the robot
robot.Connect(parameters);
/**/
// Add a breakpoint at line 10 of TP or Karel program MyProgram
robot.Telnet.AddBreakpoint("MyProgram", 10);
// List all breakpoints of TP program MyProgram
BreakpointsResult result = robot.Telnet.GetBreakpoints("MyProgram");
foreach (Breakpoint breakpoint in result.Breakpoints)
{
Console.WriteLine($"Breakpoint at line {breakpoint.Line}");
}
// Remove all breakpoints of TP program MyProgram
robot.Telnet.RemoveAllBreakpoints("MyProgram");
/**/
}
}

๐Ÿง  What If We Prototyped a TP Editor with Breakpoints?

Wellโ€ฆ it's actually easier than you'd think thanks to the Fanuc SDK! ๐Ÿ˜„
The hard part? Building the syntax-highlighted code editor itself. ๐ŸŽจ

Here's how we can quickly prototype one using WinForms with the following tools:

  • A TreeView to display *.ls files ๐ŸŒณ
  • A RichTextBox with syntax highlighting for TP code ๐ŸŒˆ
  • A "magic margin" to set breakpoints, show the execution line, and display line numbers starting from the /MN section ๐Ÿช„
  • Buttons to save, run the program, and more ๐ŸŽ›๏ธ

We'll use the SDK's FTP capabilities to:

  • List available files ๐Ÿ“
  • Read content of *.ls files ๐Ÿ“–
  • Upload modified programs ๐Ÿš€
  • Monitor tasks in the background: task names, call stacks, and the current line being executed ๐Ÿ”„

We'll also use the SDK's Telnet features to:

  • Start and stop program execution โฏ๏ธ
  • And hey , let's go wild , why not add step-by-step execution too? ๐Ÿพ

๐Ÿ’ก Check out this C# class on GitHub: TPEditorControl

And here's a quick video demo of what it looks like in action โฌ‡๏ธ
This sample is part of the Showcase demo app for Windows, available for download here. โฌ‡๏ธ

๐Ÿš€ Let's Go Even Further

The possibilities here are endless! ๐ŸŒŒ Imagine the following upgrades:

  • Support for Karel: editing, syntax highlighting, breakpoints... you name it! ๐Ÿค“
  • Smart auto-completion โœ๏ธ
  • Real-time visualization of variables and registers ๐Ÿ“Š
  • Full call stack display (In our current demo, we simplify this by assuming the task and program are one and the same)
  • And sure, WinForms is nice and all... but why not dream bigger?
    A VSCode extension, perhaps? Or a full-blown modern IDE integration , with a graphical view of TP instructions?! ๐Ÿ˜
    Just maybe that's a teaser of what UnderAutomation might be cooking up... ๐Ÿ”ฎ๐Ÿ˜‰

Easily integrate Universal Robots, Fanuc, Yaskawa or Staubli robots into your .NET, Python, LabVIEW or Matlab applications

UnderAutomation
Contact usLegal

ยฉ All rights reserved.