TWCManager icon indicating copy to clipboard operation
TWCManager copied to clipboard

TWC and EW11 socket options

Open revoneor opened this issue 11 months ago • 2 comments

How to start twcmanager without a usb dongle when one is having a EW11 RS485 to socket

First attempt is to remove devices from the docker compose.yaml (comment out) and hope that twcmanager gets so far as to create /etc/twcmanage/config.json (Could be that one should put this file there manually then and edit)

It did not create this file because it barks that /dev/ttyUSB0 is not found, I tried to have it pass that by listing my /dev/ttyACM0 in the docker-compose.yml but it would still barf on missing /dev/ttyUSB0

Luckily I had one RS485 USB dongle but otherwise I see no way to fake it to get it to work

With that it started and /etc/twcmanage/config.json could be edited to for socket: ip:port and restart.

Is there or should there be a syntax to have a socket line in docker-compose.yml?

revoneor avatar Feb 17 '25 11:02 revoneor

The above is still an issue.

Apart from that exception handling may be failing when the socket seems to not respond or get closed involuntarily.

It works fine and then:

{"log":"06:55:54 ⛽ Manager  20 WARNING: We haven't heard from slave 6561 for over 26 seconds.  Stop sending them heartbeat messages.\n","stream":"stdout","time":"2025-04-01T04:55:54.645362322Z"}
{"log":"Traceback (most recent call last):\n","stream":"stderr","time":"2025-04-01T04:58:50.24652001Z"}
{"log":"  File \"/usr/local/lib/python3.9/dist-packages/serial/urlhandler/protocol_socket.py\", line 167, in read\n","stream":"stderr","time":"2025-04-01T04:58:50.246938897Z"}
{"log":"    buf = self._socket.recv(size - len(read))\n","stream":"stderr","time":"2025-04-01T04:58:50.24699694Z"}
{"log":"ConnectionResetError: [Errno 104] Connection reset by peer\n","stream":"stderr","time":"2025-04-01T04:58:50.247026774Z"}
{"log":"\n","stream":"stderr","time":"2025-04-01T04:58:50.24705315Z"}
{"log":"During handling of the above exception, another exception occurred:\n","stream":"stderr","time":"2025-04-01T04:58:50.247078192Z"}
{"log":"\n","stream":"stderr","time":"2025-04-01T04:58:50.24710586Z"}
{"log":"Traceback (most recent call last):\n","stream":"stderr","time":"2025-04-01T04:58:50.247130944Z"}
{"log":"  File \"/usr/src/TWCManager/lib/TWCManager/Interface/RS485.py\", line 72, in read\n","stream":"stderr","time":"2025-04-01T04:58:50.247156444Z"}
{"log":"    return self.ser.read(len)\n","stream":"stderr","time":"2025-04-01T04:58:50.24718307Z"}
{"log":"  File \"/usr/local/lib/python3.9/dist-packages/serial/urlhandler/protocol_socket.py\", line 178, in read\n","stream":"stderr","time":"2025-04-01T04:58:50.247207904Z"}
{"log":"    raise SerialException('read failed: {}'.format(e))\n","stream":"stderr","time":"2025-04-01T04:58:50.247404701Z"}
{"log":"serial.serialutil.SerialException: read failed: [Errno 104] Connection reset by peer\n","stream":"stderr","time":"2025-04-01T04:58:50.247433744Z"}
{"log":"\n","stream":"stderr","time":"2025-04-01T04:58:50.247459619Z"}
{"log":"During handling of the above exception, another exception occurred:\n","stream":"stderr","time":"2025-04-01T04:58:50.247484745Z"}
{"log":"\n","stream":"stderr","time":"2025-04-01T04:58:50.247511538Z"}
{"log":"Traceback (most recent call last):\n","stream":"stderr","time":"2025-04-01T04:58:50.247535747Z"}
{"log":"  File \"/usr/src/TWCManager/lib/TWCManager/TWCManager.py\", line 817, in \u003cmodule\u003e\n","stream":"stderr","time":"2025-04-01T04:58:50.247561247Z"}
{"log":"    data = master.getInterfaceModule().read(dataLen)\n","stream":"stderr","time":"2025-04-01T04:58:50.247588706Z"}
{"log":"  File \"/usr/src/TWCManager/lib/TWCManager/Interface/RS485.py\", line 73, in read\n","stream":"stderr","time":"2025-04-01T04:58:50.247614457Z"}
{"log":"    except serial.serialutil.SerialException as e:\n","stream":"stderr","time":"2025-04-01T04:58:50.247640666Z"}
{"log":"NameError: name 'serial' is not defined\n","stream":"stderr","time":"2025-04-01T04:58:50.247705876Z"}
{"log":"06:58:50 ⛽ Manager  20 Unhandled Exception:Traceback (most recent call last):\n","stream":"stdout","time":"2025-04-01T04:58:50.249622222Z"}
{"log":"  File \"/usr/local/lib/python3.9/dist-packages/serial/urlhandler/protocol_socket.py\", line 167, in read\n","stream":"stdout","time":"2025-04-01T04:58:50.249804352Z"}
{"log":"    buf = self._socket.recv(size - len(read))\n","stream":"stdout","time":"2025-04-01T04:58:50.249833478Z"}
{"log":"ConnectionResetError: [Errno 104] Connection reset by peer\n","stream":"stdout","time":"2025-04-01T04:58:50.249859854Z"}
{"log":"\n","stream":"stdout","time":"2025-04-01T04:58:50.249884896Z"}
{"log":"During handling of the above exception, another exception occurred:\n","stream":"stdout","time":"2025-04-01T04:58:50.249911188Z"}
{"log":"\n","stream":"stdout","time":"2025-04-01T04:58:50.249936481Z"}
{"log":"Traceback (most recent call last):\n","stream":"stdout","time":"2025-04-01T04:58:50.249961106Z"}
{"log":"  File \"/usr/src/TWCManager/lib/TWCManager/Interface/RS485.py\", line 72, in read\n","stream":"stdout","time":"2025-04-01T04:58:50.249985899Z"}
{"log":"    return self.ser.read(len)\n","stream":"stdout","time":"2025-04-01T04:58:50.25001165Z"}
{"log":"  File \"/usr/local/lib/python3.9/dist-packages/serial/urlhandler/protocol_socket.py\", line 178, in read\n","stream":"stdout","time":"2025-04-01T04:58:50.250036734Z"}
{"log":"    raise SerialException('read failed: {}'.format(e))\n","stream":"stdout","time":"2025-04-01T04:58:50.250063484Z"}
{"log":"serial.serialutil.SerialException: read failed: [Errno 104] Connection reset by peer\n","stream":"stdout","time":"2025-04-01T04:58:50.250088902Z"}
{"log":"\n","stream":"stdout","time":"2025-04-01T04:58:50.250115194Z"}
{"log":"During handling of the above exception, another exception occurred:\n","stream":"stdout","time":"2025-04-01T04:58:50.250139403Z"}
{"log":"\n","stream":"stdout","time":"2025-04-01T04:58:50.250164779Z"}
{"log":"Traceback (most recent call last):\n","stream":"stdout","time":"2025-04-01T04:58:50.250189113Z"}
{"log":"  File \"/usr/src/TWCManager/lib/TWCManager/TWCManager.py\", line 817, in \u003cmodule\u003e\n","stream":"stdout","time":"2025-04-01T04:58:50.25021403Z"}
{"log":"    data = master.getInterfaceModule().read(dataLen)\n","stream":"stdout","time":"2025-04-01T04:58:50.250240614Z"}
{"log":"  File \"/usr/src/TWCManager/lib/TWCManager/Interface/RS485.py\", line 73, in read\n","stream":"stdout","time":"2025-04-01T04:58:50.250265823Z"}
{"log":"    except serial.serialutil.SerialException as e:\n","stream":"stdout","time":"2025-04-01T04:58:50.250291574Z"}

