From 708403bbda75e286b6317418a2a216f4849b9690 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Wed, 20 Mar 2024 23:05:24 +0100 Subject: [PATCH] Initialize progress reporting for avr_{read,write}_mem Both these functions deliberately do not initiate progress reporting, but rather leave it up to their callers to do so. For the Python wrapper, there is no explicit caller, so abuse the "check" typemap to inject the respective code. --- src/libavrdude.i | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libavrdude.i b/src/libavrdude.i index 7bb55cde..4096ef51 100644 --- a/src/libavrdude.i +++ b/src/libavrdude.i @@ -533,12 +533,27 @@ PROGRAMMER *locate_programmer_set(const LISTID programmers, const char *id, cons PROGRAMMER *locate_programmer_starts_set(const LISTID programmers, const char *id, const char **setid, AVRPART *prt); PROGRAMMER *locate_programmer(const LISTID programmers, const char *configid); +// Abuse the check typemaps to inject some code into the wrapper + +// avr_read_mem() and avr_write_mem() do not initialize progress +// reporting, since this is left to the caller. The idea is that in +// some situations (e.g. signature readout), no progress reporting is +// desired. Thus, we inject the respective progress reporting +// initialization here into the wrapper functions. +%typemap(check) AVRMEM *mem { + report_progress(0, 1, "Reading"); +} %feature("autodoc", "avr_read_mem(PROGRAMMER pgm, AVRPART p, AVRMEM mem, AVRPART v=None -> int; v: verify against") avr_read_mem; int avr_read_mem(const PROGRAMMER * pgm, const AVRPART *p, const AVRMEM *mem, const AVRPART *v = NULL); +%clear AVRMEM *mem; +%typemap(check) AVRMEM *mem { + report_progress(0, 1, "Writing"); +} %feature("autodoc", "avr_write_mem(PROGRAMMER pgm, AVRPART p, AVRMEM mem, int size, int auto_erase) -> int; write entire memory region from `mem` buffer") avr_write_mem; int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, int size, int auto_erase = false); +%clear AVRMEM *mem; %feature("autodoc", "avr_write_byte(PROGRAMMER pgm, AVRPART p, AVRMEM mem, int addr, byte data) -> int") avr_write_byte; int avr_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,