Universal Robots Forum

Get Modbus Signals with the ScriptWriter


I’d like to get a Modbussignal by inserting the Signal-Name as a String variable in the Script-Function. As it is shown below.


Unfortunatly this doesn’t work and I get the following message. Although the first Assign-Command without the variable works just fine…

Is there a way to solve this Problem so I can use String variables to address the Modbussignals?

try changing it to

writer.assign(modbus_value, "modbus_get_signal_status(\"" + modbus_1 + "\", False)");

where I’ve only added " before and after your modbus_1 inclusion. This way it gives a String instead of what it believes to be a variable (“MODBUS_1” instead of MODBUS_1).