[Iconnect] how can I use the front button (OTB button)?

Install Arch Linux ARM on other devices.

[Iconnect] how can I use the front button (OTB button)?

Postby minscof » Sat Jan 14, 2012 5:18 pm

Hi,

I have installed archlinux on my iconnect device with the methode decribed in this post viewtopic.php?f=27&t=1472

and then, I have replaced the kernel by a new one to get the LED recognized : kernel3.0.9 downloaded from this site
http://www.kroonen.eu/wiki/Downloads

Now, I would like using the OTB (one-touch backup) Button of the iconnect to reboot it. I can't find messages in the kernel log that show this button is recognized and I have no input entry on /sys/devices/platform/gpio-keys.

Does it mean I have to get another kernel ?

can someone help me ?
Thanks
minscof
 
Posts: 8
Joined: Sun Dec 04, 2011 10:03 am

Re: [Iconnect]how can I use the front button (OTB button)?

Postby kmihelich » Sat Jan 14, 2012 8:05 pm

The package 'linux' in our repository has support for the iConnect Wireless.
Arch Linux ARM exists and continues to grow through community support, please donate today!
kmihelich
Developer
 
Posts: 1133
Joined: Tue Jul 20, 2010 6:55 am
Location: aka leming #archlinuxarm

Re: [Iconnect]how can I use the front button (OTB button)?

Postby pazos » Tue Jan 24, 2012 8:55 am

I can confirm that OTB Button works in stock archlinuxarm kernel (with arcNumber = 2870 ). I use a python script to listen at /dev/input/event0 and run a custom shell script when the button is pushed.

$this->bbcode_second_pass_code('', '
# Iomega Iconnect OTB Button
# <pazos@lavabit.com>
#
# a silghty modified version of:
#
# Beagleboard user button
# Copyright 2009 mechomaniac.com
# http://mechomaniac.com/BeagleboardUserButton

import struct
import os

inputDevice = "/dev/input/event0"
inputEventFormat = 'iihhi'
inputEventSize = 16
file = open(inputDevice, "rb")
event = file.read(inputEventSize)

while event:
(time1, time2, type, code, value) = struct.unpack(inputEventFormat, event)
if type == 5 and code == 1 and value == 1: # tested in ArchLinuxArm (OTB Button)
os.system("otb-script.sh") # runs the script if it is found in PATH
event = file.read(inputEventSize)
file.close()
')

I imagine that it can work if you simply change the script line to $this->bbcode_second_pass_code('', 'os.system("reboot")')
pazos
 
Posts: 21
Joined: Thu Aug 04, 2011 2:35 pm

Re: [Iconnect]how can I use the front button (OTB button)?

Postby dennisb1 » Fri Mar 23, 2012 8:17 am

Hello

Im new to this and i just have a few days my own iConnect with linux.
But how can i use that script with a so called python script where i have no idea how to make that to listen and use that script i have uploaded to my box.

Thx!
dennisb1
 
Posts: 7
Joined: Fri Mar 23, 2012 8:16 am

Re: [Iconnect]how can I use the front button (OTB button)?

Postby pazos » Fri Mar 23, 2012 1:04 pm

hi dennisb1! the python script read the state of /dev/input/event0 looking for OTB button push (or for reset button push if you code it). Of course it needs to be run on the boot and in the background.

I put the script in /usr/share/scripts/otb-button.py and add this line to my rc.local file:

/usr/share/scripts/otb-button >/dev/null 2>&1&

the other script (in my caser otb-script) is called when the button is pressed. It must be on the path to work. I copy it to /usr/local/bin/otb-script. You can add whatever you want to do to this script. A example usb mount/umount script (i'm running linux from nand) could be:

#!/bin/sh
device=/dev/sda1
if eval "mount | grep $device >/dev/null 2>&1"; then
umount $device # the device is mounted, we are going to unmount it
else
mount $device # you will need to declare this device on fstab or
# using mountpoint=/some/path; mount $device $mountpoint
fi

this is the simpliest way of getting buttons working.
pazos
 
Posts: 21
Joined: Thu Aug 04, 2011 2:35 pm

Re: [Iconnect] how can I use the front button (OTB button)?

Postby dennisb1 » Fri Mar 23, 2012 2:30 pm

Thank you for your reply pazos!!

I will add later when im home this to my rc.local
I got my linux on my usb disk but wont this script that is running take a lot of read writes on my usb stick?

I have permently mounted a second harddisk as sdb1 for download stuff. and the usb stick is mounted as sda1 i guess.
dennisb1
 
Posts: 7
Joined: Fri Mar 23, 2012 8:16 am

Re: [Iconnect] how can I use the front button (OTB button)?

Postby dennisb1 » Tue Mar 27, 2012 6:32 am

Pazos,

I have just done the script and gave it chmod 777 to be sure it will works.
I have added that line /usr/share/scripts/otb-button >/dev/null 2>&1& to my rc.local and rebooted.
But... it dont work.. When i put this /usr/share/scripts/otb-button >/dev/null 2>&1& command on the console it will start but will exit in 1 second.

What can i do tho fix this?

Regards,
Dennis
dennisb1
 
Posts: 7
Joined: Fri Mar 23, 2012 8:16 am

Re: [Iconnect] how can I use the front button (OTB button)?

Postby tomcheng76 » Tue Mar 27, 2012 7:26 am

$this->bbcode_second_pass_quote('dennisb1', 'P')azos,

I have just done the script and gave it chmod 777 to be sure it will works.
I have added that line /usr/share/scripts/otb-button >/dev/null 2>&1& to my rc.local and rebooted.
But... it dont work.. When i put this /usr/share/scripts/otb-button >/dev/null 2>&1& command on the console it will start but will exit in 1 second.

What can i do tho fix this?

Regards,
Dennis


ps aux |grep "otb-button"
you may see it is running, to debug, just run the command in foreground like this
/usr/share/scripts/otb-button
tomcheng76
 
Posts: 130
Joined: Mon Dec 13, 2010 11:24 am

Re: [Iconnect] how can I use the front button (OTB button)?

Postby dennisb1 » Tue Mar 27, 2012 9:26 am

im sure its really exit because of the following

[1]+ Exit 2 /home/otb-button > /dev/null 2>&1
when i do ps ax right after it and when i do it again its gone again

This is what i get


root@iconnect:~# /home/otb-button
import: unable to open X server `' @ error/import.c/ImportImageCommand/362.
import: unable to open X server `' @ error/import.c/ImportImageCommand/362.
/home/otb-button: line 13: inputDevice: command not found
/home/otb-button: line 14: inputEventFormat: command not found
/home/otb-button: line 15: inputEventSize: command not found
/home/otb-button: line 16: syntax error near unexpected token `('
/home/otb-button: line 16: `file = open(inputDevice, "rb")'
dennisb1
 
Posts: 7
Joined: Fri Mar 23, 2012 8:16 am

Re: [Iconnect] how can I use the front button (OTB button)?

Postby pazos » Tue Mar 27, 2012 1:46 pm

Hello everybody!

If you wish to call the script using
/path/to/script/otb

then add: #!/usr/bin/env python at the top of the script...

else you can call the script directly with:

python /path/to/script/otb > /path/lo/log/otb.log 2>&1&
and look at your log file for errors or something like this :)

Have fun!!!
pazos
 
Posts: 21
Joined: Thu Aug 04, 2011 2:35 pm

Next

Return to [Please read announcement] Community-Supported Devices

Who is online

Users browsing this forum: No registered users and 11 guests