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

huangapple go评论61阅读模式
英文:

Open, read and write files with Eclipse Milo OPC UA

问题

我总是收到错误消息

在读取模式下打开文件,我必须将字节中的第一个位设置为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(", ", ", ")"))
英文:

I always get the error message

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

To open the file in read mode, I have to set the first bit in a byte to 1. I am unable to do this.




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(", ", ", ")"))

I tried to declare b as a byte and set b to 1 to get "00000001".

答案1

得分: 0

可能是 objectNode.getMethod(x) 引发了这个异常...

你能够捕获 Wireshark 的数据吗?你确定你使用了正确的 ObjectNode 吗?

英文:

It's probably objectNode.getMethod(x) that is throwing this Exception...

Are you able to get a Wireshark capture of this? Are you sure you have the right ObjectNode?

huangapple
  • 本文由 发表于 2023年3月7日 01:50:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75654173.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定