pythonbinarydata-conversionedid

How to convert a string into binary data (EDID) in python


I currently writing a EDID Script to be able to choose custom resolutions in my Fedora25

I found this assembly script to generate the different solutions. I was able to use this as a "template" and my python script works fine generating the CEA Extension Blobs. Now i want to merge the "Head" and my CEA Blobs with the help of the Wikipedia EDID Byte Order Site.

But in the GitHub Skript this (end1-start1) confuses me:

Descriptor2:
start1:     .ascii  "Linux #0"
end1:       .byte   0x0a    /* End marker */
            .fill   12-(end1-start1), 1, 0x20 /* Padded spaces */

How can i do "Linux #0" - 10? (0x0a = 10) When i converte "Linux #0" i get 76 105 110 117 120 32 35 48 what doesnt make sense with the 18 Byte for the Descriptor?


Solution

  • In assembler, the tokens at the beginning of lines refer to addresses. start1 is the address where the string "Linux #0" starts, end1 is the address where the byte 0x0a starts (or is located because it is a single byte). The term (end1-start1) refers to the difference of the addresses. Since the assembler places the things right after each other into the memory, this is the length of the string "Linux #0", i. e. 8.

    The term 12 - (end1-start1) then is the number of padding bytes needed to fill up the thing to 12 bytes. These are then placed behind the .byte 0x0a (.filled with spaces (0x20)).