node-opcua / opcua-commander

a opcua client with blessed (ncurses)
MIT License
211 stars 46 forks source link

Issue in writing a OPC-Tag/Variable - Invalid variant Boolean value:1 #36

Closed georges-schutz closed 2 years ago

georges-schutz commented 2 years ago

Thank you for this very rapid reaction. I pulled the latest code base and it does now work out of the box for int and float variables (in my python opcua server environment). But there is still an issue with writing Boolean type variables, I tried typing several entrie-variants as I sow in your commit that several inputs should be handled.

  1. typed 1 in the write popup, only the numeric character.
    $ sudo docker run --network host -it commander -v -e opc.tcp://localhost:4080
    Error: Invalid variant arrayType: Scalar  dataType: Boolean value:1 (javascript type = string )
    at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:472:19)
    at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
    at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)
  2. typed true in the write popup, the 4 characters.
    $ sudo docker run --network host -it commander -v -e opc.tcp://localhost:4080
    Error: Invalid variant arrayType: Scalar  dataType: Boolean value:true (javascript type = string )
    at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:472:19)
    at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
    at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)
  3. typed "1" in the write popup, the numeric character embedded in quotes, as I was not sure how this entry would be needed.
    $ sudo docker run --network host -it commander -v -e opc.tcp://localhost:4080
    PKI Folder =  /root/.config/opcua-commander-nodejs/pki
    Error: Invalid variant arrayType: Scalar  dataType: Boolean value:"1" (javascript type = string )
    at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:472:19)
    at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
    at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)
  4. typed "true" in the write popup, the 4 characters in quotes.
    $ sudo docker run --network host -it commander -v -e opc.tcp://localhost:4080
    Error: Invalid variant arrayType: Scalar  dataType: Boolean value:"true" (javascript type = string )
    at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:472:19)
    at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
    at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)

    If I connect the OPCUA server with UA-Expert the Boolean variable is correctly identified and it is possible to tick/untick the box to change the value true/false

Originally posted by @georges-schutz in https://github.com/node-opcua/opcua-commander/issues/35#issuecomment-1100681838

georges-schutz commented 2 years ago

By the way I also tested scalar string type variables and they also work fine. I do not have a setup with arrays so I could not test that so far.

georges-schutz commented 2 years ago

Hi again I have now also tested an array variable and I get an exception while attempting to write.

Error: Matrix Variant : missing dimensions
    at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:449:23)
    at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
    at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)

It does show me the list of items in the array fine in the write-popup but when submitting the exception occurs

erossignon commented 2 years ago

Please contact support@sterfive.com , there must be inconsistencies in your OPCUA Server variables,

georges-schutz commented 2 years ago

Hello, my OPCUA server that I use for local testing is a python based FreeOPCUA server [1]. I use the corresponding GUI [2] but also the more generic UAExpert [3] for testing compatibilities. I have also access to several other operational OPCUA servers from some clients [divers products] but there I am not flexible to add variables and I also do not want to risk any thing on this systems.

I will check to update to the latest version of the FreeOPCUA server in order to ensure latest compatibilities and potential opcua protocol fixes but I doubt that the Boolean issue comes from there. It is possible that the array test where "Error: Matrix Variant : missing dimensions" could come from this kind of incompatibilities.

I will keep you informed Georges

[1] https://github.com/FreeOpcUa/python-opcua [2] https://github.com/FreeOpcUa/opcua-client-gui [3] https://www.unified-automation.com/products/development-tools/uaexpert.html