Calling method on OPC UA server for file sending to a press

Hello,

I am trying to send the recipe file to an Arburg press. The connection is OPCUA and we have a method to call.
It needs some flags and a file as a ByteString.

image

I tried with UA expert and I am able to call the method and send the file.
With Ignition I create a script that at the end calls
file = open(filePath+fileName, “rb”)
byte = file.read()
digit=len(byte)
file.close()

result = system.opcua.callMethod(
“M028783”,
“ns=2;i=399860”,
“ns=2;i=399790”,
[1, 1, 0, 0,byte]
)

In this case I get an error like this one:
image

I am assuming that the file I am passing is in the wrong format, but since is the same file I used with UA Expert, I think that I am reading the file in the wrong way.

Any idea on how to read the file in order to have a ByteString?

Many thanks
Andrea

What version of Ignition are you using? What is the type of the bytes argument you are passing to callMethod? I think just ints should work…

Try using system.file.readFileAsBytes instead of opening the file in Jython, which just gives you a String value.

https://docs.inductiveautomation.com/display/DOC81/system.file.readFileAsBytes

You need to be on a least Ignition 8.1.1 for this to work I think.

At the moment we have 8.0.12, but in case we can try a test with an installation on a laptop and give it a try.