ottlukas commented on issue #1469: URL: https://github.com/apache/plc4x/issues/1469#issuecomment-2048295750
Yes thank you very much it is working. Besides this error: ``` DEBUG:asyncio:Using selector: EpollSelector Traceback (most recent call last): File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/luk/.vscode/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module> cli.main() File "/home/luk/.vscode/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main run() File "/home/luk/.vscode/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file runpy.run_path(target, run_name="__main__") File "/home/luk/.vscode/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path return _run_module_code(code, init_globals, run_name, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/luk/.vscode/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code _run_code(code, mod_globals, init_globals, File "/home/luk/.vscode/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code exec(code, run_globals) File "/home/luk/Develop/main.py", line 20, in <module> asyncio.run(communicate_with_plc()) File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/luk/Develop/main.py", line 16, in communicate_with_plc response = future.result() ^^^^^^^^^^^^^ AttributeError: 'coroutine' object has no attribute 'result' ``` Needed to change it to: ``` import asyncio from plc4py.PlcDriverManager import PlcDriverManager connection_string = "modbus://127.0.0.1:5020" driver_manager = PlcDriverManager() try: async def communicate_with_plc(): async with driver_manager.connection(connection_string) as connection: with connection.read_request_builder() as builder: builder.add_item("Random Tag", "4x00001[11]") request = builder.build() future = connection.execute(request) response = await future # Access and process data from the response here data_value = response.response_code # Assuming "Random Tag" is a key print("Data:", data_value) except Exception as e: print("Error communicating with PLC:", e) asyncio.run(communicate_with_plc()) ``` Response: ``` INFO:root:Instantiating new PLC Driver Manager with class loader <pluggy._manager.PluginManager object at 0x76dc9e31a090> INFO:root:Registering available drivers... INFO:root:... umas .. OK INFO:root:... modbus .. OK INFO:root:... mock .. OK DEBUG:asyncio:Using selector: EpollSelector DEBUG:root:Sending read request to Modbus Device DEBUG:root:Reading tag ModbusTagHoldingRegister(address=0) from Modbus Device Data: PlcResponseCode.OK ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@plc4x.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org