Modified the write with a hardcoded delay to avoid ack on every write.

This commit is contained in:
Mariano Uvalle 2020-12-13 14:40:42 -06:00
parent adc5e6a078
commit 81e30791b0
3 changed files with 29 additions and 11 deletions

View file

@ -245,8 +245,6 @@ void program() {
while(Serial.available() == 0);
value = Serial.read();
writeEEPROM(addr, value, true);
// Send ack.
Serial.write(value);
}
}

View file

@ -1,6 +1,7 @@
import argparse
import time
import serial
from tqdm import tqdm
def get_parsed_args():
@ -82,17 +83,19 @@ def program(args):
# Sending command
ser.write((0).to_bytes(1, "big"))
bytesToWrite = args.file.read()
bytes_to_write = args.file.read()
# Forward the bytes from the selected file
for i in range(32 * 1024):
# Show progress.
if i % 1024 == 0:
print(".", end="")
value = (bytesToWrite[i]).to_bytes(1, "big")
for i in tqdm(range(32 * 1024)):
value = (bytes_to_write[i]).to_bytes(1, "big")
ser.write(value)
if value != ser.read():
# There was an error with the ack, finish early.
break
# This delay was found by experimentation.
# A byte write in the arduino takes about 80us.
# Every 64 bytes (a page) we do data polling and could
# take much longer. A byte send given a 115200 baud rate
# should take ~70us, a 100us delay should give the EEPROM enough time
# to internally write the page withouh the UART read buffer (64 bytes)
# overflowing.
time.sleep(100.0 * 1e-6)
print("Done programming!")

17
cli/requirements.txt Normal file
View file

@ -0,0 +1,17 @@
appdirs==1.4.4
astroid==2.4.2
isort==5.6.4
jedi==0.17.2
lazy-object-proxy==1.4.3
mccabe==0.6.1
mypy-extensions==0.4.3
parso==0.7.1
pathspec==0.8.1
pylint==2.6.0
pyserial==3.5
rope==0.18.0
six==1.15.0
toml==0.10.2
tqdm==4.54.1
typing-extensions==3.7.4.3
wrapt==1.12.1