Lines Matching +full:python +full:- +full:version
5 It comes with a schema-driven script tool that can validate your data, or even generate code.
14 …y zcbor is CDDL (Concise Data Definition Language) which is a powerful human-readable data descrip…
22 - C code:
23 …- As a low-footprint CBOR decoding/encoding library similar to TinyCBOR/QCBOR/NanoCBOR. The librar…
24 …- To generate C code (using the Python script) for validating and decoding or encoding CBOR, for u…
25 - Python script and module ([More information](#python-script-and-module)):
26 - Validate a YAML/JSON file and translate it into CBOR e.g. for transmission.
27 - Validate a YAML/JSON/CBOR file before processing it with some other tool
28 - Decode and validate incoming CBOR data into human-readable YAML/JSON.
29 - As part of a python script that processes YAML/JSON/CBOR files.
30 - Uses the same internal representation used by the PyYAML/json/cbor2 libraries.
31 - Do validation against a CDDL schema.
32 - Create a read-only representation via named tuples (with names taken from the CDDL schema).
43 …[unit](tests/unit) tests run using [Zephyr](https://github.com/zephyrproject-rtos/zephyr) (the sam…
46 -----------------------------------------------------
51 These checks ensure that the payload is well-formed.
60 The library is also used by generated code. See the [Code generation](#code-generation) section for…
65 ----------------------
73 Backups are needed for _decoding_ if there are any lists, maps, or CBOR-encoded strings (`zcbor_bst…
92 -------------
94 The C library has a few compile-time configuration options.
96 If using zcbor with Zephyr, use the [Kconfig options](https://github.com/zephyrproject-rtos/zephyr/…
99 ------------------------- | -----------
103 …y. Note that it also has to be enabled in the state variable (`state->constant_state->stop_on_erro…
104 `ZCBOR_BIG_ENDIAN` | All decoded values are returned as big-endian. The default is little-en…
108 Python script and module
116 ---------------------------------------
122 See `zcbor validate --help` and `zcbor convert --help` for more information.
125 zcbor validate -c <CDDL description file> -t <which CDDL type to expect> -i <input data file>
126 zcbor convert -c <CDDL description file> -t <which CDDL type to expect> -i <input data file> -o <ou…
132 python3 <zcbor base>/zcbor/zcbor.py validate -c <CDDL description file> -t <which CDDL type to expe…
133 …<zcbor base>/zcbor/zcbor.py convert -c <CDDL description file> -t <which CDDL type to expect> -i <…
136 Importing zcbor in a Python script
137 ----------------------------------
143 …aml (PyYAML)](https://pypi.org/project/PyYAML/), and [json](https://docs.python.org/3/library/json…
144 …ation types (map, list, string, number etc.) are mapped directly to the corresponding Python types.
146 …ranslator hides the idiomatic representations for bytestrings, tags, and non-text keys described a…
150 Making CBOR YAML-/JSON-compatible
151 ---------------------------------
154 This is controlled with the `--yaml-compatibility` option to `convert` and `validate`.
158 …ed as `{"zcbor_bstr": "<hex-formatted bytestring>"}`, or as `{"zcbor_bstr": <any type>}` if the CB…
172 zcbor code <--decode or --encode or both> -c <CDDL description file(s)> -t <which CDDL type(s) to e…
173 …--decode or --encode or both> -c <CDDL description file(s)> -t <which CDDL type(s) to expose in th…
178 Finally, it takes the "entry types" (`-t`) and creates a public API function for each of them.
183 - A header file with types (always)
184 - A header file with declarations for decoding functions (if `--decode`/`-d` is specified)
185 - A C file with decoding functions (if `--decode`/`-d` is specified)
186 - A header file with declarations for encoding functions (if `--encode`/`-e` is specified)
187 - A C file with encoding functions (if `--encode`/`-e` is specified)
188 …- A CMake file that creates a library with the generated code and the C library (if `--output-cmak…
195 The tests require [Zephyr](https://github.com/zephyrproject-rtos/zephyr) (if your system is set up …
200 ------------
202 When calling zcbor with the argument `--output-cmake <file path>`, a CMake file will be created at …
203 The generated CMake file creates a target library and adds the generated and non-generated source f…
206 …bor can be instructed to copy the non-generated sources to the same location as the generated sour…
225 ---------------
228 python3 <zcbor base>/zcbor/zcbor.py code -c pet.cddl -d -t Pet --oc pet_decode.c --oh pet_decode.h
230 zcbor code -c pet.cddl -d -t Pet --oc pet_decode.c --oh pet_decode.h
234 ----------
239 python3 <zcbor base>/zcbor/zcbor.py convert -c pet.cddl -t Pet -i mypet.yaml -o mypet.cbor
241 zcbor convert -c pet.cddl -t Pet -i mypet.yaml -o mypet.cbor
247 ----------
252 python3 <zcbor base>/zcbor/zcbor.py validate -c pet.cddl -t Pet --yaml-compatibility -i mypet.json
254 zcbor validate -c pet.cddl -t Pet --yaml-compatibility -i mypet.json
257 …takes the json structure in mypet.json, converts any [yaml-compatible](#making-cbor-yaml-json-comp…
269 In this file there are also tests for code style of all python scripts, using the `pycodestyle` lib…
284 - `int`: Positive or negative integer
285 - `uint`: Positive integer
286 - `bstr`: Byte string
287 - `tstr`: Text string
288 - `bool`: Boolean
289 - `nil`: Nil/Null value
290 - `float`: Floating point value
291 - `any`: Any single element
295 - `[]`: List. Elements don't need to have the same type.
296 …- `{}`: Map. Key/value pairs as are declared as `<key> => <value>` or `<key>: <value>`. Note that …
297 …- `()`: Groups. Grouping with no enclosing type, which means that e.g. `Foo = [(int, bstr)]` is eq…
298 …- `/`: Unions. Analogous to unions in C. E.g. `Foo = int/bstr/Bar` where Foo is either an int, a b…
302 …- Number: `Foo = 3`, where Foo is a uint with the additional requirement that it must have the val…
303 - Number range: `Foo = -100..100`, where Foo is an int with value between -100 and 100.
304 - Text string: `Foo = "hello"`, where Foo is a tstr with the requirement that it must be "hello".
305 - True/False: `Foo = false`, where Foo is a bool which is always false.
309 …- `.size`: Works for integers and strings. E.g. `Foo = uint .size 4` where Foo is a uint exactly 4…
310 …- `.cbor`/`.cborseq`: E.g. `Foo = bstr .cbor Bar` where Foo is a bstr whose contents must be CBOR …
314 …- `?`: 0 or 1 time. E.g. `Foo = [int, ?bstr]`, where Foo is a list with an int possibly followed b…
315 - `*`: 0 or more times. E.g. `Foo = [*tstr]`, where Foo is a list containing 0 or more tstrs.
316 - `+`: 1 or more times. E.g. `Foo = [+Bar]`.
317 …- `x*y`: Between x and y times, inclusive. E.g. `Foo = {4*8(int => bstr)}` where Foo is a map with…
328 -------------------------
355 | 1 byte | 0, 1, 2, 4, or 8 bytes | 0 - 2^64-1 bytes/elements |
362 For all major types, Values 0-23 are encoded directly in the _Additional info_, meaning that the _V…
368 * `nint`: Interpret the _Value_ as a positive integer, then multiply by -1 and subtract 1.
369 * `tag`: The _Value_ says something about the next non-tag element.
370 …See the [CBOR tag documentation](https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml) for d…
372 * 0-19: Unassigned simple values.
381 * 31: End of an indefinite-length `list` or `map`.
387 If a `list` or `map` has _Additional info_ 31, it is "indefinite-length", which means it has an "un…
394 zcbor (then "cddl-gen") was initially conceived as a code generation project.
395 …tures in the [IETF SUIT specification](https://datatracker.ietf.org/doc/draft-ietf-suit-manifest/).
401 Since CBOR, YAML, and JSON are all represented in roughly the same way internally in Python, it was…
404 - [MCUboot's serial recovery mechanism](https://github.com/mcu-tools/mcuboot/blob/main/boot/boot_se…
405 - [Zephyr's mcumgr](https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/mgmt/mcumgr/grp/i…
406 - [Zephyr's LwM2M SenML](https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/net/lib/lwm2…
407 - [nRF Connect SDK's full modem update mechanism](https://github.com/nrfconnect/sdk-nrf/blob/main/s…
408 - [nRF Connect SDK's nrf_rpc](https://github.com/nrfconnect/sdk-nrfxlib/blob/main/nrf_rpc/nrf_rpc_c…
416 zcbor --help
417 ------------
420 usage: zcbor [-h] [--version] {code,validate,convert} ...
429 -h, --help show this help message and exit
430 --version show program's version number and exit
434 zcbor code --help
435 -----------------
438 usage: zcbor code [-h] -c CDDL [--no-prelude] [-v]
439 [--default-max-qty DEFAULT_MAX_QTY] [--output-c OUTPUT_C]
440 [--output-h OUTPUT_H] [--output-h-types OUTPUT_H_TYPES]
441 [--copy-sources] [--output-cmake OUTPUT_CMAKE] -t
442 ENTRY_TYPES [ENTRY_TYPES ...] [-d] [-e] [--time-header]
443 [--git-sha-header] [-b {32,64}]
444 [--include-prefix INCLUDE_PREFIX] [-s]
445 [--file-header FILE_HEADER]
457 decoding. Using this mechanism is necessary when the CDDL contains self-
463 -h, --help show this help message and exit
464 -c CDDL, --cddl CDDL Path to one or more input CDDL file(s). Passing
466 --no-prelude Exclude the standard CDDL prelude from the build. The
469 -v, --verbose Print more information while parsing CDDL and
471 --default-max-qty DEFAULT_MAX_QTY, --dq DEFAULT_MAX_QTY
480 --output-c OUTPUT_C, --oc OUTPUT_C
481 Path to output C file. If both --decode and --encode
485 --output-cmake file. A 'src' directory will be created
489 --output-h OUTPUT_H, --oh OUTPUT_H
490 Path to output header file. If both --decode and
491 --encode are specified, _decode and _encode will be
494 the --output-cmake file. An 'include' directory will
498 --output-h-types OUTPUT_H_TYPES, --oht OUTPUT_H_TYPES
502 (--output-h), with '_types' added to the file name.
503 --copy-sources Copy the non-generated source files (zcbor_*.c/h) into
505 --output-cmake OUTPUT_CMAKE
515 without the --copy-sources option.
516 -t ENTRY_TYPES [ENTRY_TYPES ...], --entry-types ENTRY_TYPES [ENTRY_TYPES ...]
519 -d, --decode Generate decoding code. Either --decode or --encode or
521 -e, --encode Generate encoding code. Either --decode or --encode or
523 --time-header Put the current time in a comment in the generated
525 --git-sha-header Put the current git sha of zcbor in a comment in the
527 -b {32,64}, --default-bit-size {32,64}
532 --include-prefix INCLUDE_PREFIX
535 -s, --short-names Attempt to make most generated struct member names
541 --file-header FILE_HEADER
549 zcbor validate --help
550 ---------------------
553 usage: zcbor validate [-h] -c CDDL [--no-prelude] [-v] -i INPUT
554 [--input-as {yaml,json,cbor,cborhex}] -t ENTRY_TYPE
555 [--default-max-qty DEFAULT_MAX_QTY]
556 [--yaml-compatibility]
562 -h, --help show this help message and exit
563 -c CDDL, --cddl CDDL Path to one or more input CDDL file(s). Passing
565 --no-prelude Exclude the standard CDDL prelude from the build. The
568 -v, --verbose Print more information while parsing CDDL and
570 -i INPUT, --input INPUT
571 Input data file. The option --input-as specifies how
572 to interpret the contents. Use "-" to indicate stdin.
573 --input-as {yaml,json,cbor,cborhex}
578 -t ENTRY_TYPE, --entry-type ENTRY_TYPE
581 --default-max-qty DEFAULT_MAX_QTY, --dq DEFAULT_MAX_QTY
586 --yaml-compatibility Whether to convert CBOR-only values to YAML-compatible
592 maps with non-text keys need special handling. See the
597 zcbor convert --help
598 --------------------
601 usage: zcbor convert [-h] -c CDDL [--no-prelude] [-v] -i INPUT
602 [--input-as {yaml,json,cbor,cborhex}] -t ENTRY_TYPE
603 [--default-max-qty DEFAULT_MAX_QTY]
604 [--yaml-compatibility] -o OUTPUT
605 [--output-as {yaml,json,cbor,cborhex,c_code}]
606 [--c-code-var-name C_CODE_VAR_NAME]
607 [--c-code-columns C_CODE_COLUMNS]
615 -h, --help show this help message and exit
616 -c CDDL, --cddl CDDL Path to one or more input CDDL file(s). Passing
618 --no-prelude Exclude the standard CDDL prelude from the build. The
621 -v, --verbose Print more information while parsing CDDL and
623 -i INPUT, --input INPUT
624 Input data file. The option --input-as specifies how
625 to interpret the contents. Use "-" to indicate stdin.
626 --input-as {yaml,json,cbor,cborhex}
631 -t ENTRY_TYPE, --entry-type ENTRY_TYPE
634 --default-max-qty DEFAULT_MAX_QTY, --dq DEFAULT_MAX_QTY
639 --yaml-compatibility Whether to convert CBOR-only values to YAML-compatible
645 maps with non-text keys need special handling. See the
647 -o OUTPUT, --output OUTPUT
648 Output data file. The option --output-as specifies how
649 to interpret the contents. Use "-" to indicate stdout.
650 --output-as {yaml,json,cbor,cborhex,c_code}
656 --c-code-var-name C_CODE_VAR_NAME
657 Only relevant together with '--output-as c_code' or .c
659 --c-code-columns C_CODE_COLUMNS
660 Only relevant together with '--output-as c_code' or .c