Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.08 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.08 KB

Sample with code generation

This sample uses zcbor-generated code to decode 3 instances of a data structure. The 3 data structures are created in 3 different ways:

  1. Converted from YAML using the zcbor script (See CMakeLists.txt, pet1.yml, and pet1.h).
  2. Encoded using the zcbor C API.
  3. Encoded using zcbor-generated C code.

The generated code is found in src and include. To regenerate the files, invoke the CMakeLists.txt file with -DREGENERATE_ZCBOR=Y.

pet1.yml files contain the first three representations. Changing pet1.yml will change the printed output for the first pet. To change the output for the second and third, change the code in src/main.c.

To build:

mkdir build
cmake . -Bbuild
make -C build

To run:

build/app

Expected output:

Name: Carrie Cat Birthday: 0x0012003400560078 Species: Cat

Name: Danny the Dog Birthday: 0x0001020304050607 Species: Dog

Name: Gary Giraffe Birthday: 0x010203040a0b0c0d Species: Other