英文:
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?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论