MichaluxPL / Sofar_LSW3

Get MODBUS data from Sofar (K-TLX) inverter through LSW-3 or LSE module
GNU General Public License v3.0
98 stars 47 forks source link

Błąd po uruchomieniu #2

Closed pablolite closed 2 years ago

pablolite commented 2 years ago

Po uruchomieniu skryptu na linux'ie otrzymałem komunikat:

admin@nas:~/DeyeInverter-main$ **sudo python InverterData.py**
Traceback (most recent call last):
  File "InverterData.py", line 18, in <module>
    os.chdir(os.path.dirname(sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory: ''

Zakomentowałem 18 linię i uruchomiłem ponownie i otrzymałem błąd:

Traceback (most recent call last):
  File "InverterData.py", line 108, in <module>
    response=twosComplement_hex(str(''.join(hex(ord(chr(x)))[2:].zfill(2) for x in bytearray(data))+'  '+re.sub('[^\x20-\x7f]', '', ''))[p1:p2])
  File "InverterData.py", line 13, in twosComplement_hex
    val = int(hexval, bits)
ValueError: invalid literal for int() with base 16: ''

Wstawiłem w kodzie print ze zmiennej "data" i dostaję wynik:

0
DATA:
b"\xa5\x10\x00\x10\x15\x00<\xa0\x1fjf\x02\x01@f\x98\x00/\x0e\x00\x00'\x13\xbc`\x05\x00\xd9\x15"
0x003B-Running Status:21
Traceback (most recent call last):
  File "InverterData.py", line 110, in <module>
    response=twosComplement_hex(str(''.join(hex(ord(chr(x)))[2:].zfill(2) for x in bytearray(data))+'  '+re.sub('[^\x20-\x7f]', '', ''))[p1:p2])
  File "InverterData.py", line 13, in twosComplement_hex
    val = int(hexval, bits)
ValueError: invalid literal for int() with base 16: ''

Mój konfig:

[DeyeInverter]
inverter_ip=10.0.0.55
inverter_port=8899
inverter_sn=1718230944
mqtt=0
mqtt_server=10.0.0.111
mqtt_port=1883
mqtt_topic=sofar
mqtt_username=home
mqtt_passwd=xxx

Co może być nie tak?

Pozdrawiam, Paweł

pablolite commented 2 years ago

Pomyłka, testowałem kod nie z tego GIT'a :) Wszystko działa jak należy.