Metadata-Version: 2.1
Name: pynrfjprog
Version: 10.24.1
Summary: A simple Python interface for the nrfjprog functionality
Author-email: Nordic Semiconductor ASA <sagtools@nordicsemi.no>
License: Copyright (c) 2010 - 2024, Nordic Semiconductor ASA
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without modification,
        are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form, except as embedded into a Nordic
           Semiconductor ASA integrated circuit in a product or a software update for
           such product, must reproduce the above copyright notice, this list of
           conditions and the following disclaimer in the documentation and/or other
           materials provided with the distribution.
        
        3. Neither the name of Nordic Semiconductor ASA nor the names of its
           contributors may be used to endorse or promote products derived from this
           software without specific prior written permission.
        
        4. This software, with or without modification, must only be used with a
           Nordic Semiconductor ASA integrated circuit.
        
        5. Any software provided in binary form under this license must not be reverse
           engineered, decompiled, modified and/or disassembled.
        
        THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
        OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
        LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
        GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
        OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://www.nordicsemi.com/Products/Development-tools/nrf-pynrfjprog/
Project-URL: Bug Tracker, https://github.com/NordicSemiconductor/pynrfjprog/issues
Keywords: nrfjprog,pynrfjprog
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Embedded Systems
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: Other/Proprietary License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: future
Requires-Dist: tomli-w

[![PyPI](https://img.shields.io/static/v1?label=license&message=Nordic%205-Clause%20License&color=brightgreen)](https://github.com/NordicSemiconductor/pynrfjprog/blob/master/LICENSE)
![PyPI](https://img.shields.io/static/v1?label=platform&message=windows%20%7C%20linux%20%7C%20osx&color=lightgrey)
![PyPI](https://img.shields.io/static/v1?label=python&message=>=3.7&color=blue) [![PyPI](https://img.shields.io/pypi/v/pynrfjprog)](https://pypi.org/project/pynrfjprog/)

# pynrfjprog
Python wrapper around the nrfjprog dynamic link libraries (DLL). Use of this API allows developers to program/debug nRF SOC and SIP devices from the interpreter, write simple scripts for a more efficient development work flow, or write automated test frameworks. It can also be used to create applications in Python (i.e. command-line tools).

## Use-cases
*  Maximizing development efficiency: i.e. a script to perform various operations every time an application is built and run (could be hooked into a Makefile or automated build system etc...).
*  Automated testing: [Testing Production Programming tools on nRF5 using pynrfjprog](https://github.com/NordicSemiconductor/nrf52-production-programming/blob/master/tests/example_test_script.py).

## Dependencies
* [SEGGER JLink DLL] (https://www.segger.com/jlink-software.html)
* (Windows-only) [Microsoft Visual C++ Redistributable] (https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist)

## Structure
```pynrfjprog
pynrfjprog
  ├── pynrfjprog
  │     ├──__init__.py    # Package marker to make pynrfjprog a module. Also defines the version number
  │     ├── API.py        # (Deprecated; included only for backwards compatibility) Alias for LowLevel.py
  │     ├── APIError.py   # Wrapper for the error return codes of the DLL
  │     ├── Hex.py        # (Deprecated; included only for backwards compatibility) Hex parsing library
  │     ├── HighLevel.py  # (Deprecated; included only for backwards compatibility) Wrapper for the nrfjprog highlevel DLL
  │     ├── JLink.py      # (Deprecated; included only for backwards compatibility) Finds the JLinkARM DLL
  │     ├── LowLevel.py   # Wrapper for the nrfjprog DLL, previously API.py
  │     ├── MultiAPI.py   # Allow multiple devices (up to 128) to be programmed simultaneously with a LowLevel API
  │     ├── lib_armhf
  │     │   └── # armhf nrfjprog libraries
  │     ├── lib_x64
  │     │   └── # 64-bit nrfjprog libraries
  │     ├── lib_x86
  │     │   └── # 32-bit nrfjprog libraries
  │     ├── docs
  │     │   └── # Header files of the nrfjprog DLL to provide in-depth documentation of the functions that are wrapped
  │     └── examples
  │         └── # Example scripts to show off the different APIs
  ├── LICENSE
  ├── README.md
  ├── requirements.txt
  └── pyproject.toml
```

## Getting started
To install the latest release from PyPI:
```
python -m pip install pynrfjprog
```
To install from source:
```
python -m pip install path_to_unzipped_pynrfjprog
```
Open the Python interpreter and connect nRF device to PC:
```
from pynrfjprog import LowLevel

with LowLevel.API('NRF52') as api:
    api.enum_emu_snr()
    api.connect_to_emu_without_snr()
    api.erase_all()
    api.write_u32(ADDRESS, DATA, IS_FLASH)
    api.disconnect_from_emu()
```

To work with multiple nRF devices at once:
```
import LowLevel

api = LowLevel.API('NRF52')
api.open()

api2 = LowLevel.API('NRF52')
api2.open()

api3 = LowLevel.API('NRF52')
api3.open()

api.close()
api2.close()
api3.close()
```

To program firmware into the devices:
```
from pynrfjprog import LowLevel

with LowLevel.API() as api:
    api.program_file(<hex_file>)

    # Optional
    api.verify_file(<hex_file>)
```

## Contributing
Contributing is encouraged along with the following coding standards.
* [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
* http://www.clifford.at/style.html
* [Semantic versioning](http://semver.org/)