could it be that

else: actualDataLen = dataLen dataLen = 1 data = master.getInterfaceModule().read(dataLen)

in twcmanager.py lacks exception handling in the while true loop?

If I docker stop and start it works again, it seems a lost socket is not reconnected in the loop ?

revoneor avatar Apr 02 '25 16:04 revoneor

Actually after fiddling with the EW11 and making sure that DHCP off and AP off, and docker log files were not overfilling my emmc it is sort of stable. Probably wifi channel disconnecting issues.

Original issue still has some validity, there is no re-connect on port as a socket.

I fixed these errors with bash inside the docker {"log":"/usr/src/TWCManager/lib/TWCManager/Policy/Policy.py:221: SyntaxWarning: "is not" with a literal. Did you mean "!="?\n","stream":"stderr","time":"2025-04-16T17:48:37.129312168Z"} {"log":" if bgt is not "checkGreenEnergy":\n","stream":"stderr","time":"2025-04-16T17:48:37.129878434Z"} {"log":"/usr/src/TWCManager/lib/TWCManager/EMS/TeslaPowerwall2.py:300: SyntaxWarning: "is" with a literal. Did you mean "=="?\n","stream":"stderr","time":"2025-04-16T17:48:38.919061212Z"} {"log":" if r.status_code is 403:\n","stream":"stderr","time":"2025-04-16T17:48:38.919404097Z"}

revoneor avatar Apr 24 '25 12:04 revoneor