diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index e1a115f5..b2e582df 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -12,7 +12,7 @@ jobs: strategy: matrix: platform: ["native_posix", "native_posix_64", "mps2_an521"] - asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"] + asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON -e no_verbose"] name: Merge tests 1 (${{ matrix.platform }}${{ matrix.asserts != '' && ' with asserts' || '' }}) steps: - name: Checkout the code diff --git a/README.md b/README.md index 00c86ee4..43da8c5f 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,27 @@ ZCBOR_STATE_D(decode_state, n, payload, payload_len, elem_count, n_flags); ZCBOR_STATE_E(encode_state, n, payload, payload_len, 0); ``` +Diagnostic printing of CBOR data +-------------------------------- + +The C library contains a function (`zcbor_print_cbor()`) for printing CBOR data to terminal in a human readable way. +The functionality must be enabled via the `ZCBOR_PRINT_CBOR` configuration option for the function to be available. +By also defining `ZCBOR_PRINT_CBOR_PRETTY`, the output is made more readable via more thorough interpretation, and colorized using ANSI escape codes, see the figure below for the difference. +The color choices can be configured via the `ZCBOR_PRINT_CBOR_COLOR_*` (`HEADER`, `VALUE`, `DESC`, `TAG`), the defaults are red, blue, green, and yellow respectively. +If the `ZCBOR_PRINT_CBOR_PRETTY` functionality is wanted without the color, set all the `ZCBOR_*_COLOR` definitions to empty strings. +If changing the color, the defines should be full ANSI escape codes: + +```c +/* Make the header green */ +#define ZCBOR_PRINT_CBOR_COLOR_HEADER "\x1B[32m" +``` + +![`zcbor_print_cbor() output`](images/zcbor_print_cbor_ex1.png) +Figure: Example output from `zcbor_print_cbor()`, without and with `ZCBOR_PRINT_CBOR_PRETTY`. + +By default, `zcbor_print_cbor()` uses Zephyr's `printk` to print. +To change this, define `ZCBOR_PRINT_FUNC` to your preferred function (must follow the `printf` signature). + Configuration ------------- @@ -98,6 +119,9 @@ Name | Description `ZCBOR_STOP_ON_ERROR` | Enable the `stop_on_error` functionality. This makes all functions abort their execution if called when an error has already happened. `ZCBOR_BIG_ENDIAN` | All decoded values are returned as big-endian. The default is little-endian. `ZCBOR_MAP_SMART_SEARCH` | Applies to decoding of unordered maps. When enabled, a flag is kept for each element in an array, ensuring it is not processed twice. If disabled, a count is kept for map as a whole. Enabling increases code size and memory usage, and requires the state variable to possess the memory necessary for the flags. +`ZCBOR_PRINT_CBOR` | Enable the `zcbor_print_cbor()` function for printing CBOR. +`ZCBOR_PRINT_CBOR_PRETTY` | Enable color printing and better readability for `zcbor_print_cbor()`. `ZCBOR_PRINT_CBOR` must also be defined. This leads to bigger code size. +`ZCBOR_PRINT_FUNC` | Function used for all printing (`zcbor_log*()`, `zcbor_trace()`, `zcbor_print*()`). When undefined, the default is `printf` Python script and module diff --git a/images/zcbor_print_cbor_ex1.png b/images/zcbor_print_cbor_ex1.png new file mode 100644 index 00000000..a807434e Binary files /dev/null and b/images/zcbor_print_cbor_ex1.png differ diff --git a/include/zcbor_common.h b/include/zcbor_common.h index 87988971..48cd7f4f 100644 --- a/include/zcbor_common.h +++ b/include/zcbor_common.h @@ -48,6 +48,10 @@ struct zcbor_string_fragment { #define MAX(a, b) (((a) < (b)) ? (b) : (a)) #endif +#ifndef NAN +#define NAN (0.0/0.0) +#endif + #ifndef ZCBOR_ARRAY_SIZE #define ZCBOR_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #endif diff --git a/include/zcbor_decode.h b/include/zcbor_decode.h index 61a6f176..fa39e31a 100644 --- a/include/zcbor_decode.h +++ b/include/zcbor_decode.h @@ -440,6 +440,17 @@ void zcbor_bstr_next_fragment(zcbor_state_t *state, /** Can be used on any fragment to tell if it is the final fragment of the string. */ bool zcbor_is_last_fragment(const struct zcbor_string_fragment *fragment); +/** Diagnostic printing of CBOR data + * + * Traverses and prints one CBOR element, analogous to @ref zcbor_any_skip. + * Must be enabled via ZCBOR_PRINT_CBOR. Can be modified via + * ZCBOR_PRINT_CBOR_PRETTY, ZCBOR_PRINT_CBOR_COLOR_HEADER, ZCBOR_PRINT_CBOR_COLOR_VALUE, + * ZCBOR_PRINT_CBOR_COLOR_DESC, ZCBOR_PRINT_CBOR_COLOR_TAG, and ZCBOR_PRINT_FUNC. + * + * See the README for more information. +*/ +bool zcbor_print_cbor(zcbor_state_t *state); + #ifdef __cplusplus } #endif diff --git a/include/zcbor_print.h b/include/zcbor_print.h index ee7db693..2ba96462 100644 --- a/include/zcbor_print.h +++ b/include/zcbor_print.h @@ -147,6 +147,247 @@ static void zcbor_print_error(int error) zcbor_do_print("%s\r\n", zcbor_error_str(error)); } +#ifdef ZCBOR_PRINT_CBOR +static bool indent_printed = false; + +__attribute__((used)) +static void zcbor_print_indent(size_t indent_len) +{ + if (!indent_printed) { + for (int i = 0; i < indent_len; i++) { + zcbor_do_print("| "); + } + indent_printed = true; + } +} + +__attribute__((used)) +static void zcbor_print_newline(void) +{ + zcbor_do_print("\r\n"); + indent_printed = false; +} + +#define BYTES_PER_LINE 16 + +__attribute__((used)) +static void zcbor_print_str(const uint8_t *str, size_t len, size_t indent_len) +{ + for (size_t i = 0; i < len; i++) { + if (!(i % BYTES_PER_LINE)) { + if (i > 0) {zcbor_print_newline();} + zcbor_print_indent(indent_len); + zcbor_do_print("0x"); + } + zcbor_do_print("%02x ", str[i]); + } +} + +__attribute__((used)) +static void zcbor_print_bstr(uint8_t const *payload, size_t len, size_t indent_len) +{ + zcbor_print_str(payload, len, indent_len); + zcbor_print_newline(); +} + +static void zcbor_print_tstr(uint8_t const *payload, size_t len, size_t indent_len); + +__attribute__((used)) +static void zcbor_print_btstr(uint8_t const *payload, size_t len, bool is_bstr, size_t indent_len) +{ + if (is_bstr) { + zcbor_print_bstr(payload, len, indent_len); + } else { + zcbor_print_tstr(payload, len, indent_len); + } +} + + +#ifdef ZCBOR_PRINT_CBOR_PRETTY +#include +#include +#include +#include +#include "zcbor_common.h" +#define RESET_COLOR "\x1B[0m" + +#ifndef ZCBOR_PRINT_CBOR_COLOR_HEADER +#define ZCBOR_PRINT_CBOR_COLOR_HEADER "\x1B[31m" /* red */ +#endif +#ifndef ZCBOR_PRINT_CBOR_COLOR_VALUE +#define ZCBOR_PRINT_CBOR_COLOR_VALUE "\x1B[34m" /* blue */ +#endif +#ifndef ZCBOR_PRINT_CBOR_COLOR_DESC +#define ZCBOR_PRINT_CBOR_COLOR_DESC "\x1B[32m" /* green */ +#endif +#ifndef ZCBOR_PRINT_CBOR_COLOR_TAG +#define ZCBOR_PRINT_CBOR_COLOR_TAG "\x1B[33m" /* yellow */ +#endif + + +const static char *zcbor_header_byte_strings[] = { + "", "", "bstr", "tstr", "list", "map", "tag", "simple" +}; + + +__attribute__((used)) +static const char *zcbor_header_byte_str(uint8_t header_byte) +{ + zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(header_byte); + uint8_t additional = ZCBOR_ADDITIONAL(header_byte); + const char *simple_strings[] = {"false", "true", "nil", "undefined"}; + + if ((major_type < ZCBOR_MAJOR_TYPE_SIMPLE) + || (additional < ZCBOR_BOOL_TO_SIMPLE) + || (additional == ZCBOR_VALUE_IS_1_BYTE)) { + return zcbor_header_byte_strings[major_type]; + } else if (additional <= ZCBOR_VALUE_IN_HEADER) { + return simple_strings[additional - ZCBOR_BOOL_TO_SIMPLE]; + } + + return ""; +} + +__attribute__((used)) +static bool zcbor_print_float(int8_t additional, uint64_t value) +{ + uint32_t value32; + double dvalue; + + switch(additional) { + case ZCBOR_VALUE_IS_2_BYTES: + dvalue = (double)zcbor_float16_to_32((uint16_t)value); + break; + case ZCBOR_VALUE_IS_4_BYTES: + value32 = (uint32_t)value; + dvalue = (double)(*(float *)&value32); + break; + case ZCBOR_VALUE_IS_8_BYTES: + dvalue = *(double *)&value; + break; + default: + return false; + } + zcbor_do_print("%f", dvalue); + return true; +} + +__attribute__((used)) +static void zcbor_print_numeric(uint8_t header_byte, uint64_t value) +{ + zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(header_byte); + uint8_t additional = ZCBOR_ADDITIONAL(header_byte); + + if (major_type == ZCBOR_MAJOR_TYPE_NINT) { + zcbor_do_print("-%llu", value + 1); + } else if (major_type == ZCBOR_MAJOR_TYPE_SIMPLE + && additional >= ZCBOR_BOOL_TO_SIMPLE + && additional <= ZCBOR_VALUE_IN_HEADER) { + /* Do nothing */ + } else if (additional == ZCBOR_VALUE_IS_INDEFINITE_LENGTH) { + /* Do nothing */ + } else if (major_type == ZCBOR_MAJOR_TYPE_SIMPLE + && zcbor_print_float(additional, value)) { + /* Do nothing, already printed */ + } else { + zcbor_do_print("%llu", value); + } +} + +__attribute__((used)) +static void zcbor_print_value(uint8_t const *payload, size_t len, uint64_t value, size_t indent_len) +{ + uint8_t header_byte = *payload; + + zcbor_print_indent(indent_len); + zcbor_do_print(ZCBOR_PRINT_CBOR_COLOR_HEADER "0x%02x " ZCBOR_PRINT_CBOR_COLOR_VALUE, + header_byte); + if (len > 0) { + zcbor_print_str(payload + 1, len - 1, 0); + } + zcbor_do_print(ZCBOR_PRINT_CBOR_COLOR_DESC "(%s", zcbor_header_byte_str(header_byte)); + zcbor_print_numeric(header_byte, value); + zcbor_do_print(")" RESET_COLOR); + zcbor_print_newline(); +} + +__attribute__((used)) +static void zcbor_print_tstr(uint8_t const *payload, size_t len, size_t indent_len) +{ + zcbor_print_indent(indent_len); + zcbor_do_print("\""); + size_t prev_i = 0; + + for (size_t i = 0; i < len; i++) { + if (payload[i] == '\n') { + /* Add indent after newlines. */ + zcbor_do_print("%.*s", i - prev_i, payload + prev_i); + prev_i = i + 1; + zcbor_print_newline(); + zcbor_print_indent(indent_len); + } + } + zcbor_do_print("%.*s\"", len - prev_i, payload + prev_i); + zcbor_print_newline(); +} + +__attribute__((used)) +static void zcbor_print_tag(uint32_t tag, size_t indent_len) +{ + zcbor_print_indent(indent_len); + zcbor_do_print(ZCBOR_PRINT_CBOR_COLOR_TAG "0x%02x ", tag); +} + +__attribute__((used)) +static void zcbor_print_end(zcbor_major_type_t major_type, size_t indent_len) +{ + zcbor_print_indent(indent_len); + zcbor_do_print(ZCBOR_PRINT_CBOR_COLOR_HEADER "0xff " ZCBOR_PRINT_CBOR_COLOR_DESC "(%s end)" RESET_COLOR, + zcbor_header_byte_strings[major_type]); + zcbor_print_newline(); +} + +#else + +__attribute__((used)) +static void zcbor_print_tstr(uint8_t const *payload, size_t len, size_t indent_len) +{ + zcbor_do_print("\"%.*s\"", len, payload); + zcbor_print_newline(); +} + +__attribute__((used)) +static void zcbor_print_value(uint8_t const *payload, size_t len, uint64_t value, size_t indent_len) +{ + zcbor_print_str(payload, len, indent_len); + if (len) { + if (ZCBOR_ADDITIONAL(*payload) == ZCBOR_VALUE_IS_INDEFINITE_LENGTH) { + zcbor_do_print("(start)"); + } else { + zcbor_do_print("(%llu)", value); + } + zcbor_print_newline(); + } +} + +__attribute__((used)) +static void zcbor_print_tag(uint32_t tag, size_t indent_len) +{ + zcbor_print_indent(indent_len); + zcbor_do_print("0x%02x ", tag); +} + +__attribute__((used)) +static void zcbor_print_end(zcbor_major_type_t major_type, size_t indent_len) +{ + zcbor_print_indent(indent_len); + zcbor_do_print("0xff (end)"); + zcbor_print_newline(); +} + +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/samples/pet/src/pet_decode.c b/samples/pet/src/pet_decode.c index 8f6e50dd..128a9a2d 100644 --- a/samples/pet/src/pet_decode.c +++ b/samples/pet/src/pet_decode.c @@ -13,6 +13,7 @@ #include #include #include "zcbor_decode.h" +#include "zcbor_print.h" #include "pet_decode.h" #include "zcbor_print.h" diff --git a/samples/pet/src/pet_encode.c b/samples/pet/src/pet_encode.c index e006a490..1bb464ba 100644 --- a/samples/pet/src/pet_encode.c +++ b/samples/pet/src/pet_encode.c @@ -13,6 +13,7 @@ #include #include #include "zcbor_encode.h" +#include "zcbor_print.h" #include "pet_encode.h" #include "zcbor_print.h" diff --git a/src/zcbor_decode.c b/src/zcbor_decode.c index 92f9fe51..21df2aa2 100644 --- a/src/zcbor_decode.c +++ b/src/zcbor_decode.c @@ -962,6 +962,7 @@ bool zcbor_search_key_tstr_term(zcbor_state_t *state, char const *str, size_t ma } +#ifndef ZCBOR_CANONICAL static bool array_end_expect(zcbor_state_t *state) { INITIAL_CHECKS(); @@ -970,6 +971,7 @@ static bool array_end_expect(zcbor_state_t *state) state->payload++; return true; } +#endif static bool list_map_end_decode(zcbor_state_t *state) @@ -1397,46 +1399,71 @@ bool zcbor_float_pexpect(zcbor_state_t *state, double *expected) } -bool zcbor_any_skip(zcbor_state_t *state, void *result) +#ifdef ZCBOR_PRINT_CBOR +static bool traverse_element(zcbor_state_t *state, bool do_print, uint8_t indent_len); + +bool zcbor_print_cbor(zcbor_state_t *state) { - PRINT_FUNC(); - zcbor_assert_state(result == NULL, - "'any' type cannot be returned, only skipped.\r\n"); - (void)result; + return traverse_element(state, true, 0); +} - INITIAL_CHECKS(); - zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(*state->payload); - uint8_t additional = ZCBOR_ADDITIONAL(*state->payload); - uint64_t value = 0; /* In case of indefinite_length_array. */ +static void print_cbor_if_valid(zcbor_state_t *state, size_t len, uint8_t indent_len); + +static void print_btstr_w_cbor(zcbor_state_t *state, size_t len, bool is_bstr, uint8_t indent_len) +{ + if (len) { + zcbor_print_btstr(state->payload, len, is_bstr, indent_len); + if (is_bstr) { + print_cbor_if_valid(state, len, indent_len); + } + } +} + +#define PRINT_CBOR_IF(do_print, func, ...) do { \ + if (do_print) func(__VA_ARGS__); \ +} while (0) + +#else +#define PRINT_CBOR_IF(do_print, func, ...) /* Disabled */ +#endif + +static bool traverse_element(zcbor_state_t *state, bool do_print, uint8_t indent_len) +{ + /* INITIAL_CHECKS(); done by zcbor_tag_decode() below. */ zcbor_state_t state_copy; + uint32_t tag_dummy; memcpy(&state_copy, state, sizeof(zcbor_state_t)); - while (major_type == ZCBOR_MAJOR_TYPE_TAG) { - uint32_t tag_dummy; - - if (!zcbor_tag_decode(&state_copy, &tag_dummy)) { - ZCBOR_FAIL(); - } - ZCBOR_ERR_IF(state_copy.payload >= state_copy.payload_end, ZCBOR_ERR_NO_PAYLOAD); - major_type = ZCBOR_MAJOR_TYPE(*state_copy.payload); - additional = ZCBOR_ADDITIONAL(*state_copy.payload); + while (zcbor_tag_decode(&state_copy, &tag_dummy)) { + PRINT_CBOR_IF(do_print, zcbor_print_tag, tag_dummy, indent_len); } + zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(*state_copy.payload); + uint64_t value = 0; /* 0 in case of indefinite_length_array. */ + uint8_t const *payload_after_tags = state_copy.payload; + (void)payload_after_tags; /* Not always used. */ #ifdef ZCBOR_CANONICAL const bool indefinite_length_array = false; #else + uint8_t additional = ZCBOR_ADDITIONAL(*state_copy.payload); const bool indefinite_length_array = ((additional == ZCBOR_VALUE_IS_INDEFINITE_LENGTH) && ((major_type == ZCBOR_MAJOR_TYPE_LIST) || (major_type == ZCBOR_MAJOR_TYPE_MAP))); #endif - if (!indefinite_length_array && !value_extract(&state_copy, &value, sizeof(value))) { + if (indefinite_length_array) { + state_copy.payload++; + } else if (!value_extract(&state_copy, &value, sizeof(value))) { /* Can happen because of elem_count (or payload_end) */ ZCBOR_FAIL(); } + PRINT_CBOR_IF(do_print, zcbor_print_value, payload_after_tags, + state_copy.payload - payload_after_tags, value, indent_len); + switch (major_type) { case ZCBOR_MAJOR_TYPE_BSTR: + /* Fallthrough */ case ZCBOR_MAJOR_TYPE_TSTR: /* 'value' is the length of the BSTR or TSTR. * The subtraction is safe because value_extract() above @@ -1444,6 +1471,10 @@ bool zcbor_any_skip(zcbor_state_t *state, void *result) ZCBOR_ERR_IF( value > (uint64_t)(state_copy.payload_end - state_copy.payload), ZCBOR_ERR_NO_PAYLOAD); + + PRINT_CBOR_IF(do_print, print_btstr_w_cbor, &state_copy, (size_t)value, + major_type == ZCBOR_MAJOR_TYPE_BSTR, indent_len + 1); + (state_copy.payload) += value; break; case ZCBOR_MAJOR_TYPE_MAP: @@ -1452,18 +1483,18 @@ bool zcbor_any_skip(zcbor_state_t *state, void *result) /* fallthrough */ case ZCBOR_MAJOR_TYPE_LIST: if (indefinite_length_array) { - state_copy.payload++; value = ZCBOR_LARGE_ELEM_COUNT; } state_copy.elem_count = (size_t)value; state_copy.decode_state.indefinite_length_array = indefinite_length_array; while (!zcbor_array_at_end(&state_copy)) { - if (!zcbor_any_skip(&state_copy, NULL)) { + if (!traverse_element(&state_copy, do_print, indent_len + 1)) { ZCBOR_FAIL(); } } - if (indefinite_length_array && !array_end_expect(&state_copy)) { - ZCBOR_FAIL(); + if (indefinite_length_array) { + state_copy.payload++; /* payload bounds checked by zcbor_array_at_end(). */ + PRINT_CBOR_IF(do_print, zcbor_print_end, major_type, indent_len); } break; default: @@ -1477,6 +1508,34 @@ bool zcbor_any_skip(zcbor_state_t *state, void *result) return true; } +__attribute__((used)) +static void print_cbor_if_valid(zcbor_state_t *state, size_t len, uint8_t indent_len) +{ + uint8_t const *payload_bak = state->payload; + size_t elem_count_bak = state->elem_count; + + state->elem_count++; + if (traverse_element(state, false, indent_len) + && (state->payload == (payload_bak + len))) { + state->elem_count++; + state->payload = payload_bak; + (void)traverse_element(state, true, indent_len); + } + state->payload = payload_bak; + state->elem_count = elem_count_bak; +} + + +bool zcbor_any_skip(zcbor_state_t *state, void *result) +{ + PRINT_FUNC(); + zcbor_assert_state(result == NULL, + "'any' type cannot be returned, only skipped.\r\n"); + (void)result; + + return traverse_element(state, false, 0); +} + bool zcbor_tag_decode(zcbor_state_t *state, uint32_t *result) { diff --git a/tests/cmake/test_template.cmake b/tests/cmake/test_template.cmake index a87a7fb5..41b8d17e 100644 --- a/tests/cmake/test_template.cmake +++ b/tests/cmake/test_template.cmake @@ -16,6 +16,14 @@ if (CANONICAL) zephyr_compile_definitions(ZCBOR_CANONICAL) endif() +if (ZCBOR_PRINT_CBOR) + zephyr_compile_definitions(ZCBOR_PRINT_CBOR) +endif() + +if (ZCBOR_PRINT_COLORS) + zephyr_compile_definitions(ZCBOR_PRINT_CBOR_PRETTY) +endif() + if (CONFIG_BIG_ENDIAN OR BIG_ENDIAN) zephyr_compile_definitions(ZCBOR_BIG_ENDIAN) endif() diff --git a/tests/decode/test2_suit/CMakeLists.txt b/tests/decode/test2_suit/CMakeLists.txt index bc2d4ae4..63595f38 100644 --- a/tests/decode/test2_suit/CMakeLists.txt +++ b/tests/decode/test2_suit/CMakeLists.txt @@ -36,7 +36,7 @@ include(${PROJECT_BINARY_DIR}/manifest2.cmake) target_link_libraries(manifest2 PRIVATE zephyr_interface) target_link_libraries(app PRIVATE manifest2) -if (NOT VERBOSE) +if (NOT VERBOSE AND NOT ZCBOR_PRINT_CBOR) # VERBOSE means including printk which doesn't build with these options. target_compile_options(manifest2 PRIVATE -Wpedantic -Wconversion -Wdouble-promotion) endif() diff --git a/tests/decode/test5_corner_cases/CMakeLists.txt b/tests/decode/test5_corner_cases/CMakeLists.txt index 18a586aa..9e54d97a 100644 --- a/tests/decode/test5_corner_cases/CMakeLists.txt +++ b/tests/decode/test5_corner_cases/CMakeLists.txt @@ -79,7 +79,7 @@ if (TEST_INDEFINITE_LENGTH_ARRAYS) target_compile_definitions(app PUBLIC TEST_INDEFINITE_LENGTH_ARRAYS) endif() -if (NOT VERBOSE AND CONFIG_MINIMAL_LIBC) +if (NOT VERBOSE AND CONFIG_MINIMAL_LIBC AND NOT ZCBOR_PRINT_CBOR) # VERBOSE means including printk which doesn't build with these options. target_compile_options(corner_cases PRIVATE -Wpedantic -Wconversion -Wdouble-promotion) endif() diff --git a/tests/encode/test4_senml/CMakeLists.txt b/tests/encode/test4_senml/CMakeLists.txt index dfd858e7..5d882e24 100644 --- a/tests/encode/test4_senml/CMakeLists.txt +++ b/tests/encode/test4_senml/CMakeLists.txt @@ -32,7 +32,7 @@ include(${PROJECT_BINARY_DIR}/senml.cmake) target_link_libraries(senml PRIVATE zephyr_interface) target_link_libraries(app PRIVATE senml) -if (NOT VERBOSE) +if (NOT VERBOSE AND NOT ZCBOR_PRINT_CBOR) # VERBOSE means including printk which doesn't build with these options. target_compile_options(senml PRIVATE -Wpedantic -Wconversion) endif() diff --git a/tests/scripts/test_repo_files.py b/tests/scripts/test_repo_files.py index e7f89d79..7547a8a4 100644 --- a/tests/scripts/test_repo_files.py +++ b/tests/scripts/test_repo_files.py @@ -142,7 +142,7 @@ def __init__(self, *args, **kwargs): repo_url_args = ['git', 'remote', 'get-url', remote] repo_url = check_output(repo_url_args).decode('utf-8').strip().strip('.git') if 'github.com' in repo_url: - self.base_url = (repo_url + '/tree/' + remote_branch + '/') + self.base_url = (repo_url + '/blob/' + remote_branch + '/') else: # The URL is not in github.com, so we are not sure it is constructed correctly. self.base_url = None diff --git a/tests/unit/test4_print_cbor/CMakeLists.txt b/tests/unit/test4_print_cbor/CMakeLists.txt new file mode 100644 index 00000000..b7ac9bb7 --- /dev/null +++ b/tests/unit/test4_print_cbor/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(test4_print_cbor) + +set(REPO_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../..) + +include(${REPO_ROOT}/tests/cmake/test_template.cmake) + +FILE(GLOB zcbor_sources ${REPO_ROOT}/src/*.c) +target_sources(app PRIVATE + ${zcbor_sources}) + +target_include_directories(app PRIVATE ${REPO_ROOT}/include) + +zephyr_compile_definitions(ZCBOR_STOP_ON_ERROR) +zephyr_compile_definitions(ZCBOR_PRINT_CBOR) diff --git a/tests/unit/test4_print_cbor/prj.conf b/tests/unit/test4_print_cbor/prj.conf new file mode 100644 index 00000000..106c73da --- /dev/null +++ b/tests/unit/test4_print_cbor/prj.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_CBPRINTF_FP_SUPPORT=y diff --git a/tests/unit/test4_print_cbor/src/main.c b/tests/unit/test4_print_cbor/src/main.c new file mode 100644 index 00000000..8a7ba276 --- /dev/null +++ b/tests/unit/test4_print_cbor/src/main.c @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + + +uint8_t suit_example[] = { + 0xd8, 0x6b, 0xa4, 0x02, 0x58, 0x73, 0x82, 0x58, 0x24, 0x82, 0x2f, + 0x58, 0x20, 0x86, 0xbb, 0xcc, 0x88, 0x23, 0xf3, 0xa4, 0x44, 0x19, + 0x56, 0xf0, 0x2b, 0x00, 0x13, 0x02, 0xf5, 0x03, 0x48, 0x74, 0x61, + 0xfb, 0x77, 0xfa, 0xb0, 0x86, 0xef, 0xe3, 0x15, 0x30, 0x88, 0x1f, + 0x97, 0x58, 0x4a, 0xd2, 0x84, 0x43, 0xa1, 0x01, 0x26, 0xa0, 0xf6, + 0x58, 0x40, 0x8c, 0x6b, 0xf0, 0x14, 0xb6, 0x2f, 0xa7, 0xb8, 0x0d, + 0xd5, 0xeb, 0x2f, 0xf7, 0x02, 0x4a, 0xb5, 0x2a, 0x11, 0x6c, 0xd1, + 0xbc, 0x0d, 0xb1, 0xf1, 0x03, 0x11, 0xb3, 0x1e, 0x7b, 0x29, 0xe3, + 0xbe, 0xae, 0x76, 0x5f, 0xad, 0x42, 0xfb, 0x86, 0x00, 0xfa, 0x13, + 0xa6, 0xbf, 0x6d, 0x5e, 0x45, 0x92, 0x9a, 0x05, 0xa6, 0x07, 0x67, + 0xf9, 0xb7, 0x42, 0x0a, 0x50, 0x02, 0xa0, 0x5d, 0x95, 0xe4, 0x9e, + 0x03, 0x58, 0xbb, 0xa7, 0x01, 0x01, 0x02, 0x02, 0x03, 0x58, 0x5f, + 0xa2, 0x02, 0x81, 0x81, 0x41, 0x00, 0x04, 0x58, 0x56, 0x86, 0x14, + 0xa4, 0x01, 0x50, 0xfa, 0x6b, 0x4a, 0x53, 0xd5, 0xad, 0x5f, 0xdf, + 0xbe, 0x9d, 0xe6, 0x63, 0xe4, 0xd4, 0x1f, 0xfe, 0x02, 0x50, 0x14, + 0x92, 0xaf, 0x14, 0x25, 0x69, 0x5e, 0x48, 0xbf, 0x42, 0x9b, 0x2d, + 0x51, 0xf2, 0xab, 0x45, 0x03, 0x58, 0x24, 0x82, 0x2f, 0x58, 0x20, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, + 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, + 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x0e, + 0x19, 0x87, 0xd0, 0x01, 0x0f, 0x02, 0x0f, 0x07, 0x43, 0x82, 0x03, + 0x0f, 0x09, 0x43, 0x82, 0x17, 0x02, 0x11, 0x82, 0x2f, 0x58, 0x20, + 0xcf, 0xa9, 0x0c, 0x5c, 0x58, 0x59, 0x5e, 0x7f, 0x51, 0x19, 0xa7, + 0x2f, 0x80, 0x3f, 0xd0, 0x37, 0x0b, 0x3e, 0x6a, 0xbb, 0xec, 0x63, + 0x15, 0xcd, 0x38, 0xf6, 0x31, 0x35, 0x28, 0x1b, 0xc4, 0x98, 0x17, + 0x82, 0x2f, 0x58, 0x20, 0x2b, 0xfc, 0x4d, 0x0c, 0xc6, 0x68, 0x0b, + 0xe7, 0xdd, 0x9f, 0x5c, 0xa3, 0x0a, 0xa2, 0xbb, 0x5d, 0x19, 0x98, + 0x14, 0x5d, 0xe3, 0x3d, 0x54, 0x10, 0x1b, 0x80, 0xe2, 0xca, 0x49, + 0xfa, 0xf9, 0x18, 0x11, 0x58, 0x3c, 0x86, 0x14, 0xa1, 0x15, 0x78, + 0x32, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x65, + 0x72, 0x79, 0x2f, 0x6c, 0x6f, 0x6e, 0x67, 0x2f, 0x70, 0x61, 0x74, + 0x68, 0x2f, 0x74, 0x6f, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x66, + 0x69, 0x6c, 0x65, 0x2e, 0x62, 0x69, 0x6e, 0x15, 0x02, 0x03, 0x0f, + 0x17, 0x59, 0x02, 0x04, 0xa2, 0x01, 0x79, 0x01, 0x9d, 0x23, 0x23, + 0x20, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x32, 0x3a, + 0x20, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x74, 0x61, 0x6e, 0x65, 0x6f, + 0x75, 0x73, 0x20, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, + 0x2c, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, + 0x20, 0x42, 0x6f, 0x6f, 0x74, 0x2c, 0x20, 0x53, 0x65, 0x76, 0x65, + 0x72, 0x65, 0x64, 0x20, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x0a, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, + 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6c, + 0x61, 0x74, 0x65, 0x73, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, + 0x74, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x20, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x20, 0x28, 0x7b, 0x7b, 0x74, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, + 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x7d, 0x7d, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2a, + 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x42, 0x6f, 0x6f, + 0x74, 0x20, 0x28, 0x7b, 0x7b, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x2d, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2d, 0x62, + 0x6f, 0x6f, 0x74, 0x7d, 0x7d, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x2a, 0x20, 0x46, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x20, + 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x28, 0x7b, + 0x7b, 0x66, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x2d, 0x64, + 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x2d, 0x74, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x7d, 0x7d, 0x29, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x69, 0x73, + 0x20, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x61, 0x6c, + 0x73, 0x6f, 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x73, 0x20, 0x73, 0x65, 0x76, 0x65, 0x72, 0x61, + 0x62, 0x6c, 0x65, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x20, 0x28, 0x7b, 0x7b, 0x6f, 0x76, 0x72, 0x2d, 0x73, 0x65, + 0x76, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x7d, 0x7d, 0x29, 0x2c, + 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x28, + 0x7b, 0x7b, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x2d, + 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x2d, 0x74, 0x65, 0x78, 0x74, + 0x7d, 0x7d, 0x29, 0x2e, 0x81, 0x41, 0x00, 0xa2, 0x03, 0x67, 0x61, + 0x72, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x05, 0x78, 0x52, 0x54, 0x68, + 0x69, 0x73, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x64, 0x65, 0x6d, 0x6f, + 0x6e, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20, + 0x54, 0x68, 0x65, 0x20, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x20, + 0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x20, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x2c, 0x20, 0x6e, + 0x6f, 0x74, 0x20, 0x61, 0x20, 0x72, 0x65, 0x61, 0x6c, 0x20, 0x6f, + 0x6e, 0x65, 0x2e +}; + + +int main(void) +{ + uint8_t payload[150] = {0}; + uint8_t bstr_ex[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; + + ZCBOR_STATE_E(state_e, 3, payload, sizeof(payload), 0); + ZCBOR_STATE_D(print_state1, 3, payload, sizeof(payload), 30, 0); + ZCBOR_STATE_D(print_state2, 3, suit_example, sizeof(suit_example), 30, 0); + + state_e->constant_state->stop_on_error = true; + + zcbor_list_start_encode(state_e, 0); + zcbor_int32_put(state_e, 0); + zcbor_int32_put(state_e, 0x1234); + zcbor_int64_put(state_e, 9876543210); + zcbor_bstr_put_arr(state_e, bstr_ex); + zcbor_tstr_put_lit(state_e, "Hello World"); + zcbor_tag_encode(state_e, &(uint32_t){9}); + zcbor_tag_put(state_e, 0x1234); + zcbor_bool_put(state_e, true); + zcbor_bool_put(state_e, false); + zcbor_float16_put(state_e, 3.14); + zcbor_float32_put(state_e, 10.5); + zcbor_float64_put(state_e, 12.7); + zcbor_nil_put(state_e, NULL); + zcbor_undefined_put(state_e, NULL); + zcbor_bstr_start_encode(state_e); + zcbor_bstr_end_encode(state_e, NULL); + zcbor_list_start_encode(state_e, 1); + zcbor_map_start_encode(state_e, 2); + zcbor_tstr_put_lit(state_e, "Key0"); + zcbor_float32_put(state_e, 0.0); + zcbor_int32_put(state_e, 1); + zcbor_tstr_put_lit(state_e, "Value1"); + zcbor_map_end_encode(state_e, 2); + zcbor_list_end_encode(state_e, 1); + bool ret = zcbor_list_end_encode(state_e, 0); + + if (!ret) { + printk("Encode error: %d\r\n", zcbor_peek_error(state_e)); + return 1; + } + + k_msleep(1); + ret = zcbor_print_cbor(print_state1); + + if (!ret) { + printk("Print error 1: %d\r\n", zcbor_peek_error(print_state1)); + return 1; + } + + ret = zcbor_print_cbor(print_state2); + + if (!ret) { + printk("Print error 2: %d\r\n", zcbor_peek_error(print_state2)); + return 1; + } + + return 0; +} diff --git a/tests/unit/test4_print_cbor/testcase.yaml b/tests/unit/test4_print_cbor/testcase.yaml new file mode 100644 index 00000000..d56cd920 --- /dev/null +++ b/tests/unit/test4_print_cbor/testcase.yaml @@ -0,0 +1,474 @@ +tests: + zcbor.unit.test4_print_cbor: + # Note: mps2_an521 sometimes faults during printing and so is excluded here + # I don't know why, but I think it's unrelated. + platform_allow: native_posix qemu_malta_be + extra_args: ZCBOR_PRINT_CBOR=ON + tags: zcbor unit test4 print_cbor no_verbose + timeout: 10 + harness: console + harness_config: + type: multi_line + regex: + - '0x9f \(start\)' + - '\| 0x00 \(0\)' + - '\| 0x19 12 34 \(4660\)' + - '\| 0x1b 00 00 00 02 4c b0 16 ea \(9876543210\)' + - '\| 0x58 20 \(32\)' + - '\| \| 0x01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10' + - '\| \| 0x00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff' + - '\| 0x6b \(11\)' + - '"Hello World"' + - '\| 0x09 0x1234 0xf5 \(21\)' + - '\| 0xf4 \(20\)' + - '\| 0xf9 42 48 \(16968\)' + - '\| 0xfa 41 28 00 00 \(1093140480\)' + - '\| 0xfb 40 29 66 66 66 66 66 66 \(4623339082463209062\)' + - '\| 0xf6 \(22\)' + - '\| 0xf7 \(23\)' + - '\| 0x40 \(0\)' + - '\| 0x9f \(start\)' + - '\| \| 0xbf \(start\)' + - '\| \| \| 0x64 \(4\)' + - '"Key0"' + - '\| \| \| 0xfa 00 00 00 00 \(0\)' + - '\| \| \| 0x01 \(1\)' + - '\| \| \| 0x66 \(6\)' + - '"Value1"' + - '\| \| 0xff \(end\)' + - '\| 0xff \(end\)' + - '0xff \(end\)' + - '0x6b 0xa4 \(4\)' + - '\| 0x02 \(2\)' + - '\| 0x58 73 \(115\)' + - '\| \| 0x82 58 24 82 2f 58 20 86 bb cc 88 23 f3 a4 44 19' + - '\| \| 0x56 f0 2b 00 13 02 f5 03 48 74 61 fb 77 fa b0 86' + - '\| \| 0xef e3 15 30 88 1f 97 58 4a d2 84 43 a1 01 26 a0' + - '\| \| 0xf6 58 40 8c 6b f0 14 b6 2f a7 b8 0d d5 eb 2f f7' + - '\| \| 0x02 4a b5 2a 11 6c d1 bc 0d b1 f1 03 11 b3 1e 7b' + - '\| \| 0x29 e3 be ae 76 5f ad 42 fb 86 00 fa 13 a6 bf 6d' + - '\| \| 0x5e 45 92 9a 05 a6 07 67 f9 b7 42 0a 50 02 a0 5d' + - '\| \| 0x95 e4 9e' + - '\| \| 0x82 \(2\)' + - '\| \| \| 0x58 24 \(36\)' + - '\| \| \| \| 0x82 2f 58 20 86 bb cc 88 23 f3 a4 44 19 56 f0 2b' + - '\| \| \| \| 0x00 13 02 f5 03 48 74 61 fb 77 fa b0 86 ef e3 15' + - '\| \| \| \| 0x30 88 1f 97' + - '\| \| \| \| 0x82 \(2\)' + - '\| \| \| \| \| 0x2f \(15\)' + - '\| \| \| \| \| 0x58 20 \(32\)' + - '\| \| \| \| \| \| 0x86 bb cc 88 23 f3 a4 44 19 56 f0 2b 00 13 02 f5' + - '\| \| \| \| \| \| 0x03 48 74 61 fb 77 fa b0 86 ef e3 15 30 88 1f 97' + - '\| \| \| 0x58 4a \(74\)' + - '\| \| \| \| 0xd2 84 43 a1 01 26 a0 f6 58 40 8c 6b f0 14 b6 2f' + - '\| \| \| \| 0xa7 b8 0d d5 eb 2f f7 02 4a b5 2a 11 6c d1 bc 0d' + - '\| \| \| \| 0xb1 f1 03 11 b3 1e 7b 29 e3 be ae 76 5f ad 42 fb' + - '\| \| \| \| 0x86 00 fa 13 a6 bf 6d 5e 45 92 9a 05 a6 07 67 f9' + - '\| \| \| \| 0xb7 42 0a 50 02 a0 5d 95 e4 9e' + - '\| \| \| \| 0x12 0x84 \(4\)' + - '\| \| \| \| \| 0x43 \(3\)' + - '\| \| \| \| \| \| 0xa1 \(1\)' + - '\| \| \| \| \| \| \| 0x01 \(1\)' + - '\| \| \| \| \| \| \| 0x26 \(6\)' + - '\| \| \| \| \| 0xa0 \(0\)' + - '\| \| \| \| \| 0xf6 \(22\)' + - '\| \| \| \| \| 0x58 40 \(64\)' + - '\| \| \| \| \| \| 0x8c 6b f0 14 b6 2f a7 b8 0d d5 eb 2f f7 02 4a b5' + - '\| \| \| \| \| \| 0x2a 11 6c d1 bc 0d b1 f1 03 11 b3 1e 7b 29 e3 be' + - '\| \| \| \| \| \| 0xae 76 5f ad 42 fb 86 00 fa 13 a6 bf 6d 5e 45 92' + - '\| \| \| \| \| \| 0x9a 05 a6 07 67 f9 b7 42 0a 50 02 a0 5d 95 e4 9e' + - '\| 0x03 \(3\)' + - '\| 0x58 bb \(187\)' + - '\| \| 0xa7 01 01 02 02 03 58 5f a2 02 81 81 41 00 04 58' + - '\| \| 0x56 86 14 a4 01 50 fa 6b 4a 53 d5 ad 5f df be 9d' + - '\| \| 0xe6 63 e4 d4 1f fe 02 50 14 92 af 14 25 69 5e 48' + - '\| \| 0xbf 42 9b 2d 51 f2 ab 45 03 58 24 82 2f 58 20 00' + - '\| \| 0x11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01' + - '\| \| 0x23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10 0e' + - '\| \| 0x19 87 d0 01 0f 02 0f 07 43 82 03 0f 09 43 82 17' + - '\| \| 0x02 11 82 2f 58 20 cf a9 0c 5c 58 59 5e 7f 51 19' + - '\| \| 0xa7 2f 80 3f d0 37 0b 3e 6a bb ec 63 15 cd 38 f6' + - '\| \| 0x31 35 28 1b c4 98 17 82 2f 58 20 2b fc 4d 0c c6' + - '\| \| 0x68 0b e7 dd 9f 5c a3 0a a2 bb 5d 19 98 14 5d e3' + - '\| \| 0x3d 54 10 1b 80 e2 ca 49 fa f9 18' + - '\| \| 0xa7 \(7\)' + - '\| \| \| 0x01 \(1\)' + - '\| \| \| 0x01 \(1\)' + - '\| \| \| 0x02 \(2\)' + - '\| \| \| 0x02 \(2\)' + - '\| \| \| 0x03 \(3\)' + - '\| \| \| 0x58 5f \(95\)' + - '\| \| \| \| 0xa2 02 81 81 41 00 04 58 56 86 14 a4 01 50 fa 6b' + - '\| \| \| \| 0x4a 53 d5 ad 5f df be 9d e6 63 e4 d4 1f fe 02 50' + - '\| \| \| \| 0x14 92 af 14 25 69 5e 48 bf 42 9b 2d 51 f2 ab 45' + - '\| \| \| \| 0x03 58 24 82 2f 58 20 00 11 22 33 44 55 66 77 88' + - '\| \| \| \| 0x99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef fe' + - '\| \| \| \| 0xdc ba 98 76 54 32 10 0e 19 87 d0 01 0f 02 0f' + - '\| \| \| \| 0xa2 \(2\)' + - '\| \| \| \| \| 0x02 \(2\)' + - '\| \| \| \| \| 0x81 \(1\)' + - '\| \| \| \| \| \| 0x81 \(1\)' + - '\| \| \| \| \| \| \| 0x41 \(1\)' + - '\| \| \| \| \| \| \| \| 0x00 \(0\)' + - '\| \| \| \| \| 0x04 \(4\)' + - '\| \| \| \| \| 0x58 56 \(86\)' + - '\| \| \| \| \| \| 0x86 14 a4 01 50 fa 6b 4a 53 d5 ad 5f df be 9d e6' + - '\| \| \| \| \| \| 0x63 e4 d4 1f fe 02 50 14 92 af 14 25 69 5e 48 bf' + - '\| \| \| \| \| \| 0x42 9b 2d 51 f2 ab 45 03 58 24 82 2f 58 20 00 11' + - '\| \| \| \| \| \| 0x22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23' + - '\| \| \| \| \| \| 0x45 67 89 ab cd ef fe dc ba 98 76 54 32 10 0e 19' + - '\| \| \| \| \| \| 0x87 d0 01 0f 02 0f' + - '\| \| \| \| \| \| 0x86 \(6\)' + - '\| \| \| \| \| \| \| 0x14 \(20\)' + - '\| \| \| \| \| \| \| 0xa4 \(4\)' + - '\| \| \| \| \| \| \| \| 0x01 \(1\)' + - '\| \| \| \| \| \| \| \| 0x50 \(16\)' + - '\| \| \| \| \| \| \| \| \| 0xfa 6b 4a 53 d5 ad 5f df be 9d e6 63 e4 d4 1f fe' + - '\| \| \| \| \| \| \| \| 0x02 \(2\)' + - '\| \| \| \| \| \| \| \| 0x50 \(16\)' + - '\| \| \| \| \| \| \| \| \| 0x14 92 af 14 25 69 5e 48 bf 42 9b 2d 51 f2 ab 45' + - '\| \| \| \| \| \| \| \| 0x03 \(3\)' + - '\| \| \| \| \| \| \| \| 0x58 24 \(36\)' + - '\| \| \| \| \| \| \| \| \| 0x82 2f 58 20 00 11 22 33 44 55 66 77 88 99 aa bb' + - '\| \| \| \| \| \| \| \| \| 0xcc dd ee ff 01 23 45 67 89 ab cd ef fe dc ba 98' + - '\| \| \| \| \| \| \| \| \| 0x76 54 32 10' + - '\| \| \| \| \| \| \| \| \| 0x82 \(2\)' + - '\| \| \| \| \| \| \| \| \| \| 0x2f \(15\)' + - '\| \| \| \| \| \| \| \| \| \| 0x58 20 \(32\)' + - '\| \| \| \| \| \| \| \| \| \| \| 0x00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff' + - '\| \| \| \| \| \| \| \| \| \| \| 0x01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10' + - '\| \| \| \| \| \| \| \| 0x0e \(14\)' + - '\| \| \| \| \| \| \| \| 0x19 87 d0 \(34768\)' + - '\| \| \| \| \| \| \| 0x01 \(1\)' + - '\| \| \| \| \| \| \| 0x0f \(15\)' + - '\| \| \| \| \| \| \| 0x02 \(2\)' + - '\| \| \| \| \| \| \| 0x0f \(15\)' + - '\| \| \| 0x07 \(7\)' + - '\| \| \| 0x43 \(3\)' + - '\| \| \| \| 0x82 \(2\)' + - '\| \| \| \| \| 0x03 \(3\)' + - '\| \| \| \| \| 0x0f \(15\)' + - '\| \| \| 0x09 \(9\)' + - '\| \| \| 0x43 \(3\)' + - '\| \| \| \| 0x82 \(2\)' + - '\| \| \| \| \| 0x17 \(23\)' + - '\| \| \| \| \| 0x02 \(2\)' + - '\| \| \| 0x11 \(17\)' + - '\| \| \| 0x82 \(2\)' + - '\| \| \| \| 0x2f \(15\)' + - '\| \| \| \| 0x58 20 \(32\)' + - '\| \| \| \| \| 0xcf a9 0c 5c 58 59 5e 7f 51 19 a7 2f 80 3f d0 37' + - '\| \| \| \| \| 0x0b 3e 6a bb ec 63 15 cd 38 f6 31 35 28 1b c4 98' + - '\| \| \| 0x17 \(23\)' + - '\| \| \| 0x82 \(2\)' + - '\| \| \| \| 0x2f \(15\)' + - '\| \| \| \| 0x58 20 \(32\)' + - '\| \| \| \| \| 0x2b fc 4d 0c c6 68 0b e7 dd 9f 5c a3 0a a2 bb 5d' + - '\| \| \| \| \| 0x19 98 14 5d e3 3d 54 10 1b 80 e2 ca 49 fa f9 18' + - '\| 0x11 \(17\)' + - '\| 0x58 3c \(60\)' + - '\| \| 0x86 14 a1 15 78 32 68 74 74 70 3a 2f 2f 65 78 61' + - '\| \| 0x6d 70 6c 65 2e 63 6f 6d 2f 76 65 72 79 2f 6c 6f' + - '\| \| 0x6e 67 2f 70 61 74 68 2f 74 6f 2f 66 69 6c 65 2f' + - '\| \| 0x66 69 6c 65 2e 62 69 6e 15 02 03 0f' + - '\| \| 0x86 \(6\)' + - '\| \| \| 0x14 \(20\)' + - '\| \| \| 0xa1 \(1\)' + - '\| \| \| \| 0x15 \(21\)' + - '\| \| \| \| 0x78 32 \(50\)' + - '"http://example.com/very/long/path/to/file/file\.bin"' + - '\| \| \| 0x15 \(21\)' + - '\| \| \| 0x02 \(2\)' + - '\| \| \| 0x03 \(3\)' + - '\| \| \| 0x0f \(15\)' + - '\| 0x17 \(23\)' + - '\| 0x59 02 04 \(516\)' + - '\| \| 0xa2 01 79 01 9d 23 23 20 45 78 61 6d 70 6c 65 20' + - '\| \| 0x32 3a 20 53 69 6d 75 6c 74 61 6e 65 6f 75 73 20' + - '\| \| 0x44 6f 77 6e 6c 6f 61 64 2c 20 49 6e 73 74 61 6c' + - '\| \| 0x6c 61 74 69 6f 6e 2c 20 53 65 63 75 72 65 20 42' + - '\| \| 0x6f 6f 74 2c 20 53 65 76 65 72 65 64 20 46 69 65' + - '\| \| 0x6c 64 73 0a 0a 20 20 20 20 54 68 69 73 20 65 78' + - '\| \| 0x61 6d 70 6c 65 20 63 6f 76 65 72 73 20 74 68 65' + - '\| \| 0x20 66 6f 6c 6c 6f 77 69 6e 67 20 74 65 6d 70 6c' + - '\| \| 0x61 74 65 73 3a 0a 20 20 20 20 0a 20 20 20 20 2a' + - '\| \| 0x20 43 6f 6d 70 61 74 69 62 69 6c 69 74 79 20 43' + - '\| \| 0x68 65 63 6b 20 28 7b 7b 74 65 6d 70 6c 61 74 65' + - '\| \| 0x2d 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 2d 63' + - '\| \| 0x68 65 63 6b 7d 7d 29 0a 20 20 20 20 2a 20 53 65' + - '\| \| 0x63 75 72 65 20 42 6f 6f 74 20 28 7b 7b 74 65 6d' + - '\| \| 0x70 6c 61 74 65 2d 73 65 63 75 72 65 2d 62 6f 6f' + - '\| \| 0x74 7d 7d 29 0a 20 20 20 20 2a 20 46 69 72 6d 77' + - '\| \| 0x61 72 65 20 44 6f 77 6e 6c 6f 61 64 20 28 7b 7b' + - '\| \| 0x66 69 72 6d 77 61 72 65 2d 64 6f 77 6e 6c 6f 61' + - '\| \| 0x64 2d 74 65 6d 70 6c 61 74 65 7d 7d 29 0a 20 20' + - '\| \| 0x20 20 0a 20 20 20 20 54 68 69 73 20 65 78 61 6d' + - '\| \| 0x70 6c 65 20 61 6c 73 6f 20 64 65 6d 6f 6e 73 74' + - '\| \| 0x72 61 74 65 73 20 73 65 76 65 72 61 62 6c 65 20' + - '\| \| 0x65 6c 65 6d 65 6e 74 73 20 28 7b 7b 6f 76 72 2d' + - '\| \| 0x73 65 76 65 72 61 62 6c 65 7d 7d 29 2c 20 61 6e' + - '\| \| 0x64 20 74 65 78 74 20 28 7b 7b 6d 61 6e 69 66 65' + - '\| \| 0x73 74 2d 64 69 67 65 73 74 2d 74 65 78 74 7d 7d' + - '\| \| 0x29 2e 81 41 00 a2 03 67 61 72 6d 2e 63 6f 6d 05' + - '\| \| 0x78 52 54 68 69 73 20 63 6f 6d 70 6f 6e 65 6e 74' + - '\| \| 0x20 69 73 20 61 20 64 65 6d 6f 6e 73 74 72 61 74' + - '\| \| 0x69 6f 6e 2e 20 54 68 65 20 64 69 67 65 73 74 20' + - '\| \| 0x69 73 20 61 20 73 61 6d 70 6c 65 20 70 61 74 74' + - '\| \| 0x65 72 6e 2c 20 6e 6f 74 20 61 20 72 65 61 6c 20' + - '\| \| 0x6f 6e 65 2e' + - '\| \| 0xa2 \(2\)' + - '\| \| \| 0x01 \(1\)' + - '\| \| \| 0x79 01 9d \(413\)' + - '"## Example 2: Simultaneous Download, Installation, Secure Boot, Severed Fields' + - 'This example covers the following templates:' + - '\* Compatibility Check \(\{\{template-compatibility-check\}\}\)' + - '\* Secure Boot \(\{\{template-secure-boot\}\}\)' + - '\* Firmware Download \(\{\{firmware-download-template\}\}\)' + - 'This example also demonstrates severable elements \(\{\{ovr-severable\}\}\), and text \(\{\{manifest-digest-text\}\}\)\."' + - '\| \| \| 0x81 \(1\)' + - '\| \| \| \| 0x41 \(1\)' + - '\| \| \| \| \| 0x00 \(0\)' + - '\| \| \| 0xa2 \(2\)' + - '\| \| \| \| 0x03 \(3\)' + - '\| \| \| \| 0x67 \(7\)' + - '\"arm.com\"' + - '\| \| \| \| 0x05 \(5\)' + - '\| \| \| \| 0x78 52 \(82\)' + - '\"This component is a demonstration\. The digest is a sample pattern, not a real one\.\"' + zcbor.unit.test4_print_cbor.colors: + platform_allow: native_posix qemu_malta_be + extra_args: ZCBOR_PRINT_CBOR=ON ZCBOR_PRINT_COLORS=ON + tags: zcbor unit test4 print_cbor no_verbose colors + timeout: 10 + harness: console + harness_config: + type: multi_line + regex: + - '.\[31m0x9f .\[34m.\[32m\(list\).\[0m' + - '\| .\[31m0x00 .\[34m.\[32m\(0\).\[0m' + - '\| .\[31m0x19 .\[34m0x12 34 .\[32m\(4660\).\[0m' + - '\| .\[31m0x1b .\[34m0x00 00 00 02 4c b0 16 ea .\[32m\(9876543210\).\[0m' + - '\| .\[31m0x58 .\[34m0x20 .\[32m\(bstr32\).\[0m' + - '\| \| 0x01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10' + - '\| \| 0x00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff' + - '\| .\[31m0x6b .\[34m.\[32m\(tstr11\).\[0m' + - '\| \| .Hello World.' + - '\| .\[33m0x09 .\[33m0x1234 .\[31m0xf5 .\[34m.\[32m\(true\).\[0m' + - '\| .\[31m0xf4 .\[34m.\[32m\(false\).\[0m' + - '\| .\[31m0xf9 .\[34m0x42 48 .\[32m\(3.140625\).\[0m' + - '\| .\[31m0xfa .\[34m0x41 28 00 00 .\[32m\(10.500000\).\[0m' + - '\| .\[31m0xfb .\[34m0x40 29 66 66 66 66 66 66 .\[32m\(12.700000\).\[0m' + - '\| .\[31m0xf6 .\[34m.\[32m\(nil\).\[0m' + - '\| .\[31m0xf7 .\[34m.\[32m\(undefined\).\[0m' + - '\| .\[31m0x40 .\[34m.\[32m\(bstr0\).\[0m' + - '\| .\[31m0x9f .\[34m.\[32m\(list\).\[0m' + - '\| \| .\[31m0xbf .\[34m.\[32m\(map\).\[0m' + - '\| \| \| .\[31m0x64 .\[34m.\[32m\(tstr4\).\[0m' + - '\| \| \| \| .Key0.' + - '\| \| \| .\[31m0xfa .\[34m0x00 00 00 00 .\[32m\(0.000000\).\[0m' + - '\| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| .\[31m0x66 .\[34m.\[32m\(tstr6\).\[0m' + - '\| \| \| \| .Value1.' + - '\| \| .\[31m0xff .\[32m\(map end\).\[0m' + - '\| .\[31m0xff .\[32m\(list end\).\[0m' + - '.\[31m0xff .\[32m\(list end\).\[0m' + - '.\[33m0x6b .\[31m0xa4 .\[34m.\[32m\(map4\).\[0m' + - '\| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| .\[31m0x58 .\[34m0x73 .\[32m\(bstr115\).\[0m' + - '\| \| 0x82 58 24 82 2f 58 20 86 bb cc 88 23 f3 a4 44 19' + - '\| \| 0x56 f0 2b 00 13 02 f5 03 48 74 61 fb 77 fa b0 86' + - '\| \| 0xef e3 15 30 88 1f 97 58 4a d2 84 43 a1 01 26 a0' + - '\| \| 0xf6 58 40 8c 6b f0 14 b6 2f a7 b8 0d d5 eb 2f f7' + - '\| \| 0x02 4a b5 2a 11 6c d1 bc 0d b1 f1 03 11 b3 1e 7b' + - '\| \| 0x29 e3 be ae 76 5f ad 42 fb 86 00 fa 13 a6 bf 6d' + - '\| \| 0x5e 45 92 9a 05 a6 07 67 f9 b7 42 0a 50 02 a0 5d' + - '\| \| 0x95 e4 9e' + - '\| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| .\[31m0x58 .\[34m0x24 .\[32m\(bstr36\).\[0m' + - '\| \| \| \| 0x82 2f 58 20 86 bb cc 88 23 f3 a4 44 19 56 f0 2b' + - '\| \| \| \| 0x00 13 02 f5 03 48 74 61 fb 77 fa b0 86 ef e3 15' + - '\| \| \| \| 0x30 88 1f 97' + - '\| \| \| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| \| \| .\[31m0x2f .\[34m.\[32m\(-16\).\[0m' + - '\| \| \| \| \| .\[31m0x58 .\[34m0x20 .\[32m\(bstr32\).\[0m' + - '\| \| \| \| \| \| 0x86 bb cc 88 23 f3 a4 44 19 56 f0 2b 00 13 02 f5' + - '\| \| \| \| \| \| 0x03 48 74 61 fb 77 fa b0 86 ef e3 15 30 88 1f 97' + - '\| \| \| .\[31m0x58 .\[34m0x4a .\[32m\(bstr74\).\[0m' + - '\| \| \| \| 0xd2 84 43 a1 01 26 a0 f6 58 40 8c 6b f0 14 b6 2f' + - '\| \| \| \| 0xa7 b8 0d d5 eb 2f f7 02 4a b5 2a 11 6c d1 bc 0d' + - '\| \| \| \| 0xb1 f1 03 11 b3 1e 7b 29 e3 be ae 76 5f ad 42 fb' + - '\| \| \| \| 0x86 00 fa 13 a6 bf 6d 5e 45 92 9a 05 a6 07 67 f9' + - '\| \| \| \| 0xb7 42 0a 50 02 a0 5d 95 e4 9e' + - '\| \| \| \| .\[33m0x12 .\[31m0x84 .\[34m.\[32m\(list4\).\[0m' + - '\| \| \| \| \| .\[31m0x43 .\[34m.\[32m\(bstr3\).\[0m' + - '\| \| \| \| \| \| .\[31m0xa1 .\[34m.\[32m\(map1\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x26 .\[34m.\[32m\(-7\).\[0m' + - '\| \| \| \| \| .\[31m0xa0 .\[34m.\[32m\(map0\).\[0m' + - '\| \| \| \| \| .\[31m0xf6 .\[34m.\[32m\(nil\).\[0m' + - '\| \| \| \| \| .\[31m0x58 .\[34m0x40 .\[32m\(bstr64\).\[0m' + - '\| \| \| \| \| \| 0x8c 6b f0 14 b6 2f a7 b8 0d d5 eb 2f f7 02 4a b5' + - '\| \| \| \| \| \| 0x2a 11 6c d1 bc 0d b1 f1 03 11 b3 1e 7b 29 e3 be' + - '\| \| \| \| \| \| 0xae 76 5f ad 42 fb 86 00 fa 13 a6 bf 6d 5e 45 92' + - '\| \| \| \| \| \| 0x9a 05 a6 07 67 f9 b7 42 0a 50 02 a0 5d 95 e4 9e' + - '\| .\[31m0x03 .\[34m.\[32m\(3\).\[0m' + - '\| .\[31m0x58 .\[34m0xbb .\[32m\(bstr187\).\[0m' + - '\| \| 0xa7 01 01 02 02 03 58 5f a2 02 81 81 41 00 04 58' + - '\| \| 0x56 86 14 a4 01 50 fa 6b 4a 53 d5 ad 5f df be 9d' + - '\| \| 0xe6 63 e4 d4 1f fe 02 50 14 92 af 14 25 69 5e 48' + - '\| \| 0xbf 42 9b 2d 51 f2 ab 45 03 58 24 82 2f 58 20 00' + - '\| \| 0x11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01' + - '\| \| 0x23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10 0e' + - '\| \| 0x19 87 d0 01 0f 02 0f 07 43 82 03 0f 09 43 82 17' + - '\| \| 0x02 11 82 2f 58 20 cf a9 0c 5c 58 59 5e 7f 51 19' + - '\| \| 0xa7 2f 80 3f d0 37 0b 3e 6a bb ec 63 15 cd 38 f6' + - '\| \| 0x31 35 28 1b c4 98 17 82 2f 58 20 2b fc 4d 0c c6' + - '\| \| 0x68 0b e7 dd 9f 5c a3 0a a2 bb 5d 19 98 14 5d e3' + - '\| \| 0x3d 54 10 1b 80 e2 ca 49 fa f9 18' + - '\| \| .\[31m0xa7 .\[34m.\[32m\(map7\).\[0m' + - '\| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| .\[31m0x03 .\[34m.\[32m\(3\).\[0m' + - '\| \| \| .\[31m0x58 .\[34m0x5f .\[32m\(bstr95\).\[0m' + - '\| \| \| \| 0xa2 02 81 81 41 00 04 58 56 86 14 a4 01 50 fa 6b' + - '\| \| \| \| 0x4a 53 d5 ad 5f df be 9d e6 63 e4 d4 1f fe 02 50' + - '\| \| \| \| 0x14 92 af 14 25 69 5e 48 bf 42 9b 2d 51 f2 ab 45' + - '\| \| \| \| 0x03 58 24 82 2f 58 20 00 11 22 33 44 55 66 77 88' + - '\| \| \| \| 0x99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef fe' + - '\| \| \| \| 0xdc ba 98 76 54 32 10 0e 19 87 d0 01 0f 02 0f' + - '\| \| \| \| .\[31m0xa2 .\[34m.\[32m\(map2\).\[0m' + - '\| \| \| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| \| \| .\[31m0x81 .\[34m.\[32m\(list1\).\[0m' + - '\| \| \| \| \| \| .\[31m0x81 .\[34m.\[32m\(list1\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x41 .\[34m.\[32m\(bstr1\).\[0m' + - '\| \| \| \| \| \| \| \| .\[31m0x00 .\[34m.\[32m\(0\).\[0m' + - '\| \| \| \| \| .\[31m0x04 .\[34m.\[32m\(4\).\[0m' + - '\| \| \| \| \| .\[31m0x58 .\[34m0x56 .\[32m\(bstr86\).\[0m' + - '\| \| \| \| \| \| 0x86 14 a4 01 50 fa 6b 4a 53 d5 ad 5f df be 9d e6' + - '\| \| \| \| \| \| 0x63 e4 d4 1f fe 02 50 14 92 af 14 25 69 5e 48 bf' + - '\| \| \| \| \| \| 0x42 9b 2d 51 f2 ab 45 03 58 24 82 2f 58 20 00 11' + - '\| \| \| \| \| \| 0x22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23' + - '\| \| \| \| \| \| 0x45 67 89 ab cd ef fe dc ba 98 76 54 32 10 0e 19' + - '\| \| \| \| \| \| 0x87 d0 01 0f 02 0f' + - '\| \| \| \| \| \| .\[31m0x86 .\[34m.\[32m\(list6\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x14 .\[34m.\[32m\(20\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0xa4 .\[34m.\[32m\(map4\).\[0m' + - '\| \| \| \| \| \| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| \| \| \| \| \| .\[31m0x50 .\[34m.\[32m\(bstr16\).\[0m' + - '\| \| \| \| \| \| \| \| \| 0xfa 6b 4a 53 d5 ad 5f df be 9d e6 63 e4 d4 1f fe' + - '\| \| \| \| \| \| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| \| \| \| \| \| .\[31m0x50 .\[34m.\[32m\(bstr16\).\[0m' + - '\| \| \| \| \| \| \| \| \| 0x14 92 af 14 25 69 5e 48 bf 42 9b 2d 51 f2 ab 45' + - '\| \| \| \| \| \| \| \| .\[31m0x03 .\[34m.\[32m\(3\).\[0m' + - '\| \| \| \| \| \| \| \| .\[31m0x58 .\[34m0x24 .\[32m\(bstr36\).\[0m' + - '\| \| \| \| \| \| \| \| \| 0x82 2f 58 20 00 11 22 33 44 55 66 77 88 99 aa bb' + - '\| \| \| \| \| \| \| \| \| 0xcc dd ee ff 01 23 45 67 89 ab cd ef fe dc ba 98' + - '\| \| \| \| \| \| \| \| \| 0x76 54 32 10' + - '\| \| \| \| \| \| \| \| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| \| \| \| \| \| \| \| .\[31m0x2f .\[34m.\[32m\(-16\).\[0m' + - '\| \| \| \| \| \| \| \| \| \| .\[31m0x58 .\[34m0x20 .\[32m\(bstr32\).\[0m' + - '\| \| \| \| \| \| \| \| \| \| \| 0x00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff' + - '\| \| \| \| \| \| \| \| \| \| \| 0x01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10' + - '\| \| \| \| \| \| \| \| .\[31m0x0e .\[34m.\[32m\(14\).\[0m' + - '\| \| \| \| \| \| \| \| .\[31m0x19 .\[34m0x87 d0 .\[32m\(34768\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x0f .\[34m.\[32m\(15\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| \| \| \| \| .\[31m0x0f .\[34m.\[32m\(15\).\[0m' + - '\| \| \| .\[31m0x07 .\[34m.\[32m\(7\).\[0m' + - '\| \| \| .\[31m0x43 .\[34m.\[32m\(bstr3\).\[0m' + - '\| \| \| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| \| \| .\[31m0x03 .\[34m.\[32m\(3\).\[0m' + - '\| \| \| \| \| .\[31m0x0f .\[34m.\[32m\(15\).\[0m' + - '\| \| \| .\[31m0x09 .\[34m.\[32m\(9\).\[0m' + - '\| \| \| .\[31m0x43 .\[34m.\[32m\(bstr3\).\[0m' + - '\| \| \| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| \| \| .\[31m0x17 .\[34m.\[32m\(23\).\[0m' + - '\| \| \| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| .\[31m0x11 .\[34m.\[32m\(17\).\[0m' + - '\| \| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| \| .\[31m0x2f .\[34m.\[32m\(-16\).\[0m' + - '\| \| \| \| .\[31m0x58 .\[34m0x20 .\[32m\(bstr32\).\[0m' + - '\| \| \| \| \| 0xcf a9 0c 5c 58 59 5e 7f 51 19 a7 2f 80 3f d0 37' + - '\| \| \| \| \| 0x0b 3e 6a bb ec 63 15 cd 38 f6 31 35 28 1b c4 98' + - '\| \| \| .\[31m0x17 .\[34m.\[32m\(23\).\[0m' + - '\| \| \| .\[31m0x82 .\[34m.\[32m\(list2\).\[0m' + - '\| \| \| \| .\[31m0x2f .\[34m.\[32m\(-16\).\[0m' + - '\| \| \| \| .\[31m0x58 .\[34m0x20 .\[32m\(bstr32\).\[0m' + - '\| \| \| \| \| 0x2b fc 4d 0c c6 68 0b e7 dd 9f 5c a3 0a a2 bb 5d' + - '\| \| \| \| \| 0x19 98 14 5d e3 3d 54 10 1b 80 e2 ca 49 fa f9 18' + - '\| .\[31m0x11 .\[34m.\[32m\(17\).\[0m' + - '\| .\[31m0x58 .\[34m0x3c .\[32m\(bstr60\).\[0m' + - '\| \| 0x86 14 a1 15 78 32 68 74 74 70 3a 2f 2f 65 78 61' + - '\| \| 0x6d 70 6c 65 2e 63 6f 6d 2f 76 65 72 79 2f 6c 6f' + - '\| \| 0x6e 67 2f 70 61 74 68 2f 74 6f 2f 66 69 6c 65 2f' + - '\| \| 0x66 69 6c 65 2e 62 69 6e 15 02 03 0f' + - '\| \| .\[31m0x86 .\[34m.\[32m\(list6\).\[0m' + - '\| \| \| .\[31m0x14 .\[34m.\[32m\(20\).\[0m' + - '\| \| \| .\[31m0xa1 .\[34m.\[32m\(map1\).\[0m' + - '\| \| \| \| .\[31m0x15 .\[34m.\[32m\(21\).\[0m' + - '\| \| \| \| .\[31m0x78 .\[34m0x32 .\[32m\(tstr50\).\[0m' + - '\| \| \| \| \| .http://example.com/very/long/path/to/file/file.bin.' + - '\| \| \| .\[31m0x15 .\[34m.\[32m\(21\).\[0m' + - '\| \| \| .\[31m0x02 .\[34m.\[32m\(2\).\[0m' + - '\| \| \| .\[31m0x03 .\[34m.\[32m\(3\).\[0m' + - '\| \| \| .\[31m0x0f .\[34m.\[32m\(15\).\[0m' + - '\| .\[31m0x17 .\[34m.\[32m\(23\).\[0m' + - '\| .\[31m0x59 .\[34m0x02 04 .\[32m\(bstr516\).\[0m' + - '\| \| 0xa2 01 79 01 9d 23 23 20 45 78 61 6d 70 6c 65 20' + - '\| \| 0x32 3a 20 53 69 6d 75 6c 74 61 6e 65 6f 75 73 20' + - '\| \| 0x44 6f 77 6e 6c 6f 61 64 2c 20 49 6e 73 74 61 6c' + - '\| \| 0x6c 61 74 69 6f 6e 2c 20 53 65 63 75 72 65 20 42' + - '\| \| 0x6f 6f 74 2c 20 53 65 76 65 72 65 64 20 46 69 65' + - '\| \| 0x6c 64 73 0a 0a 20 20 20 20 54 68 69 73 20 65 78' + - '\| \| 0x61 6d 70 6c 65 20 63 6f 76 65 72 73 20 74 68 65' + - '\| \| 0x20 66 6f 6c 6c 6f 77 69 6e 67 20 74 65 6d 70 6c' + - '\| \| 0x61 74 65 73 3a 0a 20 20 20 20 0a 20 20 20 20 2a' + - '\| \| 0x20 43 6f 6d 70 61 74 69 62 69 6c 69 74 79 20 43' + - '\| \| 0x68 65 63 6b 20 28 7b 7b 74 65 6d 70 6c 61 74 65' + - '\| \| 0x2d 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 2d 63' + - '\| \| 0x68 65 63 6b 7d 7d 29 0a 20 20 20 20 2a 20 53 65' + - '\| \| 0x63 75 72 65 20 42 6f 6f 74 20 28 7b 7b 74 65 6d' + - '\| \| 0x70 6c 61 74 65 2d 73 65 63 75 72 65 2d 62 6f 6f' + - '\| \| 0x74 7d 7d 29 0a 20 20 20 20 2a 20 46 69 72 6d 77' + - '\| \| 0x61 72 65 20 44 6f 77 6e 6c 6f 61 64 20 28 7b 7b' + - '\| \| 0x66 69 72 6d 77 61 72 65 2d 64 6f 77 6e 6c 6f 61' + - '\| \| 0x64 2d 74 65 6d 70 6c 61 74 65 7d 7d 29 0a 20 20' + - '\| \| 0x20 20 0a 20 20 20 20 54 68 69 73 20 65 78 61 6d' + - '\| \| 0x70 6c 65 20 61 6c 73 6f 20 64 65 6d 6f 6e 73 74' + - '\| \| 0x72 61 74 65 73 20 73 65 76 65 72 61 62 6c 65 20' + - '\| \| 0x65 6c 65 6d 65 6e 74 73 20 28 7b 7b 6f 76 72 2d' + - '\| \| 0x73 65 76 65 72 61 62 6c 65 7d 7d 29 2c 20 61 6e' + - '\| \| 0x64 20 74 65 78 74 20 28 7b 7b 6d 61 6e 69 66 65' + - '\| \| 0x73 74 2d 64 69 67 65 73 74 2d 74 65 78 74 7d 7d' + - '\| \| 0x29 2e 81 41 00 a2 03 67 61 72 6d 2e 63 6f 6d 05' + - '\| \| 0x78 52 54 68 69 73 20 63 6f 6d 70 6f 6e 65 6e 74' + - '\| \| 0x20 69 73 20 61 20 64 65 6d 6f 6e 73 74 72 61 74' + - '\| \| 0x69 6f 6e 2e 20 54 68 65 20 64 69 67 65 73 74 20' + - '\| \| 0x69 73 20 61 20 73 61 6d 70 6c 65 20 70 61 74 74' + - '\| \| 0x65 72 6e 2c 20 6e 6f 74 20 61 20 72 65 61 6c 20' + - '\| \| 0x6f 6e 65 2e' + - '\| \| .\[31m0xa2 .\[34m.\[32m\(map2\).\[0m' + - '\| \| \| .\[31m0x01 .\[34m.\[32m\(1\).\[0m' + - '\| \| \| .\[31m0x79 .\[34m0x01 9d .\[32m\(tstr413\).\[0m' + - '\| \| \| \| .\#\# Example 2\: Simultaneous Download, Installation, Secure Boot, Severed Fields' + - '\| \| \| \|' + - '\| \| \| \| This example covers the following templates\:' + - '\| \| \| \|' + - '\| \| \| \| \* Compatibility Check \(\{\{template-compatibility-check\}\}\)' + - '\| \| \| \| \* Secure Boot \(\{\{template-secure-boot\}\}\)' + - '\| \| \| \| \* Firmware Download \(\{\{firmware-download-template\}\}\)' + - '\| \| \| \|' + - '\| \| \| \| This example also demonstrates severable elements \(\{\{ovr-severable\}\}\), and text \(\{\{manifest-digest-text\}\}\)..' + - '\| \| \| .\[31m0x81 .\[34m.\[32m\(list1\).\[0m' + - '\| \| \| \| .\[31m0x41 .\[34m.\[32m\(bstr1\).\[0m' + - '\| \| \| \| \| .\[31m0x00 .\[34m.\[32m\(0\).\[0m' + - '\| \| \| .\[31m0xa2 .\[34m.\[32m\(map2\).\[0m' + - '\| \| \| \| .\[31m0x03 .\[34m.\[32m\(3\).\[0m' + - '\| \| \| \| .\[31m0x67 .\[34m.\[32m\(tstr7\).\[0m' + - '\| \| \| \| \| .arm.com.' + - '\| \| \| \| .\[31m0x05 .\[34m.\[32m\(5\).\[0m' + - '\| \| \| \| .\[31m0x78 .\[34m0x52 .\[32m\(tstr82\).\[0m' + - '\| \| \| \| \| .This component is a demonstration. The digest is a sample pattern, not a real one..' diff --git a/zcbor/zcbor.py b/zcbor/zcbor.py index 143b9f00..29ed9dfc 100755 --- a/zcbor/zcbor.py +++ b/zcbor/zcbor.py @@ -2668,6 +2668,7 @@ def render_c_file(self, header_file_name, mode): #include #include #include "zcbor_{mode}.h" +#include "zcbor_print.h" #include "{header_file_name}" #include "zcbor_print.h"