App GpioShutdownService for C2 / N2 / C4 / XU

jwilson
Posts: 26
Joined: Tue Feb 27, 2018 2:00 pm
languages_spoken: english
ODROIDs: C2, XU4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by jwilson »

Thank you for your prompt response.

I've been reading up wiringPi and trying to understand what you mean by
you need to put the pin number in wiringPi format
. The only thing I know so far is that the GPIO number for pin 29 is 228. Any tips on how the wiringPi format would look like in the 'Shutdown Pin'?

Appreciate the help.

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

I see, the 228 is the number of the pin when it is used by sysfs. I initiate the wiringPi in normal mode and not in sysfs mode. Hence the numbering is different. The wpi number of pin 29 is 21. You can see this relation on the wiki pages of Odroid C2: https://wiki.odroid.com/odroid-c2/hardw ... connectors
I used it this way because the wpi numbers usually stay the same over different odroid models, the sysfs numbers not.
These users thanked the author joerg for the post:
jwilson (Tue Aug 11, 2020 3:22 am)

jwilson
Posts: 26
Joined: Tue Feb 27, 2018 2:00 pm
languages_spoken: english
ODROIDs: C2, XU4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by jwilson »

Hm, so I tried setting the 'Shutdown Pin' to 21 (having read it in your first reply), but I couldn't get it to work. I have a push button switch (NO) connected to pins 29 and 30. I configured 21 in settings, then exited the app by clicking on the < icon on the top. Then pressed the button and nothing happens. The same switch works fine on Linux so I know the switch isn't bad. I also checked under SuperUser and ensured this app is listed there.

jwilson
Posts: 26
Joined: Tue Feb 27, 2018 2:00 pm
languages_spoken: english
ODROIDs: C2, XU4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by jwilson »

Ok I take that back. It does work, I had to change the shutdown delay to 0 to realize it was working. I didn't realize that the pins need to remain shorted (at least for the duration of the 'Shutdown Delay') for the shutdown to activate. I was simply pressing and releasing the push button and that wouldn't activate the shutdown when I had it set to a higher value.

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

OK. fine that it works. Initially the app was developed for use in car with the ignition wire that changes to constantly low when the car is switched off.
If you want only a short press, then you can use also the Extra Pin and Extra Action functions and put as action any command that can be given at the adb console, e.g 'reboot -p'.

jwilson
Posts: 26
Joined: Tue Feb 27, 2018 2:00 pm
languages_spoken: english
ODROIDs: C2, XU4
Has thanked: 1 time
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by jwilson »

Actually, I'm totally fine the way it works currently. I've set the delay to 3000, this way an accidental press won't poweroff the device. What would be great is if the app could set the wakeup gpio, as it does in Linux. That said, this app is life saver. The alternative is to download entire Android source code, then change one word in the DTS file and recompile.

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

jwilson wrote:
Tue Aug 11, 2020 3:51 am
The alternative is to download entire Android source code, then change one word in the DTS file and recompile.
Sadly it is like that. The wake up is managed by uboot and it need this devicetree setting and also the variable in boot.ini. I cannot modify the devicetree with my app to make it work more comfortably.
But you don't need to download whole Android source. Simply download the image for fastboot flashing and get the default devicetree. Then you can modify it:

Code: Select all

$ fdtget meson64_odroidc2.dtb /gpio_keypad status
disabled
$ fdtput -t s  meson64_odroidc2.dtb /gpio_keypad status okay
$ fdtget meson64_odroidc2.dtb /gpio_keypad status
okay
And finally flash it with fastboot.

kouklo
Posts: 35
Joined: Wed Jun 26, 2019 9:53 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by kouklo »

@joerg Do you think it's possible to modify your app to work with USB instead of just GPIO? I know the app Tasker can do something similar to this. When the car turns off/on the PSU sends some sort of "ping" or keyboard short cut through the USB that's plugged into it. Your app sees that incoming signal and starts the shut down/sleep process in some sort of terminal.

I would much rather use your app than Tasker because 1st your a cool guy and I love your work and second, Tasker can be a pain in the butt to use. LOL

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

Maybe yes, I have to check this. I dealed already with usb time ago for another app.
But I need to find time for it. At the moment I am busy with setting up the N1 with new Debian, OMV5 and Nextcloud.

kouklo
Posts: 35
Joined: Wed Jun 26, 2019 9:53 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by kouklo »

joerg wrote:
Sun Nov 15, 2020 5:50 am
Maybe yes, I have to check this. I dealed already with usb time ago for another app.
But I need to find time for it. At the moment I am busy with setting up the N1 with new Debian, OMV5 and Nextcloud.
So I'm actually working with someone right now to make a universal "smart" power supply that will work with any SBC on the market. It will have 12V input and 3V, 5V, 12V output. We are working to get SUPER clean power out of it (especially important for audio). What makes this car PSU "smart" is when it senses that the car is on/off it sends a keyboard shortcut/ping using USB to whatever it's plugged into.
Obviously, keyboard shortcuts are easy for Windows and (I think for) Linux/Ubuntu but it's a completely different issue for Android as I'm sure you know. Our biggest problem right now is getting Android to sleep/shut down with just some simple keystrokes.

User avatar
mad_ady
Posts: 9681
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 609 times
Been thanked: 721 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by mad_ady »

If you can send the KEYCODE_POWER (https://developer.android.com/reference ... CODE_POWER) I think it should work directly.

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

@mad_ady: Yes, one can send this code from command line. But I think what @kouklo is refering to, is to have his power supply connected to the sbc by usb and send via this connection the command.
That would be possible if the controller of this power supply emulates a hid keyboard on his usb interface. When Android knows this vid/pid and starts the keyboard driver, then the controller can send this keycode.
This would shutdown immediately.
But also would be possible to connect from my app with libusb to this controller and read commands and do a delayed shutdown. This delayed shutdown is something that makes interesting using my app.
In my car I use it with 10min delay, so I can take petrol , go paying and come back and the C4 is already there, no need to boot up again.

kouklo
Posts: 35
Joined: Wed Jun 26, 2019 9:53 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by kouklo »

joerg wrote:
Sun Nov 15, 2020 11:48 pm
@mad_ady: Yes, one can send this code from command line. But I think what @kouklo is refering to, is to have his power supply connected to the sbc by usb and send via this connection the command.
That would be possible if the controller of this power supply emulates a hid keyboard on his usb interface. When Android knows this vid/pid and starts the keyboard driver, then the controller can send this keycode.
This would shutdown immediately.
But also would be possible to connect from my app with libusb to this controller and read commands and do a delayed shutdown. This delayed shutdown is something that makes interesting using my app.
In my car I use it with 10min delay, so I can take petrol , go paying and come back and the C4 is already there, no need to boot up again.
That's exactly what I'm talking about bro!! Please don't think I'm trying to pressure you into stoping everything and working on this, I'm just curious if it's even possible. For all I know my idea is just a stupid fantasy. You got to admit tho, it's an interesting idea. Heck, if I decide to bring my PSU to market I might even work with you on integrating the app into the hardware somehow. LOL

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

Don't worry.
If I have time and like to do it, I will do it. ;)

zyssai
Posts: 190
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 60 times
Been thanked: 23 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by zyssai »

Hi joerg.
I followed your instructions on the last page for using your app with tasker.
I bought macrodroid app few months ago, it's similar to tasker.
But i'm not able to receive detailled event.

First, do you need to put something into Extra1Action?
I leaved it empty.

Image

Second, i don't know what to enter in the Intent Extra field.
If i leave it empty, Macrodroid receive correctly event but don't know what gpio it was (i need to use multiples one)
Image

Image
As you can see i setup a popup, defined permanent int variables but they stays empty.

Hope you have some time to help me

misha
Posts: 1
Joined: Mon Mar 01, 2021 4:58 am
languages_spoken: english
ODROIDs: C1+
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by misha »

Hi @joerg
Is it possible to upload a version that works with Odroid C1. I tried 1.8.0 but it is probably for a newer android version and it cannot be installed. On my Odroid C1 I use Android 4.4, unfortunately the newer version of android is not stable on C1.

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

@misha, can you this version I found in my C1 folder:
GpioShutdownService-1.5.1.zip
(1.12 MiB) Downloaded 19 times
I haven't tried for years on C1. :?

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

@zyssai, I think you need to put the string gpio in Extra Name and the number of GPIO in Extra value to match. I am not familar with macrodroid. Can you add an additional Extra? Then you can put string value in Extra Name and 0 or 1 in Extra value to match.
In my app you can leave the ExtraX Action empty. When the ExtraX Pin setting is filled, a intent will be fired every value change of this GPIO, with extras "gpio":x[Integer] and "value":x[Integer].
Hope it helps.

zyssai
Posts: 190
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 60 times
Been thanked: 23 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by zyssai »

Ok thanks for your answer, i will try this week and let you know if it worked.

zyssai
Posts: 190
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 60 times
Been thanked: 23 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by zyssai »

I understood how it works, thanks for your help

Image
Image

Image
Image

As you have explained to me, i must create extra with gpio and the wpi number of the pin, and optionally an extra with value of the pin.

Just a thing, how is working holdpower pin? 23 is wpi or physical number of pin? I need to apply 3.3v, and if it stopped, odroid is shutted down?

Thanks again for your great app!

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

Holdpower is an output. It's wpi number. Please do not apply voltage, this could destroy destroy your board.
These users thanked the author joerg for the post:
zyssai (Mon Mar 08, 2021 7:38 pm)

zyssai
Posts: 190
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 60 times
Been thanked: 23 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by zyssai »

Hi joerg,
I'm using all the extra pins. Everything is working perfectly with N2+.
However I need to add 2 more ones.
Can I hope an update of the app? Or is it hardware limited?
Thanks!

User avatar
joerg
Posts: 1372
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 92 times
Been thanked: 210 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

Hi @zyassi, sure I can add 2 more. Give me some days...Need to update the app to latest AndroidStudio and add some more functionality...

zyssai
Posts: 190
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 60 times
Been thanked: 23 times
Contact:

Re: App GpioShutdownService for C2 / N2 / C4 / XU

Post by zyssai »

joerg wrote:
Mon Sep 20, 2021 12:09 am
Hi @zyassi, sure I can add 2 more. Give me some days...Need to update the app to latest AndroidStudio and add some more functionality...
I must say that i didn't thought it was possible. It's incredible, thanks you!! ;)
And, take your time!!!

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 6 guests