pylessard / python-udsoncan

Python implementation of UDS (ISO-14229) standard.
MIT License
575 stars 199 forks source link

ascii DidCodec pass parameters #184

Closed pompushko closed 10 months ago

pompushko commented 10 months ago

Hello

I know, maybe I should make own DidCodec... But! Sometimes, I have 0xFF in binary data, like data which not is filled... Could you, please, add handling decoding errors in ascii codec?

Like errors='replace'

File "/home/username/.local/lib/python3.11/site-packages/udsoncan/common/DidCodec.py", line 70, in decode
    string_ascii = string_bin.decode('ascii')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
pylessard commented 10 months ago

Sorry, 0xFF is not an ASCII character, it is normal to raise an error. If you want to tolerate it, you should make your own codec.