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
2fba7809
Commit
2fba7809
authored
Jan 28, 2018
by
Christian Bergmiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] async modules wip
parent
271034d1
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1175 additions
and
0 deletions
+1175
-0
opcua/client/async_client.py
opcua/client/async_client.py
+557
-0
opcua/client/async_ua_client.py
opcua/client/async_ua_client.py
+575
-0
opcua/common/async_connection.py
opcua/common/async_connection.py
+29
-0
opcua/ua/async_ua_binary.py
opcua/ua/async_ua_binary.py
+14
-0
No files found.
opcua/client/async_client.py
0 → 100644
View file @
2fba7809
This diff is collapsed.
Click to expand it.
opcua/client/async_ua_client.py
0 → 100644
View file @
2fba7809
This diff is collapsed.
Click to expand it.
opcua/common/async_connection.py
0 → 100644
View file @
2fba7809
import
asyncio
import
logging
from
opcua.common.connection
import
SecureConnection
from
opcua.ua.async_ua_binary
import
header_from_binary
from
opcua
import
ua
logger
=
logging
.
getLogger
(
'opcua.uaprotocol'
)
class
AsyncSecureConnection
(
SecureConnection
):
"""
Async version of SecureConnection
"""
async
def
receive_from_socket
(
self
,
protocol
):
"""
Convert binary stream to OPC UA TCP message (see OPC UA
specs Part 6, 7.1: Hello, Acknowledge or ErrorMessage), or a Message
object, or None (if intermediate chunk is received)
"""
logger
.
debug
(
"Waiting for header"
)
header
=
await
header_from_binary
(
protocol
)
logger
.
info
(
"received header: %s"
,
header
)
body
=
await
protocol
.
read
(
header
.
body_size
)
if
len
(
body
)
!=
header
.
body_size
:
# ToDo: should never happen since UASocketProtocol.read() waits until `size` bytes are received. Remove?
raise
ua
.
UaError
(
"{0} bytes expected, {1} available"
.
format
(
header
.
body_size
,
len
(
body
)))
return
self
.
receive_from_header_and_body
(
header
,
ua
.
utils
.
Buffer
(
body
))
opcua/ua/async_ua_binary.py
0 → 100644
View file @
2fba7809
import
struct
from
opcua
import
ua
from
opcua.ua.ua_binary
import
Primitives
async
def
header_from_binary
(
data
):
hdr
=
ua
.
Header
()
hdr
.
MessageType
,
hdr
.
ChunkType
,
hdr
.
packet_size
=
struct
.
unpack
(
"<3scI"
,
await
data
.
read
(
8
))
hdr
.
body_size
=
hdr
.
packet_size
-
8
if
hdr
.
MessageType
in
(
ua
.
MessageType
.
SecureOpen
,
ua
.
MessageType
.
SecureClose
,
ua
.
MessageType
.
SecureMessage
):
hdr
.
body_size
-=
4
hdr
.
ChannelId
=
Primitives
.
UInt32
.
unpack
(
ua
.
utils
.
Buffer
(
await
data
.
read
(
4
)))
return
hdr
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