Code Monkey home page Code Monkey logo

Comments (13)

stefanrueger avatar stefanrueger commented on August 14, 2024

I suspect the corresponding m->tags[] bytes are not set.

(off-topic: I also suspect the python implementation/wrapper of progress reporting does something else than the AVRDUDE progress reporting as I haven't seen the behaviour that "ing 0 %" is written for the latter.)

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

The progress indication is indeed quite simplified.
Who is responsible for setting the tags? (and how is it done? :)

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

As I've got that m->put method, it could certainly somehow handle setting the tags.

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

Who is responsible for setting the tags? (and how is it done? :)

Reading in a file for writing sets the tags (to manage holes in files in the Intel hex or Motorola S record format)

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

Yes, the progress reporter is a much simplified version in my test (it's a plain Python callback now).
I guess I have to assign m->tag[] in my m.put() helper then, yes.

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

Yep, works now:

>>> m=ad.avr_locate_mem(p, 'eeprom')
>>> ad.avr_read_mem(pgm, p, m)
Reading 100 %
512
>>> m.get(10)
b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
>>> m.put(b'The quick brown fox jumps over the lazy dog.')
44
>>> ad.avr_write_mem(pgm, p, m, 44)
Writing 100 %
44
>>> ad.avr_read_mem(pgm, p, m)
Reading 100 %
512
>>> m.get(44)
b'The quick brown fox jumps over the lazy dog.'

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

All is working.
Finally, I could also write back my previously saved flash contents from the test device:

>>> m=ad.avr_locate_mem(p, 'flash')
>>> with open("dump.bin","rb") as f:
...  b=f.read()
... 
>>> len(b)
8666
>>> m.put(b)
8666
>>> ad.avr_write_mem(pgm, p, m, 8666)
avrdude: padding flash [0x2180, 0x21ff]
Writing 100 %
8666

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

m.put and m.get are Python access methods to m->buf, accepting or returning Python bytes objects

m.put and m.get ought to take an address within buffer argument as well in order to provide random access to m->buf

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

They do, it is called offset. It just defaults to 0.

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

And for m.put, the length is taken from the input byte string, while for m.get, the length needs to be specified.

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

Remember, this is Python, we can have default values for arguments. :-) (The SWIG wrapper can handle them, even though the C backend functions cannot.)

from avrdude.

stefanrueger avatar stefanrueger commented on August 14, 2024

They do, it is called offset. It just defaults to 0.

Ahh, great.

Yes, the progress reporter is a much simplified version in my test (it's a plain Python callback now).

In order to support the logic of libavrdude progress reporting, the application-specific update_progress() functions should not do anything before a header was provided and they should stop updating on progress as soon as a terminating progress report call was issued. Basically, it's a logic that dances around

avrdude/src/term.c

Lines 2685 to 2686 in 34366a6

static char *header;
static int last, done = 1;

This needs documentation, and this could be provided at the same time when Issue #1721 is dealt with.

from avrdude.

dl8dtl avatar dl8dtl commented on August 14, 2024

I think the existing progress_callback in my Python test code works basically like that:

# very simplified progress callback
global prog_hdr
prog_hdr = ""
def progress_callback(percent: int, etime: float, hdr: str, finish: int):
    if hdr:
        global prog_hdr
        prog_hdr = hdr
    print(f"{prog_hdr} {percent:3d} %", end='\r', file=sys.stderr, flush=True)
    if (percent == 100):
        print("", file=sys.stderr)

But that's merely a simplified example right now. There's room for fine-tuning. :-)

from avrdude.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.