lykahb / neotools

Command-line tools for AlphaSmart NEO
GNU General Public License v3.0
39 stars 7 forks source link

reads old version? #1

Closed egh closed 3 years ago

egh commented 3 years ago

Thanks so much for this tool! It seems like a much better solution than sending via the keyboard, which is quite slow.

However, I am finding that when attempting to read the text in file 8, I am getting an old version.

I'll look into the issue more, but I was curious if you had any ideas.

egh commented 3 years ago

I was wrong - it's not reading an old version, it's reading the wrong file.

I had a look at the code and I think the core problem is that, for some reason, my file indexes are not aligned with the space value. I made a small change

diff --git a/neotools/file.py b/neotools/file.py
index c36716b..76a4130 100644
--- a/neotools/file.py
+++ b/neotools/file.py
@@ -169,7 +169,7 @@ def list_files(device, applet_id):
         files.append(attrs)
         logger.debug('file listed file_index=%s attrs=%s', file_index, attrs)
         file_index = file_index + 1
-    files = sorted(files, key=lambda f: f.space)
+    # files = sorted(files, key=lambda f: f.space)
     return files

And you can see the files are out of order:

image

But the read code assumes that space is the same as index. (There is also a file at space 0, which the code assumes is impossible?) So the behavior I am seeing is that:

  1. The wrong file is read when I run neotools read file 8
  2. If I try to read the correct file, it is truncated, because the wrong attributes are read and not enough text is requested.

At least, that is what seems to me to be happening.

lykahb commented 3 years ago

Thank you for the PR. I also pushed a few more small improvements on top of your fix. Can you try out the recent master for a few days and see if there are any issues? If everything's fine, I'll release it.

egh commented 3 years ago

Can you try out the recent master for a few days and see if there are any issues?

Absolutely! Thanks for you work on this.