Skip to content
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

Green on Linux should check power saving status of Jade #89

Open
grubles opened this issue May 31, 2023 · 1 comment
Open

Green on Linux should check power saving status of Jade #89

grubles opened this issue May 31, 2023 · 1 comment

Comments

@grubles
Copy link

grubles commented May 31, 2023

On a more modern Linux such as Fedora, a default power saving config option prevents newer Jade units from being able to communicate with the Green app, causing it to crash. Older Jades are unaffected because they have a different serial chip.

We should query if the power saving feature is enabled or not and provide an alert to the user that points them to instructions (I'm thinking here is a good home) for how to install appropriate udev rules that disable this feature every time the Jade is plugged into the host machine.

To check if a Jade is plugged in we can look to see if /dev/ttyACM0 exists and then proceed to determining if power saving is enabled.

It's possible for a non-root user to query the state of the power saving feature, even when inside a Flatpak sandbox:

$ cat /sys/bus/usb/devices/1-2/power/control
auto

Note this path is dependent on the user's machine and is very likely to be different across different sets of hardware. But, we can (again, as non-root user) look in each device subdirectory for the idProduct and idVendor files which contain the product and vendor IDs and see if we can find Jade's:

$ pwd
/sys/bus/usb/devices

$ ls -la */idProduct*
-r--r--r--. 1 root root 4096 May 30 07:36 1-10/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 1-7/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 1-8/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 3-1/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb1/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb2/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb3/idProduct
-r--r--r--. 1 root root 4096 May 30 07:36 usb4/idProduct

$ cat 1-10/idProduct
01a2

This particular device is not Jade :(. On to the next one...

I've tested the udev rule below (placed in /etc/udev/rules.d/21-jade.rules) on a couple different Fedora machines successfully.

ATTRS{idProduct}=="55d4", ATTRS{idVendor}=="1a86", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="on"

This will turn off the power saving automatically any time a Jade is plugged in.

Older Linux distros like Ubuntu 22.04 do not enable the power saving OOTB and are unaffected by this, but future versions might. It's unclear if it's a difference between Linux kernel versions or their configs or if Ubuntu is intentionally turning this off and Fedora leaves it untouched, so it's a good idea to tackle this ahead of time.

@SmileyChris
Copy link

Thanks, that udev rule allowed me to finish setting up my jade on Manjaro (it would crash with SIGABRT after double entering the pin every time).

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

No branches or pull requests

2 participants