README.md
1
2# Sample with code generation
3
4This sample uses zcbor-generated code to decode 3 instances of a data
5structure. The 3 data structures are created in 3 different ways:
6
71. Converted from YAML using the zcbor script (See [CMakeLists.txt](CMakeLists.txt), [pet1.yml](pet1.yml), and pet1.h).
82. Encoded using the zcbor C API.
93. Encoded using zcbor-generated C code.
10
11The generated code is found in [src](src) and [include](include).
12To regenerate the files, invoke the [CMakeLists.txt](CMakeLists.txt) file with `-DREGENERATE_ZCBOR=Y`.
13
14[pet1.yml](pet1.yml) files contain the first three representations. Changing [pet1.yml](pet1.yml) will change the printed output for the first pet.
15To change the output for the second and third, change the code in [src/main.c](src/main.c).
16
17### To build:
18
19```
20mkdir build
21cmake . -Bbuild
22make -C build
23```
24
25### To run:
26
27```
28build/app
29```
30
31### Expected output:
32
33> Name: Carrie Cat
34> Birthday: 0x0012003400560078
35> Species: Cat
36>
37> Name: Danny the Dog
38> Birthday: 0x0001020304050607
39> Species: Dog
40>
41> Name: Gary Giraffe
42> Birthday: 0x010203040a0b0c0d
43> Species: Other
44