PacktPublishing / TinyML-Cookbook_2E

TinyML Cookbook, 2E_Published by Packt
MIT License
54 stars 24 forks source link

Chapter 2 02_serial_to_gdrive.py results in NameError: name 'elapsed' is not defined #1

Open jomoengineer opened 8 months ago

jomoengineer commented 8 months ago

The code in the Chapter 2 02_serial_to_gdrive.py will not work as written. The code will give the following error:

NameError: name 'elapsed' is not defined

The variable 'elapsed' should be elapsed_s Ex:

start_s   = time.time()
elapsed_s = 0
while(elapsed < max_time_s):
  text   += serial_readline(ser)
  end_s   = time.time()
  elapsed = end_s - start_s

Should be:

start_s   = time.time()
elapsed_s = 0
while(elapsed_s < max_time_s):
  text   += serial_readline(ser)
  end_s   = time.time()
  elapsed_s = end_s - start_s