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

Fixed utf-8 decoding error #49

Merged
merged 1 commit into from
Jul 8, 2023

Conversation

denilsonsa
Copy link
Contributor

Fixed this error:

ERROR: 'utf-8' codec can't decode byte 0x80 in position 2818: invalid start byte

It happens because indeed there is a 0x80 byte in the middle of Extra descriptor at the EDID information. Look:

image

   EDID hex dump:
              +0          +4          +8          +c            0   4   8   c   
      +0000   00 ff ff ff ff ff ff 00 06 af 2d 56 00 00 00 00   ..........-V....
      +0010   00 1c 01 04 a5 1d 11 78 02 ee 95 a3 54 4c 99 26   .......x....TL.&
      +0020   0f 50 54 00 00 00 01 01 01 01 01 01 01 01 01 01   .PT.............
      +0030   01 01 01 01 01 01 b4 37 80 a0 70 38 3e 40 3a 2a   .......7..p8>@:*
      +0040   35 00 25 a5 10 00 00 1a b4 37 80 a0 70 38 5c 41   5.%......7..p8\A
      +0050   3a 2a 35 00 25 a5 10 00 00 1a 00 00 00 fe 00 38   :*5.%..........8
      +0060   34 58 46 37 80 42 31 33 33 48 41 4e 00 00 00 00   4XF7.B133HAN....
      +0070   00 02 41 03 9e 00 11 00 00 0a 01 0a 20 20 00 c4   ..A.........  ..

This, by the way, is reported as Invalid display, because This is an eDP laptop display. Laptop displays do not support DDC/CI.


Bonus: Tracking down this error was annoying because the try…except block at line 6531 swallows the stacktrace. I managed to view the stacktrace by adding a plain raise line in the except block, effectively re-throwing the error. Maybe the stacktrace should be printed if --debug is passed. I'll leave the implementation as an exercise to someone else. ;)

Fixed this error:

ERROR: 'utf-8' codec can't decode byte 0x80 in position 2818: invalid start byte

It happens because indeed there is a 0x80 byte in the middle of `Extra descriptor` at the EDID information.
@digitaltrails digitaltrails merged commit 6c5065e into digitaltrails:master Jul 8, 2023
@digitaltrails
Copy link
Owner

Thanks fo the patch. I shall raise an issue about adding more debugging.

I would like to support laptops by providing a wrapper around ddcutil that would support a subset of commands - see #44. But I don't own any laptops, maybe one day (probably not though).

digitaltrails added a commit that referenced this pull request Jul 8, 2023
@denilsonsa
Copy link
Contributor Author

There may be other uses of .decode() that can throw the same error, but I haven't investigated any further.

@digitaltrails
Copy link
Owner

There may be other uses of .decode() that can throw the same error, but I haven't investigated any further.

I will be looking at any other decode() calls.

digitaltrails added a commit that referenced this pull request Jul 8, 2023
@digitaltrails digitaltrails self-assigned this Jul 8, 2023
@digitaltrails digitaltrails added bug Something isn't working enhancement New feature or request labels Jul 8, 2023
@digitaltrails
Copy link
Owner

I changed errors='replace' to errors='surrogateescape' in an attempt to retain as much info as possible. I've put this in place in almost every instance where decode is used.

In many cases decode is issued when creating diagnostics, leaving an escaped representation of the offending character should be safe. I'm sure about what will happen if a decoded surrogateescape value is used functionally, but I don't think that is likely to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants