Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP Modbus example does not work? #87

Closed
hansij66 opened this issue Feb 5, 2023 · 4 comments
Closed

TCP Modbus example does not work? #87

hansij66 opened this issue Feb 5, 2023 · 4 comments

Comments

@hansij66
Copy link

hansij66 commented Feb 5, 2023

Windows10
Python 3.9
PyCharm

I just got a SMOS40/S2125 installed. I was able to integrate with Home Assistant and get some readings (hence, TCP MODBUS is working).

If I use the README.md TCP Modbus example, I do get errors...and in this example a bit clueless what to change. I literately took README.md, changed to Model.SMOS40 and try to read current-outdoor-temperature-bt1-30002.

I do get the following errors in PyCharm/Windows (I reduced paths a bit to make readable). Any hints appreciated! :) Thanks

DEBUG:asyncio:Using proactor: IocpProactor
DEBUG:nibe.nibe.connection.modbus:Sending read request
DEBUG:sockio.TCP(192.168.1.16:502):open connection (#1)
Traceback (most recent call last):
  File "nibe-s2125\test.py", line 31, in <module>
    loop.run_until_complete(main())
  File "Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "nibe-s2125\test.py", line 23, in main
    await connection.read_coil(coil)
  File "Python39\lib\site-packages\nibe\connection\modbus.py", line 86, in read_coil
    result = await self._client.read_input_registers(
  File "Python39\lib\site-packages\async_modbus\core.py", line 194, in read_input_registers
    return await self._send_message(request)
  File "Python39\lib\site-packages\async_modbus\core.py", line 142, in _send_message
    return await self.protocol._async_send_message(
  File "Python39\lib\site-packages\async_modbus\core.py", line 39, in send_message_tcp
    await writer.drain()
  File "Python39\lib\site-packages\async_modbus\core.py", line 113, in drain
    await self._write_coro
  File "Python39\lib\site-packages\sockio\aio.py", line 31, in wrapper
    await self.open()
  File "Python39\lib\site-packages\sockio\aio.py", line 287, in open
    self.reader, self.writer = await coro
  File "Python39\lib\site-packages\sockio\aio.py", line 158, in open_connection
    configure_socket(sock, no_delay=no_delay, tos=tos, keep_alive=keep_alive)
  File "Python39\lib\site-packages\sockio\aio.py", line 117, in configure_socket
    sock.setsockopt(socket.SOL_IP, socket.IP_TOS, tos)
  File "Python39\lib\asyncio\trsock.py", line 82, in setsockopt
    self._sock.setsockopt(*args, **kwargs)
OSError: [WinError 10022] An invalid argument was supplied
@elupus
Copy link
Collaborator

elupus commented Feb 5, 2023

I dont think it work on windows. Its not been a target platform. It does seem to be an issue in the sockio library.

@elupus
Copy link
Collaborator

elupus commented Feb 5, 2023

Some other that mention issues with that lib on wondows: tiagocoutinho/sockio#5

You can test in wsl2 on windows instead.

@hansij66
Copy link
Author

hansij66 commented Feb 6, 2023 via email

@hansij66
Copy link
Author

Confirmed that it does work as expected on Linux; It is an issue with (PyCharm on) WIndows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants