使用Eclipse米洛OPC UA打开、读取和写入文件

ifmq2ha2  于 2023-03-08  发布在  Eclipse
关注(0)|答案(1)|浏览(246)

我总是收到错误消息

Exception in thread "main" UaMethodException: status=Bad_NotFound, message=A requested item was not found or a search operation ended without success..

要以读模式打开文件,我必须将字节中的第一位设置为1。我无法做到这一点。

val nodeId = new NodeId(2, "Demo.Files.readwrite.txt") 

  val client: Option[OpcUaClient] = OpcConnector.createOpcClients()
  
  val objectNode = client.get.getAddressSpace.getObjectNode(nodeId)

  val x = new QualifiedName(0, "Open")

  val method = objectNode.getMethod(x)

  val b: Byte = 1
  val inputs: Array[Variant] = Array(new Variant(b))
  val outputs: Array[Variant] = method.call(inputs)
  private val logger = LoggerFactory.getLogger(getClass)
  logger.info("Input values: " + inputs.mkString("Array(", ", ", ")"))
  logger.info("Output values: " + outputs.mkString("Array(", ", ", ")"))

我尝试将B声明为字节,并将b设置为1以获得“00000001”。

8yparm6h

8yparm6h1#

引发此异常的可能是objectNode.getMethod(x) ...
你能用Wireshark捕获这个吗?你确定你有正确的对象节点吗?

相关问题