oom
oom copied to clipboard
VENDOR_NAME decoding problem
Get such key-value pair when reading SERIAL_ID from SFP HG Genuine MXPD-243S.
'VENDOR_NAME': 'HG GENUINE\x00\x00\x00\x00\x00\x00'
To me it seems strange.
i2cdump of this SFP.
root@raspberrypi:~# i2cdump -y 11 0x50
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 03 04 07 00 00 00 02 12 00 01 01 01 0d 00 0a 64 ???...??.????.?d
10: 00 00 00 00 48 47 20 47 45 4e 55 49 4e 45 00 00 ....HG GENUINE..
20: 00 00 00 00 00 00 00 00 4d 58 50 44 2d 32 34 33 ........MXPD-243
30: 53 20 20 20 20 20 20 20 00 00 00 00 05 1e 00 af S ....??.?
40: 00 1a 00 00 48 41 30 39 33 36 30 30 32 30 35 36 .?..HA0936002056
50: 32 20 20 20 30 39 30 39 30 33 20 20 58 f0 01 f2 2 090903 X???
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
90: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
The vendor of that transceiver appears to have put null/zero into the remaining bytes after 'HG GENUINE'. The spec says that the vendor name is 16 bytes long, so OOM reads all 16 bytes in and provides them to the programmer. It looks like some defensive coding might be required to handle the variety of data that some vendors provide.