Skip to content

Commit

Permalink
Merge pull request #16 from amarkevich/master
Browse files Browse the repository at this point in the history
README.md: replace deprecated API usage; use 'with' block
  • Loading branch information
simtind authored Sep 10, 2021
2 parents 8bdced5 + fb216fa commit ef6ce47
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ python setup.py install
```
Open the Python interpreter and connect nRF5 device to PC:
```
from pynrfjprog import API
api = API.API('NRF52')
api.open()
api.enum_emu_snr()
api.connect_to_emu_without_snr()
api.erase_all()
api.write_u32(ADDRESS, DATA, IS_FLASH)
api.disconnect_from_emu()
api.close()
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 nRF5 devices at once:
Expand All @@ -98,25 +96,20 @@ To program hex files using the HighLevel API:
```
from pynrfjprog import HighLevel
api = HighLevel.API()
api.open()
# To program J-Link probe at snr <snr>:
probe = HighLevel.DebugProbe(api, <snr>)
probe.program(<hex_file>)
probe.close()
with HighLevel.API() as api:
snrs = api.get_connected_probes()
# To program MCUBoot target at serial port <serial>:
probe = HighLevel.MCUBootDFUProbe(api, <serial>)
probe.program(<hex_file>)
probe.close()
# To program J-Link probe at snr <snr>:
with HighLevel.DebugProbe(api, <snr>) as probe:
probe.program(<hex_file>)
# To update LTE modem connected to J-Link prbe at snr <snr>:
probe = HighLevel.IPCDFUProbe(api, <snr>)
probe.program(<hex_file>)
probe.close()
# To program MCUBoot target at serial port <serial>:
with HighLevel.MCUBootDFUProbe(api, <serial>) as probe:
probe.program(<hex_file>)
api.close()
# To update LTE modem connected to J-Link probe at snr <snr>:
with HighLevel.IPCDFUProbe(api, <snr>, HighLevel.CoProcessor.CP_MODEM) as probe:
probe.program(<zip_file>, HighLevel.ProgramOptions(verify = HighLevel.VerifyAction.VERIFY_HASH))
```
Note: Only one HighLevel API can be instantiated and opened at a time. But, several HighLevel probes can be opened from the same API at the same time, as long as you don't open two probes to the same target.

Expand Down

0 comments on commit ef6ce47

Please sign in to comment.