Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
0962e65f
Commit
0962e65f
authored
Feb 19, 2023
by
Alexander Schrode
Committed by
oroulet
Feb 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow non unicode bytestring nodeid
parent
b380a566
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
asyncua/ua/uatypes.py
asyncua/ua/uatypes.py
+5
-2
tests/test_common.py
tests/test_common.py
+4
-2
tests/test_unit.py
tests/test_unit.py
+8
-0
No files found.
asyncua/ua/uatypes.py
View file @
0962e65f
...
...
@@ -520,7 +520,10 @@ class NodeId:
identifier
=
uuid
.
UUID
(
f"urn:uuid:
{
v
}
"
)
elif
k
==
"b"
:
ntype
=
NodeIdType
.
ByteString
identifier
=
bytes
(
v
,
'utf-8'
)
if
v
[
0
:
2
]
==
'0x'
:
identifier
=
bytes
.
fromhex
(
v
[
2
:])
else
:
identifier
=
v
.
encode
()
elif
k
==
"srv"
:
srv
=
int
(
v
)
elif
k
==
"nsu"
:
...
...
@@ -549,7 +552,7 @@ class NodeId:
ntype
=
"g"
elif
self
.
NodeIdType
==
NodeIdType
.
ByteString
:
ntype
=
"b"
identifier
=
identifier
.
decode
()
identifier
=
'0x'
+
identifier
.
hex
()
string
.
append
(
f"
{
ntype
}
=
{
identifier
}
"
)
return
";"
.
join
(
string
)
...
...
tests/test_common.py
View file @
0962e65f
...
...
@@ -149,8 +149,10 @@ async def test_delete_nodes(opc):
async
def
test_node_bytestring
(
opc
):
obj
=
opc
.
opc
.
nodes
.
objects
var
=
await
obj
.
add_variable
(
ua
.
ByteStringNodeId
(
b"VarByteString"
,
2
),
ua
.
QualifiedName
(
"toto"
,
2
),
ua
.
UInt16
(
9
))
node
=
opc
.
opc
.
get_node
(
"ns=2;b=VarByteString"
)
var
=
await
obj
.
add_variable
(
ua
.
ByteStringNodeId
(
b'VarByteString'
,
2
),
ua
.
QualifiedName
(
"toto"
,
2
),
ua
.
UInt16
(
9
))
node
=
opc
.
opc
.
get_node
(
f"ns=2;b=VarByteString"
)
assert
node
==
var
node
=
opc
.
opc
.
get_node
(
f"ns=2;b=0x
{
b'VarByteString'
.
hex
()
}
"
)
assert
node
==
var
...
...
tests/test_unit.py
View file @
0962e65f
...
...
@@ -390,6 +390,14 @@ def test_nodeid_bytestring():
s2
=
n2
.
to_string
()
assert
n
==
n2
assert
s
==
s2
n
=
ua
.
ByteStringNodeId
(
Identifier
=
b'
\
x01
\
x00
\
x05
\
x55
'
)
s
=
n
.
to_string
()
n2
=
ua
.
NodeId
.
from_string
(
s
)
s2
=
n2
.
to_string
()
assert
n
==
n2
assert
s
==
s2
n
=
ua
.
NodeId
.
from_string
(
'b=0xaabbccdd'
)
assert
n
.
Identifier
==
b'
\
xaa
\
xbb
\
xcc
\
xdd
'
def
test__nodeid
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment