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

'charmap' codec can't decode byte 0x81 in position 7950: character maps to <undefined> #6

Closed
k0201 opened this issue Oct 8, 2021 · 4 comments
Labels
question Further information is requested

Comments

@k0201
Copy link

k0201 commented Oct 8, 2021

Hi! Glad to see that someone did figure out how does protocol v5 works. I tried it on my inverter and I am getting such message:

Chunk no:  0
Sent data:  bytearray(b'\xa5\x17\x00\x10E\x00\x00\xe1,\x1ah\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x00\x00(E\xd4\x00\x15')
Received data:  b'\xa5c\x00\x10\x15\x00\x03\xe1,\x1ah\x02\x01\x0f\xa6/\x00H\x00\x00\x00\x00\x00\x00\x00\x01\x03P\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x128\x02\x81\x11\xf6\x02w\x01+\x01"\x028\xff\xbe\x13\x89\t$\x03-\t0\x03-\t\x1e\x03,\x00\x00\x07\xf9\x00\x00\x03V\x05\x01\x01(\x00*\x001\x19\x01\x12*\x11\xf2\x00<\x00\x00\x00\x01\x00\x00\x04\x9e\x0b\x02\t\x10\x00\x0ce=\xd9\x15'
Traceback (most recent call last):
  File "C:\Users\Lenovo\Documents\Sofar_LSW3-main\InverterData.py", line 156, in <module>
    parameters=json.loads(txtfile.read())
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python39-32\lib\encodings\cp1250.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 7950: character maps to <undefined>

The LWS serial numer is 174654****, FW: LSW3_14_FFFF_1.0.34
Inverter type is SF4ES008 (Sofar 8.8KTL-X) V2.40
I did try it on Windows with python 3.9.0 but can also check on linux later.

If you have any ideas what should I change to make it work I would be glad to hear them :D Thanks!

@k0201
Copy link
Author

k0201 commented Oct 8, 2021

Changing line 155 to
with open("./SOFARMap.xml", encoding="utf8") as txtfile:
Did solve the problem, i suppose changing it in the repo is a good idea.

@MichaluxPL
Copy link
Owner

Glad to hear that :)
Don't know if changing it permanently in the code is a good idea - encoding can be OS dependent ...
Maybe a better solution would be to add config parameter to change it as required :)
I'll thing about that.

@MichaluxPL MichaluxPL added the question Further information is requested label Oct 8, 2021
@k0201
Copy link
Author

k0201 commented Oct 9, 2021

I have added a pull request with CSV file saving support in which i harcoded the encoding

@MichaluxPL
Copy link
Owner

Please fork Your own project for that.
Don't want to add a foreign code to this one.

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

No branches or pull requests

2 participants