xref: /openbmc/libcper/parse_example.py (revision cd9b1c5826323f8035a10513c832cc1a0d351247)
1*cd9b1c58SEd Tanous#!/usr/bin/env python3
2*cd9b1c58SEd Tanous
3*cd9b1c58SEd Tanousimport json
4*cd9b1c58SEd Tanous
5*cd9b1c58SEd Tanousimport cper
6*cd9b1c58SEd Tanous
7*cd9b1c58SEd Tanous
8*cd9b1c58SEd Tanousdef main():
9*cd9b1c58SEd Tanous    cper_raw = (
10*cd9b1c58SEd Tanous        b"\x43\x50\x45\x52\x01\x01\xff\xff\xff\xff\x01\x00\x03"
11*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x28\x01\x00\x00\x00\x00"
12*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
13*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
14*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x78"
15*cd9b1c58SEd Tanous        b"\xe4\x01\xa9\x73\x11\xef\x11\x96\xa8\x5f\xa6\xbe\xf5"
16*cd9b1c58SEd Tanous        b"\xee\xa4\xac\xd5\xa9\x09\x04\x52\x14\x42\x96\xe5\x94"
17*cd9b1c58SEd Tanous        b"\x99\x2e\x75\x2b\xcd\x00\x00\x00\x00\x00\x00\x00\x00"
18*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
19*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x00"
20*cd9b1c58SEd Tanous        b"\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
21*cd9b1c58SEd Tanous        b"\x00\xf2\x44\x52\x6d\x12\x27\xec\x11\xbe\xa7\xcb\x3f"
22*cd9b1c58SEd Tanous        b"\xdb\x95\xc7\x86\x4a\x33\x4f\xcc\x63\xc5\xeb\x11\x8f"
23*cd9b1c58SEd Tanous        b"\x88\x9f\x7a\xc7\x6c\x6f\x0c\x03\x00\x00\x00\x00\x00"
24*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
25*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x44\x52\x41\x4d\x2d\x43\x48\x41"
26*cd9b1c58SEd Tanous        b"\x4e\x4e\x45\x4c\x53\x00\x00\x00\x00\x20\x00\x00\x03"
27*cd9b1c58SEd Tanous        b"\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\xbe"
28*cd9b1c58SEd Tanous        b"\x02\x04\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00"
29*cd9b1c58SEd Tanous        b"\x00\x04\xbe\x02\x04\x00\x10\x00\x00\xff\xff\xff\xff"
30*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
31*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
32*cd9b1c58SEd Tanous        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
33*cd9b1c58SEd Tanous    )
34*cd9b1c58SEd Tanous
35*cd9b1c58SEd Tanous    result = cper.parse(cper_raw)
36*cd9b1c58SEd Tanous    print(json.dumps(result, indent=4))
37*cd9b1c58SEd Tanous
38*cd9b1c58SEd Tanous
39*cd9b1c58SEd Tanousif __name__ == "__main__":
40*cd9b1c58SEd Tanous    main()
41