Universal Robots Forum

XMLRPC: failed with error code 1: <class 'termios.error'>:(5, 'Input/output error')

I implemented a program that communicates through Tool I/O.

Installation Node :
Implemented the serial communication daemon using /dev/ttyTool port by refferring to the mydaemonswing example.

public void generateScript(ScriptWriter writer) {
    writer.assign(XMLRPC_VARIABLE, "rpc_factory(\"xmlrpc\", \"" + PORT + "/RPC2\")");
    writer.appendLine(XMLRPC_VARIABLE + ".set_data(1)");

Go to Installation > General > Tool IO and set Tool Analog Inputs to Communications Interface.

However, when I run the program, an error occurs in the script on the installation node.

Popup Title: An error occurred in the running program

XMLRPC: Failed with error code 1: <class ‘termios.error’>:(5, ‘Input/output error’)

Installation node: SOMETHING
OK / Go to program Button

^Advanced view(script) ------------------------------

Script Code

  Error position: line24, column 3
  # begin:  URCap Installation Node
  #   Source: XXXX
  #   Type:  SOMETHING
  mydaemon = rpc_factory("xmlrpc", "")
  mydaemon.set_data(1)    <- Error Here
  # end:  URCap Installation Node
  while (True):

I think it seems to be a problem with port access permissions.
But I don’t know what did I do wrong…

In fact, if it fails to open the port, the daemon fails to run, but the daemon is running well.

What kind of data type parameter does your set_date()-method require on client and server side?
I think i had the same problem because of that.

The problem is… global variable.

I opened the serial port as a global variable, and tried to communicate using the global variable in the function.

ser = serial.Serial(port = '/dev/ttyTool', baudrate=57600)

def set_data(data):
    packet = [1, 2, 3, 4, 5]

    global ser
    return True

There was no problem when installing ursim on a laptop, connecting a usb to serial device and communicating via /dev/ttyUSB0.

Now, the problem is solved by opening the port in all fuctions that use serial communications, then communicating, and then close the port.

def set_data(data):
    packet = [1, 2, 3, 4, 5]

    ser = serial.Serial(port = '/dev/ttyTool', baudrate=57600)
    return True