Skip to content

Performance #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Performance #13

wants to merge 3 commits into from

Conversation

userid0x0
Copy link
Contributor

Some further improvements

  1. use binary data transmission from the Python script
  2. remove sleep directives
    Result: Read Performance +30%, Write Performance (+80%)

userid0x0 and others added 3 commits April 10, 2019 18:11
sync with nfd/spi-flash-programmer
switch read to binary data transmission (read 30% better read performance)
swith write to binary data transmission
  serial connection has a 1 second timeout
  implementation does 3 tries anyway -> 3 seconds timeout
  write performane +80%
@userid0x0
Copy link
Contributor Author

I am open for a discussion.

@nfd
Copy link
Owner

nfd commented Apr 18, 2019

I like the idea and I'm glad you left the option to read and write using hex in there, but _readPageBinary and _writePageBinary are very similar to _readPage and _writePage -- and those themselves are pretty complex functions, so that's quite a bit of copy paste code. Is there any way to clean that up by extracting the common code?

Also, I'm not in a position to test at the moment, but I think at least the first sleep() (for the bootloader) is required for some boards. Were you able to test on some of the older Arduinos, e.g. a Diecimila?

@userid0x0
Copy link
Contributor Author

Yes, readPage/writePage and the binary implementations contain lots of duplicate code. I will rework that.

Thanks for the note with 'Diecimila' I wasn't aware of that. Let me dig into the implementation of the reset via DTR. I will do some research if disabling the DTR signal is sufficient or not.

@nfd
Copy link
Owner

nfd commented Apr 25, 2019

Thanks, much appreciated! I've just moved and won't have my things for a few weeks, so unfortunately I'm not much help at the moment. :(

@userid0x0
Copy link
Contributor Author

It looks like the first wait may be required to keep compatibility with older boards.
According to
https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.open
there might be a short glitch on DTR when opening the port.
I checked the following sequence

#self.sock = serial.Serial(port, baud_rate, timeout=1)
#sequence to disable DTR when opening the port
self.sock = serial.Serial()
self.sock.baudrate = baud_rate
self.sock.port = port
self.sock.timeout = 1
self.sock.dsrdtr = False
self.sock.dtr = False
self.sock.open()`

Using a borrowed Diecimila clone of a friend I can perfectly reproduce the glitch. The first time the port is opened the board gets a reset. The second and following times not. So it looks like we need to keep the wait as described on
https://www.arduino.cc/en/Main/ArduinoBoardDiecimila
Section Automatic (Software) Reset.
Thanks for the hint. I will rework my optimizations in read/writePage later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants