User:Morlac

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(hardware-switches for bash)
m (hardware-switches and misc for bash)
 
(6 intermediate revisions by one user not shown)
Line 1: Line 1:
== hardware-switches for bash ==
+
== hardware-switches and misc for bash ==
  
 
=== bt_hardware ===
 
=== bt_hardware ===
Line 89: Line 89:
 
                 ;;
 
                 ;;
 
         esac
 
         esac
 +
        ;;
 +
esac
 +
 +
exit 0
 +
 +
=== wifi_hardware ===
 +
(planned but not available yet)
 +
 +
=== bluetooth-gps-relay ===
 +
#!/bin/bash
 +
 +
# (c) Copyright 2009 Christian Adams <morlac@morlac.de>
 +
# GPL V2 or later
 +
 +
# set -x
 +
 +
HCITOOL="hcitool"
 +
HCITOOL_BIN=`which ${HCITOOL}`
 +
RFCOMM="rfcomm"
 +
RFCOMM_BIN=`which ${RFCOMM}`
 +
SDPTOOL="sdptool"
 +
SDPTOOL_BIN=`which ${SDPTOOL}`
 +
 +
test -x ${HCITOOL_BIN} || exit 0
 +
test -x ${RFCOMM_BIN} || exit 0
 +
test -x ${SDPTOOL_BIN} || exit 0
 +
 +
BT_ADDR=`${HCITOOL_BIN} dev |grep hci|awk '{print $2}'`
 +
 +
if [ "x${BT_ADDR}" == "x" ] ; then
 +
        echo "no bloutooth-device available - exiting"
 +
        exit 0
 +
fi
 +
 +
PID_FILE=/var/run/gps_relay.pid
 +
 +
CHANNEL="1"
 +
 +
PID=""
 +
test -f ${PID_FILE} && . ${PID_FILE}
 +
 +
do_start() {
 +
        if [ "x${PID}" == "x" ] ; then
 +
                echo "starting gps-bluetooth-relay on bt-channel 1"
 +
                ${SDPTOOL_BIN} add --channel ${CHANNEL} --handle 0x424242 SP
 +
 +
                ${RFCOMM_BIN} -r watch 0 ${CHANNEL} sh -c "gpspipe -r >/dev/rfcomm0" &
 +
                PID=$!
 +
 +
                echo "PID=${PID}" > ${PID_FILE}
 +
        else
 +
                echo "not starting - stale pidfile (${PID_FILE}) or allready running with pid ${PID}"
 +
        fi
 +
}
 +
 +
is_running() {
 +
        test -f ${PID_FILE} || return 0
 +
 +
        running=`ps x|grep ${PID}|awk '{print $5}'`
 +
        running=`echo $running|awk '{print $1}'`
 +
 +
        if [ "x${running}" == "x${RFCOMM_BIN}" ] ; then
 +
                return 1
 +
        fi
 +
 +
        return 0
 +
}
 +
 +
do_stop() {
 +
        is_running
 +
        if [ "x$?" == "x1" ] ; then
 +
                echo "stoping gps-bluetooth-relay .."
 +
                ${SDPTOOL_BIN} del 0x424242
 +
 +
                kill -9 ${PID}
 +
                rm ${PID_FILE}
 +
        else
 +
                echo "not running - not halting .."
 +
        fi
 +
}
 +
 +
case "${1}" in
 +
(start)
 +
        do_start
 +
        ;;
 +
(stop)
 +
        do_stop
 +
        ;;
 +
(restart)
 +
        do_stop
 +
        do_start
 +
        ;;
 +
(status)
 +
        is_running
 +
        if [ "x$?" == "x1" ] ; then
 +
                echo "gps-bluetooth-relay running"
 +
        else
 +
                echo "gps_bluetooth-relay not running"
 +
        fi
 
         ;;
 
         ;;
 
  esac
 
  esac
Line 100: Line 199:
 
mv /usr/bin/apm /usr/bin/apm.o and create new /usr/bin/apm as follows:<br>
 
mv /usr/bin/apm /usr/bin/apm.o and create new /usr/bin/apm as follows:<br>
  
/usr/bin/apm
+
=== /usr/bin/apm ===
 
  #!/bin/sh
 
  #!/bin/sh
 
  echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk
 
  echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk
Line 109: Line 208:
 
