Skip to content

Instantly share code, notes, and snippets.

@player999
Last active June 22, 2023 18:47
Show Gist options
  • Save player999/30e5b65510ec9865ae12e0522ae49e3f to your computer and use it in GitHub Desktop.
Save player999/30e5b65510ec9865ae12e0522ae49e3f to your computer and use it in GitHub Desktop.
Preparing testing data for BEJ decoder

Install dependencies

python -m pip install lxml
python -m pip install tabulate

Get dictionaries from DMTF website

Use URL to get dictionaries. Use URL to get dictionary tools.

View one of the dictionaries

python rde_schema_dictionary_gen.py view -f ..\DSP8010_2023_1\dictionaries\Memory_v1.bin

Use dictionary data to compose your JSON

{
	"CapacityMiB": 65536,
	"DataWidthBits": 64,
	"AllowedSpeedsMHz": [2400, 3200],
	"ErrorCorrection": "NoECC",
	"MemoryLocation": {
		"Channel": 0,
		"Slot": 0
	}
}

Encode JSON to BEJ

python pldm_bej_encoder_decoder.py encode -j ..\example.json -s ..\DSP8010_2023_1\dictionaries\Memory_v1.bin -a ..\DSP8010_2023_1\dictionaries\annotation.bin -o ..\example.bin
0X000000: 00 F0 F0 F1 00 00 00 01 00 00 01 3F 01 05 01 08 ...........?....
0X000010: 30 01 03 00 00 01 01 0A 30 01 01 40 01 02 10 01 0.......0..@....
0X000020: 10 01 02 01 00 30 01 02 60 09 01 02 30 01 02 80 .....0..`...0...
0X000030: 0C 01 12 40 01 02 01 02 01 26 00 01 0E 01 02 01 ...@.....&......
0X000040: 00 30 01 01 00 01 04 30 01 01 00
JSON size: 137
Total encode size: 75
Compression ratio(%): 45.25547445255474

Now example.bin can be used as your test data

Decode BEJ back to JSON (in order to ensure that everything encoded fine)

python pldm_bej_encoder_decoder.py decode -s ..\DSP8010_2023_1\dictionaries\Memory_v1.bin -a ..\DSP8010_2023_1\dictionaries\annotation.bin -b ..\example.bin
{
   "CapacityMiB": 65536,
   "DataWidthBits": 64,
   "AllowedSpeedsMHz": [
      2400,
      3200
   ],
   "ErrorCorrection": "NoECC",
   "MemoryLocation": {
      "Channel": 0,
      "Slot": 0
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment