The wikipedia EDID article tells us that bytes 8-9 are the Manufacturer ID and bytes 10-11 are the product code.
8–9 Manufacturer ID.
These IDs are assigned by Microsoft, they are PNP IDs "00001=A”; “00010=B”; ... “11010=Z”. Bit 7 (at address 08h) is 0, the first character (letter) is located at bits 6 → 2 (at address 08h), the second character (letter) is located at bits 1 & 0 (at address 08h) and bits 7 → 5 (at address 09h), and the third character (letter) is located at bits 4 → 0 (at address 09h).
Bit 15 (Reserved, always 0)
Bits 14–10 First letter of manufacturer ID (byte 8, bits 6–2)
Bits 9–5 Second letter of manufacturer ID (byte 8, bit 1 through byte 9 bit 5)
Bits 4–0 Third letter of manufacturer ID (byte 9 bits 4–0)
10–11 Manufacturer product code. 16-bit number, little-endian.
So let's make a little LibreCalc spreadsheet and a function to get the bits:
function bits(value, lowbit, highbit as double)as double retval = 0 for i = lowbit to highbit retval = retval + (value and (2^i)) next i retval = retval / (2^lowbit) bits = retval end function
then a table from a1:31 with the numbers 1 to 31
a table from b1:31 with the formula =CHAR(A1+UNICODE("A")-1) in b1 and fill copy it to b31. I'm so used to using the ASC function but now I guess it has to be UNICODE.
and to see the bit patterns, why not fill c1:c31 with =DEC2BIN(A1,5) to pad it to 5 binary digits.
then to translate a 5 bit letter code to a letter, we go:
=LOOKUP(lettercodenumber,A1:A31,B1:B31)
and to get the bits for a specific range let's use the bits routine:
=bits(number,14,10) for bits 10 to 14
Let's use cell f4 for our
put a =HEX2DEC(f4) into g4
and the following into cell h4
=LOOKUP(BITS(G4,10,14),$A$1:$A$31,$B$1:$B$31)&
LOOKUP(BITS(G4,5,9),$A$1:$A$31,$B$1:$B$31)&
LOOKUP(BITS(G4,0,4),$A$1:$A$31,$B$1:$B$31)
And now you can convert that hex code to a manufacturer ID.
The product code is easy, just reverse the little endian:
So if your hexdump looks like this:
00000000 00 ff ff ff ff ff ff 00 10 ac 15 a0 35 34 38 36 |................|
10ac = DEL
15a0 = A015
for the PNP code of DELA015
And if you want to get rid of the lookup table, you can just compute it with another function:
function pnpletter(code) as string pnpletter=chr$(code+ASC("A")-1) end function
which makes our cell h4 formula
=PNPLETTER(BITS(G4,10,14))&PNPLETTER(BITS(G4,5,9))&PNPLETTER(BITS(G4,0,4))
It would have been neat to have it "human readable" without bit fiddling but I guess they wanted to save a byte here and there.
No comments:
Post a Comment