add link /etc/apm/event.d  (don't forget to chmod +x /etc/apm/scripts.d/sd_idleclk)
 
add link /etc/apm/event.d  (don't forget to chmod +x /etc/apm/scripts.d/sd_idleclk)
  
/etc/apm/scripts.d/sd_idleclk
+
=== /etc/apm/scripts.d/sd_idleclk ===
 
  #!/bin/sh
 
  #!/bin/sh
 
  SD_IDLECLK="/sys/module/glamo_mci/parameters/sd_idleclk"
 
  SD_IDLECLK="/sys/module/glamo_mci/parameters/sd_idleclk"
Line 137: Line 236:
 
http://wiki.openmoko.org/wiki/Lint-wifi<br />
 
http://wiki.openmoko.org/wiki/Lint-wifi<br />
 
http://hdr.meetr.de/neo/openmoko/battery<br />
 
http://hdr.meetr.de/neo/openmoko/battery<br />
 +
http://www.ohli.de/download/openmoko-panel-plugin_0.1-1_all.deb<br />
 +
New Images for panel-plugin: (and patch for panel-plugin to provide keyboard-toggle [[Media:Panel-plugin.patch.txt]])<br />
 +
[[Image:Panel-plugin_48x48_off.png]]
 +
[[Image:Panel-plugin_bt_0.png]]
 +
[[Image:Panel-plugin_bt_1.png]]
 +
[[Image:Panel-plugin_gps_0.png]]
 +
[[Image:Panel-plugin_gsm_0.png]]
 +
[[Image:Panel-plugin_matchbox-keyboard_0.png‎]]
 +
[[Image:Panel-plugin_matchbox-keyboard_1.png‎]]
 +
[[Image:Panel-plugin_wifi_0.png]]
 +
<br />
 
http://www.ohli.de/download/xserver-xorg-input-tslib_0.0.5-1+fso1_armel.deb<br />
 
http://www.ohli.de/download/xserver-xorg-input-tslib_0.0.5-1+fso1_armel.deb<br />
 
 
  Option          "EmulateRightButton"    "1"
 
  Option          "EmulateRightButton"    "1"
  

Latest revision as of 14:26, 27 January 2009

Contents

[edit] hardware-switches and misc for bash

[edit] bt_hardware

#!/bin/sh
BT_HW="/sys/bus/platform/devices/neo1973-pm-bt.0/power_on"
BT_RST="/sys/bus/platform/devices/neo1973-pm-bt.0/reset"

[ -e "${BT_HW}" ] || exit 0

case "${1}" in
(start)
       echo 1 > ${BT_HW}
       echo 0 > ${BT_RST}
       echo "BlueTooth-Hardware is now on"
       ;;
(stop)
       echo 0 > ${BT_HW}
       echo "BlueTooth-Hardware is now off"
       ;;
(status)
       BT_STATUS=`cat ${BT_HW}`
       case "${BT_STATUS}" in
       ("1")
               echo "BlueTooth-Hardware is on"
               ;;
       ("0")
               echo "BlueTooth-Hardware is off"
               ;;
       esac
       ;;
esac

exit 0

[edit] gps_hardware

#!/bin/sh
GPS_HW="/sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron"
[ -e "${GPS_HW}" ] || exit 0

case "${1}" in
(start)
       echo 1 > ${GPS_HW}
       echo "GPS-Hardware is now on"
       ;;
(stop)
       echo 0 > ${GPS_HW}
       echo "GPS-Hardware is now off"
       ;;
(status)
       GPSSTATUS=`cat ${GPS_HW}`
       case "${GPSSTATUS}" in
       ("1")
               echo "GPS-Hardware is on"
               ;;
       ("0")
               echo "GPS-Hardware is off"
               ;;
       esac
       ;;
esac

exit 0

[edit] gsm_hardware

#!/bin/sh
GSM_HW="/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on"

[ -e "${GSM_HW}" ] || exit 0

case "${1}" in
(start)
       echo 1 > ${GSM_HW}
       echo "GSM-Hardware is now on"
       ;;
(stop)
       echo 0 > ${GSM_HW}
       echo "GSM-Hardware is now off"
       ;;
(status)
       GSM_STATUS=`cat ${GSM_HW}`
       case "${GSM_STATUS}" in
       ("1")
               echo "GSM-Hardware is on"
               ;;
       ("0")
               echo "GSM-Hardware is off"
               ;;
       esac
       ;;
esac

exit 0

[edit] wifi_hardware

(planned but not available yet)

[edit] bluetooth-gps-relay

#!/bin/bash

# (c) Copyright 2009 Christian Adams <morlac@morlac.de>
# GPL V2 or later

# set -x

HCITOOL="hcitool"
HCITOOL_BIN=`which ${HCITOOL}`
RFCOMM="rfcomm"
RFCOMM_BIN=`which ${RFCOMM}`
SDPTOOL="sdptool"
SDPTOOL_BIN=`which ${SDPTOOL}`

test -x ${HCITOOL_BIN} || exit 0
test -x ${RFCOMM_BIN} || exit 0
test -x ${SDPTOOL_BIN} || exit 0

BT_ADDR=`${HCITOOL_BIN} dev |grep hci|awk '{print $2}'`

if [ "x${BT_ADDR}" == "x" ] ; then
       echo "no bloutooth-device available - exiting"
       exit 0
fi

PID_FILE=/var/run/gps_relay.pid

CHANNEL="1"

PID=""
test -f ${PID_FILE} && . ${PID_FILE}

do_start() {
       if [ "x${PID}" == "x" ] ; then
               echo "starting gps-bluetooth-relay on bt-channel 1"
               ${SDPTOOL_BIN} add --channel ${CHANNEL} --handle 0x424242 SP 

               ${RFCOMM_BIN} -r watch 0 ${CHANNEL} sh -c "gpspipe -r >/dev/rfcomm0" &
               PID=$! 

               echo "PID=${PID}" > ${PID_FILE}
       else
               echo "not starting - stale pidfile (${PID_FILE}) or allready running with pid ${PID}"
       fi
}

is_running() {
       test -f ${PID_FILE} || return 0

       running=`ps x|grep ${PID}|awk '{print $5}'`
       running=`echo $running|awk '{print $1}'`

       if [ "x${running}" == "x${RFCOMM_BIN}" ] ; then
               return 1
       fi

       return 0 
}

do_stop() {
       is_running
       if [ "x$?" == "x1" ] ; then
               echo "stoping gps-bluetooth-relay .."
               ${SDPTOOL_BIN} del 0x424242

               kill -9 ${PID}
               rm ${PID_FILE}
       else
               echo "not running - not halting .."
       fi
}

case "${1}" in
(start)
       do_start
       ;;
(stop)
       do_stop
       ;;
(restart)
       do_stop
       do_start
       ;;
(status)
       is_running
       if [ "x$?" == "x1" ] ; then
               echo "gps-bluetooth-relay running"
       else
               echo "gps_bluetooth-relay not running"
       fi
       ;;
esac

exit 0

[edit] workaround for apm with debian@FR

first: turn off apmd
what's actually running for me is:
mv /usr/bin/apm /usr/bin/apm.o and create new /usr/bin/apm as follows:

[edit] /usr/bin/apm

#!/bin/sh
echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk
apm.o ${*}
echo 0 > /sys/module/glamo_mci/parameters/sd_idleclk

Another script:
add link /etc/apm/event.d (don't forget to chmod +x /etc/apm/scripts.d/sd_idleclk)

[edit] /etc/apm/scripts.d/sd_idleclk

#!/bin/sh
SD_IDLECLK="/sys/module/glamo_mci/parameters/sd_idleclk"
[ -x "${SD_IDLECLK}" ] || exit 0

case "${1},${2}" in
(suspend,*)
    echo 1 > ${SD_IDLECLK}
    touch /etc
    ;;
(resume,suspend)
    echo 0 > ${SD_IDLECLK}
    ;;
esac

# for debugging:
echo "${1}, ${2} - `date`" >> /tmp/apm.log
sleep 1
sync

exit 0

[edit] Linklist

http://wiki.openmoko.org/wiki/Switching_Keyboards
http://wiki.openmoko.org/wiki/Boot_from_sd_card
http://wiki.openmoko.org/wiki/Lint-wifi
http://hdr.meetr.de/neo/openmoko/battery
http://www.ohli.de/download/openmoko-panel-plugin_0.1-1_all.deb
New Images for panel-plugin: (and patch for panel-plugin to provide keyboard-toggle Media:Panel-plugin.patch.txt)
Panel-plugin 48x48 off.png Panel-plugin bt 0.png Panel-plugin bt 1.png Panel-plugin gps 0.png Panel-plugin gsm 0.png Panel-plugin matchbox-keyboard 0.png Panel-plugin matchbox-keyboard 1.png Panel-plugin wifi 0.png
http://www.ohli.de/download/xserver-xorg-input-tslib_0.0.5-1+fso1_armel.deb

Option          "EmulateRightButton"    "1"

[edit] Location

Trier, Germany

[edit] Contact

-----BEGIN CONTACT BLOCK-----
 eMail:	morlac@morlac.de
 Jabber:morlac@skavaer.homelinux.org
------END CONTACT BLOCK------

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS$/IT;d-;s:;a?;C++(+++)>++++;UL++++;P++(+++)>++++;
L++(+++);E---;W++;N(+);o?;K?;!w;!O;!M+>;!V;PS(+);PE;
Y+;PGP++;t+(++);5(+)>++;X(+);R*;tv->+;b++(+++);DI++;
D++(+++)>++++;G(+)>++;e+>+++;h-()>++;r++;y++;
------END GEEK CODE BLOCK------

Key-ID: 2949CB31
http://pgpkeys.pca.dfn.de/pks/lookup?search=0x2949CB31&fingerprint=on&op=vindex
Personal tools

hardware-switches for bash

bt_hardware

#!/bin/sh
BT_HW="/sys/bus/platform/devices/neo1973-pm-bt.0/power_on"
BT_RST="/sys/bus/platform/devices/neo1973-pm-bt.0/reset"

[ -e "${BT_HW}" ] || exit 0

case "${1}" in
(start)
       echo 1 > ${BT_HW}
       echo 0 > ${BT_RST}
       echo "BlueTooth-Hardware is now on"
       ;;
(stop)
       echo 0 > ${BT_HW}
       echo "BlueTooth-Hardware is now off"
       ;;
(status)
       BT_STATUS=`cat ${BT_HW}`
       case "${BT_STATUS}" in
       ("1")
               echo "BlueTooth-Hardware is on"
               ;;
       ("0")
               echo "BlueTooth-Hardware is off"
               ;;
       esac
       ;;
esac

exit 0

gps_hardware

#!/bin/sh
GPS_HW="/sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron"
[ -e "${GPS_HW}" ] || exit 0

case "${1}" in
(start)
       echo 1 > ${GPS_HW}
       echo "GPS-Hardware is now on"
       ;;
(stop)
       echo 0 > ${GPS_HW}
       echo "GPS-Hardware is now off"
       ;;
(status)
       GPSSTATUS=`cat ${GPS_HW}`
       case "${GPSSTATUS}" in
       ("1")
               echo "GPS-Hardware is on"
               ;;
       ("0")
               echo "GPS-Hardware is off"
               ;;
       esac
       ;;
esac

exit 0

gsm_hardware

#!/bin/sh
GSM_HW="/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on"

[ -e "${GSM_HW}" ] || exit 0

case "${1}" in
(start)
       echo 1 > ${GSM_HW}
       echo "GSM-Hardware is now on"
       ;;
(stop)
       echo 0 > ${GSM_HW}
       echo "GSM-Hardware is now off"
       ;;
(status)
       GSM_STATUS=`cat ${GSM_HW}`
       case "${GSM_STATUS}" in
       ("1")
               echo "GSM-Hardware is on"
               ;;
       ("0")
               echo "GSM-Hardware is off"
               ;;
       esac
       ;;
esac

exit 0

workaround for apm with debian@FR

first: turn off apmd
what's actually running for me is:
mv /usr/bin/apm /usr/bin/apm.o and create new /usr/bin/apm as follows:

/usr/bin/apm

#!/bin/sh
echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk
apm.o ${*}
echo 0 > /sys/module/glamo_mci/parameters/sd_idleclk

Another script:
add link /etc/apm/event.d (don't forget to chmod +x /etc/apm/scripts.d/sd_idleclk)

/etc/apm/scripts.d/sd_idleclk

#!/bin/sh
SD_IDLECLK="/sys/module/glamo_mci/parameters/sd_idleclk"
[ -x "${SD_IDLECLK}" ] || exit 0

case "${1},${2}" in
(suspend,*)
    echo 1 > ${SD_IDLECLK}
    touch /etc
    ;;
(resume,suspend)
    echo 0 > ${SD_IDLECLK}
    ;;
esac

# for debugging:
echo "${1}, ${2} - `date`" >> /tmp/apm.log
sleep 1
sync

exit 0

Linklist

http://wiki.openmoko.org/wiki/Switching_Keyboards
http://wiki.openmoko.org/wiki/Boot_from_sd_card
http://wiki.openmoko.org/wiki/Lint-wifi
http://hdr.meetr.de/neo/openmoko/battery
http://www.ohli.de/download/xserver-xorg-input-tslib_0.0.5-1+fso1_armel.deb

Option          "EmulateRightButton"    "1"

Location

Trier, Germany

Contact

-----BEGIN CONTACT BLOCK-----
 eMail:	morlac@morlac.de
 Jabber:morlac@skavaer.homelinux.org
------END CONTACT BLOCK------

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS$/IT;d-;s:;a?;C++(+++)>++++;UL++++;P++(+++)>++++;
L++(+++);E---;W++;N(+);o?;K?;!w;!O;!M+>;!V;PS(+);PE;
Y+;PGP++;t+(++);5(+)>++;X(+);R*;tv->+;b++(+++);DI++;
D++(+++)>++++;G(+)>++;e+>+++;h-()>++;r++;y++;
------END GEEK CODE BLOCK------

Key-ID: 2949CB31
http://pgpkeys.pca.dfn.de/pks/lookup?search=0x2949CB31&fingerprint=on&op=vindex