lykahb / neotools

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

Can't get this to work on Manjaro Plasma. #3

Closed HookPro1 closed 3 years ago

HookPro1 commented 3 years ago

This may very well be an ID10T error as, like the folks posting in the Alphasmart forum, I am a Linux noob,, It just doesn't seem to work for me, either with the rules file. Without using sudo, I get the access denied error. With sudo I get a strange "module not there" error. I give you the screen dump for each below.

I am sure I have Python 3 (3,9,x...) and I am a member of the plugdev group. I copy and pasted the rules from github here, called the file 50-alphsmart.rules and put it in /lib/udev/rules.d, I have Neotools in lib/bin in my home directory. And, yes, the Neo is connected and showing the expected "Attached to PC..." message.

Here in my Linux setup: Operating System: Manjaro Linux KDE Plasma Version: 5.22.3 KDE Frameworks Version: 5.84.0 Qt Version: 5.15.2 Kernel Version: 5.10.52-1-MANJARO (64-bit) Graphics Platform: X11 Processors: 4 × Intel® Core™ i5-3320M CPU @ 2.60GHz Memory: 7.5 GiB of RAM Graphics Processor: Mesa DRI Intel® HD Graphics 4000

When I type the cli command "neotools files read 1" I get: neotools files read 1 Traceback (most recent call last): File "/home/hook/.local/bin/neotools", line 8, in sys.exit(cli()) File "/home/hook/.local/lib/python3.9/site-packages/click/core.py", line 1137, in call return self.main(args, kwargs) File "/home/hook/.local/lib/python3.9/site-packages/click/core.py", line 1062, in main rv = self.invoke(ctx) File "/home/hook/.local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/hook/.local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/hook/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/hook/.local/lib/python3.9/site-packages/click/core.py", line 763, in invoke return __callback(args, kwargs) File "/home/hook/.local/lib/python3.9/site-packages/neotools/cli.py", line 120, in read_file commands.read_file(applet_id, file_name_orspace, path, format) File "/home/hook/.local/lib/python3.9/site-packages/neotools/commands.py", line 18, in new_func result = f(*args, *kwargs) File "/home/hook/.local/lib/python3.9/site-packages/neotools/commands.py", line 87, in read_file with Device.connect() as device: File "/usr/lib/python3.9/contextlib.py", line 117, in enter return next(self.gen) File "/home/hook/.local/lib/python3.9/site-packages/neotools/device.py", line 35, in connect device.init(flip_to_comms) File "/home/hook/.local/lib/python3.9/site-packages/neotools/device.py", line 54, in init if self.dev.is_kernel_driver_active(0): File "/home/hook/.local/lib/python3.9/site-packages/usb/core.py", line 1107, in is_kernel_driver_active self._ctx.managed_open() File "/home/hook/.local/lib/python3.9/site-packages/usb/core.py", line 113, in wrapper return f(self, args, kwargs) File "/home/hook/.local/lib/python3.9/site-packages/usb/core.py", line 131, in managed_open self.handle = self.backend.open_device(self.dev) File "/home/hook/.local/lib/python3.9/site-packages/usb/backend/libusb1.py", line 804, in open_device return _DeviceHandle(dev) File "/home/hook/.local/lib/python3.9/site-packages/usb/backend/libusb1.py", line 652, in init _check(_lib.libusb_open(self.devid, byref(self.handle))) File "/home/hook/.local/lib/python3.9/site-packages/usb/backend/libusb1.py", line 604, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

When I type in my terminal "sudo neotools files read 1", after typing in my password, I get:

Traceback (most recent call last): File "/home/hook/.local/bin/neotools", line 5, in from neotools.cli import cli ModuleNotFoundError: No module named 'neotools'

Any help would be greatly appreciated. Thanks.

dutchg commented 3 years ago

This is Mark (Dutch) from the Flickr Alphasmart group. I'm getting results very much like Hook's (above). I've not tried implementing the "50 rules" piece because I don't understand how to do that. Will be checking in here to follow the discussion. Thanks! FWIW, I'm running Ubuntu 20.04.2 LTS

lykahb commented 3 years ago

Thank you for the report. Getting USB work is tricky for all Python programs. Let's check everything that could go wrong.

Did you reboot after adding the 50-alphasmart.rules file? What command did you use to install neotools? Also, can you run these commands and post the output?

Check that the rules file was created correctly

$ ls -l /lib/udev/rules.d/50-alphasmart.rules
The output should have user, group and permissions as below:
-rw-r--r-- 1 root root 226 Mar 29 21:09 /lib/udev/rules.d/50-alphasmart.rules

Then check if the user is a member of plugdev.

$ groups
Example output:
boris adm cdrom sudo dip plugdev lpadmin lxd sambashare vboxusers wireshark

If plugdev is not in the list, run sudo useradd -G plugdev YOUR_USERNAME. In my case, that's sudo useradd -G plugdev boris.

@dutchg the easiest way to make that file is to run sudo gedit /lib/udev/rules.d/50-alphasmart.rules. It would open a text editor. Paste the rules in there and save, then reboot.

HookPro1 commented 3 years ago

So, I did reboot after installing the rules file, but as is too typical for former Windows users, I named the rule file with an upper case A on alphasmart. (ID10T, I told you) So I corrected that and rebooted again and checked the readout with the ls command and it looked fine. Still doesn't work.

So I checked my groups with the groups command. plugdev isn't there. I thought I had created it using sudo groupadd -f plugdev. However, it isn't listed. So I did the useradd command you posted and it just comes back and says : useradd: user 'hook' already exists and still no plugdev in the list of groups.

What am I missing?

dutchg commented 3 years ago

Success! Boris, this is terrific! I had to go through your additional steps a couple of times to correct my own errors, and now it's working beautifully. Thanks so much for creating this, and for your help today.

Hook, by sheer good fortune, I was already a member of plugdev on my system, so I can't help you with that wrinkle. I suspect, though, that once you're over that bump you'll be in good shape. Do let me know, if you would. This is a very cool and funcitonal piece of kit for my setup.

HookPro1 commented 3 years ago

Okay, so I issued the following command:

getent group | awk -F : '{print $1}'

and it shows a list of all the groups on the system and plugdev IS in the list. So, what's going wrong when I try to add myself to the group?

Thanks for all your effort on this, Boris.

lykahb commented 3 years ago

@dutchg I'm glad that it works for you, thanks for the kind words.

@HookPro1 The upper-case file should be fine. The system should pick up any .rules files in that directory.

I am not familiar with the Manjaro distribution which is based on Arch Linux. My advice is for the Debian-based systems like Ubuntu that come with plugdev. It is not clear if your user is in the group. What is the output of groups (without sudo)? It shows the groups of your current user.

Also, there is a discussion on a similar problem here https://wiki.archlinux.org/title/Talk:Udev#Use_of_.27uaccess.27_instead_of_GROUP_and_MODE.3F

If adding your user to plugdev doesn't work, try this variant of file (with reboot):

ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="081e", ATTRS{idProduct}=="bd01", TAG+="uaccess"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="081e", ATTRS{idProduct}=="bd04", TAG+="uaccess"
HookPro1 commented 3 years ago

Woo Hooo. The new file (and reboot) worked! Thank you so much! And thank you for your patience. A great contribution to the community.
John (H0ok at Flickr)