How to read/write the value from/to the variables of node on CODESYS PLC #1244
Answered
by
schroeder-
nyanko-box
asked this question in
Q&A
-
Hi, there. I want to:
import asyncio
from asyncua import Client
from asyncua.ua.uatypes import Variant,VariantType,DataValue
async def main():
username = "username"
password = "password"
ipaddress = "ipaddress"
port = "port"
url = f"opc.tcp://{username}:{password}@{ipaddress}:{port}"
async with Client(url) as client: # <- maybe this is succeeded.
# This node is defined as a DWORD.
node = await client.get_node("ns=4;s=|var|CODESYS Control for Raspberry Pi MC SL.Application.PLC_PRG.X201")
dwfreq = DataValue(Variant(10, VariantType.UInt32))
await node.write_value(dwfreq)
client.disconnect()
if __name__ == "__main__":
asyncio.run(main()) updating client limits to: TransportLimits(max_recv_buffer=65536, max_send_buffer=65536, max_chunk_count=16, max_message_size=1048576)
object Node can't be used in 'await' expression. Is there any wrong in the script? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Answered by
schroeder-
Mar 14, 2023
Replies: 1 comment 1 reply
-
Remove the await before client.get_node. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nyanko-box
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remove the await before client.get_node.