Skip to content

Opc servers like Ignition allow whitespaces at the end of tag names #1566

@alejandroalfonsoyero

Description

@alejandroalfonsoyero

This is a BUG REPORT for issues in the existing code.

If you have general questions, code handling problems or ideas, please use the:

Discussionsboard: https://github.com/FreeOpcUa/python-opcua/discussions
or

Gitter-Channel: https://gitter.im/FreeOpcUa/python-opcua


Bug Description

When creating a Node object, if the OPC tag name ends with whitespaces, example ns=2;s=[default]/Folder/tag4

To Reproduce

  • In the Ignition scada create a tag and add whitespaces at the end (you will see it is possible). (See screenshot)

  • Try to write a value to this tag using upcua python library.

Expected behavior

The new tag value should be visible at the Ignition scada

Screenshots

Image

How to fix it

The solution is quite simple:
This line converts an id like ns=2;s=[default]/Folder/tag4 into ns=2;s=[default]/Folder/tag4.
So the solution could be replace:

# v = v.strip()  replace this line using a lstrip since Ignition does not allow whitespaces at the start but it allows them at the end.
v = v.lstrip()

It is important to note that projects like open62541 works fine with this cases.

Version

Python-Version: 3.11

python-opcua Version (master branch, 0.98.13):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions