maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui! (https://talk.maemo.org/showthread.php?t=62731)

akritas 2010-09-24 19:29

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
great man!!

keep updates coming ....

BLIZZARD 2010-09-25 11:19

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by Supersimo88 (Post 825171)
ok thanks!
maybe is possible to implement it in a mainwindow so you can do something else wile scanning!

I have found a solution so you can multitask after-all :):

***NEW-VERSION***

1.2.3
Added the chance to select if you want gui or not during scanning so you can multitask
Better scanning results
Some ui changes

Quote:

Originally Posted by Supersimo88 (Post 824694)
it's possible to set the lower freq limit to 76.0?
it will be very usefull!

I will add that to the next version thanks to martin/pycage :)

BLIZZARD 2010-09-25 19:56

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Does anyone know from where i can get feddback. a file or something, if the headphones are pluged in?

WhiteWolf 2010-09-25 22:38

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by BLIZZARD (Post 825943)
I have found a solution so you can multitask after-all :):

***NEW-VERSION***

1.2.3
Added the chance to select if you want gui or not during scanning so you can multitask
Better scanning results
Some ui changes



I will add that to the next version thanks to martin/pycage :)

Great!
Thanks

pycage 2010-09-25 22:40

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by BLIZZARD (Post 826207)
Does anyone know from where i can get feddback. a file or something, if the headphones are pluged in?

This is the one to watch:
Code:

/sys/devices/platform/gpio-switch/headphone/state

Viny 2010-09-25 23:39

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Nice app hopefully someone will make a .deb file soon for the rest of us :)

WhiteWolf 2010-09-26 08:27

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
I get the following error message constantly and can not find free frequencies:

Code:

expr: syntax error
sh: -eq:argumente expected
expr: syntax error
sh: -eq:argumente expectedexpr: syntax error
sh: -eq:argumente expected
expr: syntax error
sh: -eq:argumente expected
expr: syntax error
sh: -eq:argumente expected
expr: syntax error
sh: -eq:argumente expected
expr: syntax error
sh: -eq:argumente expected


BLIZZARD 2010-09-26 12:03

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
***NEW-VERSION***

1.3.0
Checks if headphones are pluged in, thanks to pycage....again :)
Fixed some "bugs"

Tested it and works fine, remeber to type "root" NOT "sudo gainroot"

WhiteWolf 2010-09-26 12:48

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
I am using "type root"

PROMPT displays: "Nokia-N900: #"

I get the error message indicated.

BLIZZARD 2010-09-26 13:21

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by WhiteWolf (Post 826607)
I am using "type root"

PROMPT displays: "Nokia-N900: #"

I get the error message indicated.

Hmmm. I tested on my n900 again and it works fine. Can anyone else confirm what WhiteWolf is saying?

Supersimo88 2010-09-26 13:43

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
i'm testing...
it works very well!

BLIZZARD 2010-09-26 13:50

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
@WhiteWolf

When you say the error message indicated you mean "Nokia-N900: #"? This is not an error, you must make it executable and then run it:
DO THIS:
open xterm
type:
mkdir /home/user/bin
mv /home/user/MyDocs/<the path of your download file>
chmod u+x /home/user/bin/EFF-1.3.0
root
/home/user/bin/EFF-1.3.0

You need to do the above only once. The next time you want to run the EFF, just type:
/home/user/bin/EFF-1.3.0

WhiteWolf 2010-09-26 21:39

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by BLIZZARD (Post 826648)
@WhiteWolf

When you say the error message indicated you mean "Nokia-N900: #"? This is not an error, you must make it executable and then run it:
DO THIS:
open xterm
type:
mkdir /home/user/bin
mv /home/user/MyDocs/<the path of your download file>
chmod u+x /home/user/bin/EFF-1.3.0
root
/home/user/bin/EFF-1.3.0

You need to do the above only once. The next time you want to run the EFF, just type:
/home/user/bin/EFF-1.3.0

Sorry, I did not know me understand.

I followed the steps listed.

After follow step by step, I returned the error that I mentioned.


Code:

expr: syntax error
sh: -eq:argument expected
expr: syntax error
sh: -eq:argument expected
expr: syntax error
sh: -eq:argument expected
expr: syntax error
sh: -eq:argument expected
expr: syntax error
sh: -eq:argument expected
expr: syntax error
sh: -eq:argument expected
expr: syntax error
sh: -eq:argument expected
POWERED OFF


BLIZZARD 2010-09-28 18:32

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
@WhiteWolf

I can confirm that the shell script is fine. Either you follow the instructions wrong or your n900 must have a problem.
At which folder did you download the file?

BLIZZARD 2010-09-28 19:02

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
**NEW-VERSION***

1.3.1
Fixed percentage calculation (was passing 100 before)
Corrected some spelling mistakes (scaning -> scanning) :D

activemind 2010-09-28 21:33

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Are there any plans to package this and make .deb available so that we can install it from app-manager? Can someone do that please, pretty please :-)

maxximuscool 2010-09-28 21:41

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
are you planing to release this in Deb packaging?

minakmostoles 2010-09-29 10:44

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
I have the same problem, Whitewolf.

BLIZZARD 2010-09-29 13:20

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by maxximuscool (Post 828757)
are you planing to release this in Deb packaging?

Yes, i will make a deb, when i finally learn how to make one :) (i am currently reading at the wiki)

flexxxv 2010-09-29 14:30

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Hy I have the same problem like WhiteWolf

I did a debug run:
http://pastebin.com/sSANspyY

I didn't let the program run until end I just exit after some time

MohammadAG 2010-09-29 14:39

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Indent your code!
Making debs is easy, hit me up with a PM if you have any problems :)
When you make a deb though you'll have to use sudo, so you should figure out why sudo gainroot doesn't work, prefix dbus and zenity lines with run-standalone.sh

Edit 2: who's # Copyright (c) 2010 OEM LTD (HE99116) #
Edit: indented code, I hate ugly scripts :p
Code:

#!/bin/sh

# Empty Frequencies Finder, find free/empty frequencies #
#                                                      #
#      Copyright (c) 2010 OEM LTD (HE99116)          #

send_request()
{
  dbus-send --system --print-reply \
            --dest=de.pycage.FMRXEnabler \
            /de/pycage/FMRXEnabler\
            de.pycage.FMRXEnabler.request >/dev/null
}

find_sysfs_path()
{
    F=`find /sys/class/i2c-adapter -name "fm_frequency"`
    echo `dirname ${F}`
}

power_on()
{
    # switch on
    echo 1 >${SYSFS_PATH}/power_state
    # set DAC audio route
    echo 16 >${SYSFS_PATH}/audio_route
    # set stereo
    echo 12 >${SYSFS_PATH}/dac_output
    # set preset tune mode
    echo 1 >${SYSFS_PATH}/fm_search_tune_mode
    # unmute
    echo 0 >${SYSFS_PATH}/mute
}

power_off()
{
    echo "POWERED OFF"
    # mute
    echo 1 >${SYSFS_PATH}/mute
    # switch off
    echo 0 >${SYSFS_PATH}/power_state
}

tune_in()
{
    FREQ=$1
    echo ${FREQ} >${SYSFS_PATH}/fm_frequency
}

change_frq()
{
    send_request
    SYSFS_PATH=`find_sysfs_path`
    power_on
    tune_in $cur_freq
}


#Temporary file for saving empty frequencies
temp=`mktemp -t temp.XXXXXX`

#Print banner
ver="1.3.1"
zenity --info --text="E.F.F. (Emty Frequencies Finder)" --title="E.F.F-$ver"

#Vars
vars()
{
    max=`expr $max \* 100`
    min=`expr $min \* 100`
    range=`expr $max - $min`
    pers_var=`expr $range / 100`
    cur_freq=$min
    pers_cntr=0
    cnt_total=0
}

#Change testing frequency, calculate percentage of progress
change_tfrq()
{
    if [ $cur_freq -eq $max ] || [ $cur_freq -gt $max ]
        then
            break
    fi
    pers_cntr=`expr $pers_cntr + 1`
    pers=`expr \( 100 \* $pers_cntr \) / $pers_var`
    cur_freq=`expr $cur_freq + 100`
    cnt=0
    change_frq
    if [ $guiyn -eq 0 ]
        then
            echo $pers
        else
            if [ $pers -lt 100 ]
                then
                    echo "Scanning...Found $cnt_total empty frequencies. $pers %"
                else
                    echo "Scanning...Found $cnt_total empty frequencies. 100 %"
            fi
    fi
    sleep 1
    if [ $guiyn -eq 0 ]
        then
            echo "# Scanning...Found $cnt_total empty frequencies"
    fi
}

#How much empty functions
hempty_a()
{
    if [ $cnt -eq 10 ]
        then
            sleep 1
    fi
}

hempty_b()
{
    if [ $cnt -eq 10 ] || [ $cnt -eq 45 ]
        then
            sleep 1
    fi
}

hempty_c()
{
    if [ $cnt -eq 5 ] || [ $cnt -eq 20 ] || [ $cnt -eq 60 ]
        then
            sleep 1
    fi
}

hempty_d()
{
    if [ $cnt -eq 5 ] || [ $cnt -eq 30 ] || [ $cnt -eq 60 ] || [ $cnt -eq 80 ]
        then
            sleep 1
    fi
}

#Zenity question to be root
quest_root()
{
    rans=$(zenity --entry --entry-text="root" --title="To run you must be root, if you agree type ok." --text="Press OK to continue or cancel to quit.")
    if [ $? -eq 0 ]
        then
            eval $rans
        else
            zenity --error --text="You must be root!"
            exit 1
    fi
}

#Check if the frequency is empty
check_frq()
{
    while [ 1 ]
        do
            #unmake the following from comment to is if its working
            #echo "# `cat /sys/class/i2c-adapter/i2c-3/3-0022/fm_frequency` `cat /sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi`"
            #echo "# `echo $hempty $cnt`"
            if [ $cnt -eq `expr 60 * $hempty` ]
                then
                    cnt_total=`expr $cnt_total + 1`
                    msg=1
                    echo $cur_freq >> $temp
                    break
            fi
    case $hempty in
        1)
        hempty_a ;;
        2)
        hempty_b ;;
        3)
        hempty_c ;;
        4)
        hempty_d ;;
    esac
    if [ `cat /sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi` = "-112" ]
        then
            cnt=`expr $cnt + 1`
        else
            break
    fi
    done
}

#Stop with zenity cancell button
zcancel()
{
    if [ $? -eq 1 ]
        then
            power_off
            exit 1
    fi
}

#Mesage on $temp, function
tmsg()
{
    if [ $guiyn -eq 1 ]
        then
            echo "You searched from $min to $max, with $hempty emty value. Found $cnt_total empty frequencies:"
            cat $temp
        fi
}

#MAIN

if [ `cat /sys/devices/platform/gpio-switch/headphone/state` = "disconnected" ]
    then
        zenity --error --title="ERROR" --text="Headphones are not pluged in!"
        exit 1
fi

if [ `id -u` = "0" ]
    then
        hempty=$(zenity --scale --min-value=1 --max-value=4 --value=1 --text="Note that higher value requires more scaning time!" --title="Search for: 1=Slightly-empty 2=Empty 3=Very-empty 4=Extremely-empty")
        if [ $? -eq 1 ]
            then
                zenity --error --title="ERROR" --text="You must select a value!Aborting..."
                exit 1
        fi

        min=$(zenity --scale --min-value=875 --max-value=1080 --value=875 --title="Search from:" --text="Select min value (ex. 991=99.1 , 1034=103.4)")
        zcancel
        max=$(zenity --scale --min-value=875 --max-value=1080 --value=875 --title="From $min to:" --text="Select max value (ex. 991=99.1 , 1034=103.4)")
        zcancel
        zenity --question --title="Do you want gui during scanning?" --text="If you type "YES" you will not be able to multitask." --ok-label="YES"

        if [ $? -eq 1 ]
            then
                guiyn=1
            else
                guiyn=0
        fi
        vars
        if [ $min -lt $max ]
            then
                if [ $guiyn -eq 0 ]
                    then
                        (while [ 1 ]
                        do
                        change_tfrq
                        check_frq
                        done
                        ) | zenity --progress --text="Scaning..." --auto-close
                        zcancel
                    else
                        while [ 1 ]
                        do
                        change_tfrq
                        check_frq
                        done
                fi
                tmsg
                zenity --text-info --filename=$temp
                power_off
            else
                zenity --error --text="Max value must be greater than min value!"
        fi
    else
        zenity --error --text="You must be root!"
fi


BLIZZARD 2010-09-29 15:21

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
@MohammadAG

i will change that line with copyright (a friend of me told me to write that..nonsense). I will butify the script :).

GUYS I THING I SOLVED YOUR PROBLEM, TRY THIS:

1.4.0 http://www.mediafire.com/?m5xq81w58n7512v

MohammadAG 2010-09-29 15:22

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Script isn't working, keeps erroring out:
Code:

BusyBox v1.10.2 (Debian 3:1.10.2.legal-1osso30+0m5) multi-call binary

Usage: dirname FILENAME

expr: syntax error
sh: -eq: argument expected
cat: can't open '/sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi': No such file or directory
sh: -112: unknown operand


BLIZZARD 2010-09-29 15:25

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by MohammadAG (Post 829358)
Script isn't working, keeps erroring out:
Code:

BusyBox v1.10.2 (Debian 3:1.10.2.legal-1osso30+0m5) multi-call binary

Usage: dirname FILENAME

expr: syntax error
sh: -eq: argument expected
cat: can't open '/sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi': No such file or directory
sh: -112: unknown operand


Did you tried 1.4.0 ?

MohammadAG 2010-09-29 15:28

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Code:

Nokia-N900:/sys/class/i2c-adapter/i2c-3/3-0022# ls
bus        modalias  name      power      subsystem  uevent


BLIZZARD 2010-09-29 15:37

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by MohammadAG (Post 829365)
Code:

Nokia-N900:/sys/class/i2c-adapter/i2c-3/3-0022# ls
bus        modalias  name      power      subsystem  uevent


Are you talking about 1.4.0?

MohammadAG 2010-09-29 15:44

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Uh, does it matter? The kernel module is responsible on creating those files, not your script.
cat: can't open '/sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi': No such file or directory
Your script tries to read that file ^ which doesn't exist on the stock kernel (or kernels based on it)

BLIZZARD 2010-09-29 15:49

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by MohammadAG (Post 829374)
Uh, does it matter? The kernel module is responsible on creating those files, not your script.
cat: can't open '/sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi': No such file or directory
Your script tries to read that file ^ which doesn't exist on the stock kernel (or kernels based on it)

When you turn on reciever these files are created automattialy. The script works fine on my n900. Tested 1.4.0 on my n900 and works with sudo gainroot too.

MohammadAG 2010-09-29 15:56

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by BLIZZARD (Post 829380)
When you turn on reciever these files are created automattialy. The script works fine on my n900. Tested 1.4.0 on my n900 and works with sudo gainroot too.

Not really, which kernel are you on?
Code:

Nokia-N900:/sys/class/i2c-adapter/i2c-3/3-0022# fmtx_client -p1
Usage:
------
-f<uint>    Set frequency (in kHz)
-s<string>    Set RDS station name
-t<string>    Set RDS info text
-p<uint>    Turn fmtx on (1) or off (0)

Current settings (Frequencies in kHz):
--------------------------------------
version=1
frequency=107500
freq_min=76000
freq_max=107900
freq_step=100
state=enabled
rds_ps=Nokia 
rds_text=
Nokia-N900:/sys/class/i2c-adapter/i2c-3/3-0022# ls
bus        modalias  name      power      subsystem  uevent


BLIZZARD 2010-09-29 16:03

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Ffmtx_client is for controlling transmitter. I said that when you turn on reciever, these files are created automatically. Try opening FM RADIO app and you will see that the files will be created :)
I had power kernel installed but i flashed my n900 a week ago.

BLIZZARD 2010-09-29 17:26

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
@WhiteWolf and others i think i solved you problem, pleas test the new version and post if its working or not

**NEW-VERSION***

1.4.2
Added more comments, beautyfied more the script
Prefixed zenity, thanks to MohammadAG :)
Corrected an expr issue
Now you can run EFF with root **AND** sudo gainroot!!!

EFF-1.4.2 http://www.mediafire.com/?5l0ngxbuja1rqw8

pycage 2010-09-29 17:41

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by MohammadAG (Post 829374)
Uh, does it matter? The kernel module is responsible on creating those files, not your script.
cat: can't open '/sys/class/i2c-adapter/i2c-3/3-0022/fm_rssi': No such file or directory
Your script tries to read that file ^ which doesn't exist on the stock kernel (or kernels based on it)

The file gets created on a stock N900 kernel when the bcm2048_radio kernel driver gets loaded. You need to have the n900-fmrx-enabler package installed to make this work, though. The N900 ships with the driver but it won't load unless you power up the i2c bus to the FM tuner on the Bluetooth chip. The n900-fmrx-enabler takes care of this.

WhiteWolf 2010-09-29 20:44

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Version 1.0.5 works fine me. Does not give the error mentioned in the latest versions.

BLIZZARD 2010-09-30 03:59

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by WhiteWolf (Post 829637)
Version 1.0.5 works fine me. Does not give the error mentioned in the latest versions.

What about 1.4.2 ? Did you try it?

Viny 2010-09-30 04:14

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
is the .deb out yet blizzard?

WhiteWolf 2010-09-30 06:17

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by BLIZZARD (Post 829810)
What about 1.4.2 ? Did you try it?

Yes I tried but the error message is the same.

But the first version works for me.

flexxxv 2010-09-30 12:00

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
BLIZZARD:
thx. for it seems to work.

but shuldn't you check for zenity before checking for headphones?

btw: under what license is this?

BLIZZARD 2010-10-02 10:45

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Quote:

Originally Posted by flexxxv (Post 830030)
BLIZZARD:
thx. for it seems to work.

but shuldn't you check for zenity before checking for headphones?

btw: under what license is this?

Youre right :), i missed that, next version will check for zenity first.
EFF script is under the terms of the GNU General Public License.

Quote:

Originally Posted by Viny (Post 829812)
is the .deb out yet blizzard?

Not yet :( but, it will come :)

MohammadAG 2010-10-02 12:19

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
Indeed it will, mediafire was down :P

sachin007 2010-10-09 17:32

Re: [ANNOUNCE] E.F.F. Empty Frequencies Finder, shell script program with gui!
 
This is the first time i am using this. Directly tried 1.4.2 and it said no zenity. Installed zenity from apt-get and ran the script. It gives me the headphones not found error.


All times are GMT. The time now is 05:46.

vBulletin® Version 3.8.8