irekzielinski / Pylontech-Battery-Monitoring

Adding WiFi monitoring to US2000B and US2000C batteries.
133 stars 58 forks source link

wakeUpConsole() doesn't make sense on the serial console port #27

Open th-s-op opened 11 months ago

th-s-op commented 11 months ago

I have to state that the need to switch baud rates and send the "~20014682C0048520FCC3\r" string is a mistake that results from not understanding the different Pylontech ports and protocols. While this is the correct method to switch the RS485 (!) port from the semi-binary packet/frame mode to console mode, it is not necessary to be done when the RS232 (!) Console port is used.

The code WOULD make sense if the RS485 port with an RS485 transceiver is used. Using the code on the Console port doesn't do any harm but sends unnecessary garbage to the console shell.

See the RS485 protocol documentation (https://github.com/Frankkkkk/python-pylontech/blob/master/RS485-protocol-pylon-low-voltage-V3.3-20180821.pdf). The above string can be found there: "~" is the "Start of Information" byte, followed by protocol version, address, etc. up to a checksum and the "End Code" (\r).

Summary: port labeled "Console": RS232 interface, speaks "console shell" port labeled "RS485": RS485 interface, speaks frame based "Pylontech Low Voltage Protocol" but can be switched to "console shell" port labeled "CAN": CAN bus interface, speaks CAN protocol

th-s-op commented 11 months ago

Also, even when using the RS485 port, it would be good to check if it's already in "Console Mode" or still in packet-frame-mode. If you switch to "Console Mode" using the "~20014682C0048520FCC3\r" packet, it's good practice to also exit "Console Mode" using the "cmdquit" command (which is ONLY available in the console mode on the RS485 port and not in any of the admin/user modes in the RS232 console). There is software which expects RS485 on the RS485 port and the "Console Mode" should be a (temporary) exception on this port. Even Pylontech's "Batteryview.exe" sends a "cmdquit" when you exit the program.