Variables & I/O via Telnet
Read and write system variables, set output ports, simulate and unsimulate input ports using Telnet KCL.
Read and write system variables, set output ports, simulate and unsimulate input ports using Telnet KCL.
Read and write variables
parameters.Telnet.TelnetKclPassword = "TELNET_PASS";robot.Connect(parameters);// Read a variableGetVariableResult result = robot.Telnet.GetVariable("$RMT_MASTER");string value = result.RawValue;// Write a variablerobot.Telnet.SetVariable("$RMT_MASTER", 1);robot.Telnet.SetVariable("$MCR.$GENOVERRIDE", 50);robot.Telnet.SetVariable("$[MY_PROG]my_var", "hello");// Get current poseGetCurrentPoseResult pose = robot.Telnet.GetCurrentPose();}}
Click to see the full code
You can read any system variable, program variable, or user-defined variable by name. The value must match the declared data type. Use brackets ([]) after the variable name to specify an array element.
Set and simulate I/O ports
parameters.Telnet.TelnetKclPassword = "TELNET_PASS";robot.Connect(parameters);// Set an output port (DOUT port 2 = OFF)robot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);// Set an output port (DOUT port 5 = ON)robot.Telnet.SetPort(KCLPorts.DOUT, 5, 1);// Simulate an input port (DIN port 3 = ON)robot.Telnet.Simulate(KCLPorts.DIN, 3, 1);// Stop simulating DIN port 3robot.Telnet.Unsimulate(KCLPorts.DIN, 3);// Stop simulating all portsrobot.Telnet.UnsimulateAll();}}
Click to see the full code
Available port types
The KCLPorts enum defines the available port types:
| Port | Description |
|---|---|
DIN / DOUT | Digital Input / Output |
GIN / GOUT | Group Input / Output |
AIN / AOUT | Analog Input / Output |
OPIN / OPOUT | Operator Panel Input / Output |
RDI / RDO | Robot Digital Input / Output |
WDI / WDO | Weld Digital Input / Output |
PLCIN / PLCOUT | PLC Input / Output |
FLAG | Flag register |
Complete example
using UnderAutomation.Fanuc;using UnderAutomation.Fanuc.Telnet;public class TelnetVariablesIo{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);// Read a system variableGetVariableResult result = robot.Telnet.GetVariable("$RMT_MASTER");string value = result.RawValue;// Write system variablesrobot.Telnet.SetVariable("$RMT_MASTER", 1);robot.Telnet.SetVariable("$MCR.$GENOVERRIDE", 50);// Get current TCP poseGetCurrentPoseResult pose = robot.Telnet.GetCurrentPose();// Set an output portrobot.Telnet.SetPort(KCLPorts.DOUT, 2, 0);robot.Telnet.SetPort(KCLPorts.DOUT, 5, 1);// Simulate an input portrobot.Telnet.Simulate(KCLPorts.DIN, 3, 1);// Stop simulating a portrobot.Telnet.Unsimulate(KCLPorts.DIN, 3);// Stop simulating all portsrobot.Telnet.UnsimulateAll();}}
API reference
Result of a get variable command containing the raw value.
| Member | Type | Description |
|---|---|---|
GetVariableResult() Constructor | ||
RawValue Property read only | string | Gets the raw value of the variable as a string. |
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. |
ParseResult() Method | GenericVariable | Returns a structured object which represents the variable (not supported with Telnet) |
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). |
ToString() Method | string |
Result of a set variable command.
| Member | Type | Description |
|---|---|---|
SetVariableResult() Constructor | ||
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). |
Result of a set port command.
| Member | Type | Description |
|---|---|---|
SetPortResult() Constructor | ||
FromResult(string) Method | bool | During implementation, return true if it is assumed that the frame has finished being received. |
Result of a simulate port command.
| Member | Type | Description |
|---|---|---|
SimulateResult() Constructor |
Enum representing the different KCL ports.
| Name | Value | Description |
|---|---|---|
AIN | 7 | Analog Input port. |
AOUT | 8 | Analog Output port. |
DIN | 0 | Digital Input port. |
DOUT | 1 | Digital Output port. |
GIN | 9 | General Input port. |
GOUT | 10 | General Output port. |
OPOUT | 3 | Operator Panel Output port. |
RDO | 2 | Robot Digital Output port. |
TPOUT | 4 | Teach Pendant Output port. |
WDI | 5 | Weld Digital Input port. |
WDO | 6 | Weld Digital Output port. |