Re: [PATCH v7 3/5] Mention pylibfdt in the documentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, Feb 21, 2017 at 09:33:38PM -0700, Simon Glass wrote:
> Add a note about pylibfdt in the README.
> 
> Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

> ---
> 
> Changes in v7: None
> Changes in v6:
> - Update example to print the node value as an integer
> - Update example to print the bytestring as well as the string
> 
> Changes in v5:
> - Use an interactive session to demonstrate pylibfdt
> - Mention that more work remains
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - Add details on how to obtain full help and code coverage
> 
>  README | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/README b/README
> index f92008f..96d8486 100644
> --- a/README
> +++ b/README
> @@ -7,6 +7,53 @@ DTC and LIBFDT are maintained by:
>  David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
>  Jon Loeliger <jdl@xxxxxxx>
>  
> +
> +Python library
> +--------------
> +
> +A Python library is also available. To build this you will need to install
> +swig and Python development files. On Debian distributions:
> +
> +   sudo apt-get install swig python-dev
> +
> +The library provides an Fdt class which you can use like this:
> +
> +$ PYTHONPATH=../pylibfdt python
> +>>> import libfdt
> +>>> fdt = libfdt.Fdt(open('test_tree1.dtb').read())
> +>>> node = fdt.path_offset('/subnode@1')
> +>>> print node
> +124
> +>>> prop_offset = fdt.first_property_offset(node)
> +>>> prop = fdt.get_property_by_offset(prop_offset)
> +>>> print '%s=%r' % (prop.name, prop.value)
> +compatible=bytearray(b'subnode1\x00')
> +>>> print '%s=%s' % (prop.name, prop.value)
> +compatible=subnode1
> +>>> node2 = fdt.path_offset('/')
> +>>> print fdt.getprop(node2, 'compatible')
> +test_tree1
> +
> +You will find tests in tests/pylibfdt_tests.py showing how to use each
> +method. Help is available using the Python help command, e.g.:
> +
> +    $ cd pylibfdt
> +    $ python -c "import libfdt; help(libfdt)"
> +
> +If you add new features, please check code coverage:
> +
> +    $ sudo apt-get install python-pip python-pytest
> +    $ sudo pip install coverage
> +    $ cd tests
> +    $ coverage run pylibfdt_tests.py
> +    $ coverage html
> +    # Open 'htmlcov/index.html' in your browser
> +
> +
> +More work remains to support all of libfdt, including access to numeric
> +values.
> +
> +
>  Mailing list
>  ------------
>  The following list is for discussion about dtc and libfdt implementation

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux