Notices


Reply
Thread Tools
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#21
Originally Posted by pichlo View Post
results in spawning a new instance every time my cron job kicks in and the previous instance never terminates if x is any value other than 1. That means that after 30 minutes I have 10 instances of gpscon running and no data uploaded because my script never passed that line. If I use x=1, the script runs normally but the value is never updated.

What am I doing wrong?
It could be your script or the argument parser of gpscon which causes the weird behavior when used with script/cron.

I think some how the default variable value will be used and this means last known value and endless loop.

If it is not your script (I still need to try) I could change the default values (options and variable) for gpscon or better writing a own argument parser which will work with this situation.

Never tried cron-scripts with gpscon now it is time to do so.

Originally Posted by pichlo View Post
That makes sense. But it turns upside down my understanding of how the positioning in Sailfish works. I never turn it off and I was assuming that it would stay locked. Apparently not.
I think turning on means it could be used. Only when someone makes a request about your position it will get locked and this will be fast when you have all near satellite positions. It could be if the gps uses 3-4 satellites the signal is locked already.
To safe power is priority number one.

Last edited by Halftux; 2016-02-27 at 01:05. Reason: typo
 

The Following User Says Thank You to Halftux For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#22
@pichlo Thank you very much for reporting this issue.
I found the bug, it is the console reader in gpscon which was causing the cron problem.

You can stick to the gpscon-0.0.4-1.armv7hl.rpm version to solve the problem or wait for a new version.

The latest version on openrepos gpscon-0.0.8-1.armv7hl.rpm will not fix the problem it was a test version about the argument parser, but the next version will correct the console reader for sure.
 

The Following 4 Users Say Thank You to Halftux For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#23
Important update to gpscon!

For using gpscon in cron, python or any script it is recommended to use the additional otpion "--script" otherwise it could hang.
This feature is there since version 0.0.8. Type gpscon --help to check version.

All other version between 0.0.4 and 0.0.8 have a bug which cause the application hang when used with scripts and if there is no stdin.

For now this is the easiest and safest solution. I will see if it could be detected and automatically switched.
 

The Following 3 Users Say Thank You to Halftux For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#24
Hey Halftux, thanks a million for looking into this and sorry for the late feedback. Weekends are the busiest time. During the week I can (sometimes) steal some time from my employer but stealing it from the family is a bit more difficult

Unfortunately, neither a downgrade to 0.0.4 nor an upgrade to 0.0.8 and adding the --script option has made any difference. The script still freezes when launched from cron. After a while, ps shows a number of instances of my script and gpscon runs=3 running. Killing them all makes the stuck scripts move forward all at once. Having read the above post about no stdin, I also tried adding a redirection from a file (gpscon runs=3 < somefile, with or without --script) but that has not made any difference either. The only thing that does not freeze is runs=1, but that produces wrong coordinates as described earlier.

So I am thinking about changing the paradigm completely and repeating my question from a few posts back. @juiceme, how did you do it?
__________________
Русский военный корабль, иди нахуй!
 

The Following 2 Users Say Thank You to pichlo For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#25
Originally Posted by pichlo View Post
Hey Halftux, thanks a million for looking into this and sorry for the late feedback. Weekends are the busiest time. During the week I can (sometimes) steal some time from my employer but stealing it from the family is a bit more difficult
No problem I can understand.

Originally Posted by pichlo View Post
Unfortunately, neither a downgrade to 0.0.4 nor an upgrade to 0.0.8 and adding the --script option has made any difference. The script still freezes when launched from cron.
Please start your script in cron like this: "sh gps.sh".
This could solve your issue.
 

The Following 2 Users Say Thank You to Halftux For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#26
I have recognized when using gpscon run=1 posm=onlysat --script
will run for ever until satellites are in view. I will add in the future a timeout for this case (run=1 posm=onlysat).
When the timeout is reached it closes the app or will fall back to an other positioning method which is not so exact. I will see.
 

The Following User Says Thank You to Halftux For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#27
Originally Posted by Halftux View Post
Please start your script in cron like this: "sh gps.sh".
This could solve your issue.
Why did I not think of that myself?

Sadly, no
Code:
[nemo@Dinghy ~]$ ps ax | grep gps
  457 ?        Ss     0:00 /bin/sh ./gpsconupload
  458 ?        S      0:00 /bin/sh ./gpsconupload
  459 ?        S      0:00 gpscon --script runs=3
 1221 ?        Ss     0:00 /bin/sh ./gpsconupload
 1222 ?        S      0:00 /bin/sh ./gpsconupload
 1224 ?        S      0:00 gpscon --script runs=3
 1306 pts/0    S+     0:00 grep gps
[nemo@Dinghy ~]$
I have no idea where the double entries (pid 457/458 and 1221/1222) come from.

For a reference, I have made only a minimal change to the script.
Adding --script and replacing curl with echo:
Code:
#!/bin/sh

STR=`gpscon --script runs=3 | tail -n 1`

LAT=`echo $STR | cut -d " " -f 2 | cut -d ";" -f 1`
LON=`echo $STR | cut -d " " -f 4 | cut -d ";" -f 1`
ALT=`echo $STR | cut -d " " -f 6`

STR={\"gid\":\"`hostname`\",\"time\":`date +%s`,\"lon\":$LON,\"lat\":$LAT
if [ $ALT != "nan" ]; then
  STR=$STR,\"alt\":$ALT
fi
STR=$STR}

echo $STR >> ~/gpsconlog.txt
I have also tried splitting it in two files. The file evoked by cron has only the following:
Code:
#!/bin/sh

sh ./gpsconupload.do
That did not help either:
Code:
[nemo@Dinghy ~]$ ps ax | grep gps
 3871 ?        Ss     0:00 sh ./gpsconupload
 3872 ?        S      0:00 sh ./gpsconupload.do
 3873 ?        S      0:00 sh ./gpsconupload.do
 3874 ?        S      0:00 gpscon --script runs=3
 4076 ?        Ss     0:00 sh ./gpsconupload
 4077 ?        S      0:00 sh ./gpsconupload.do
 4078 ?        S      0:00 sh ./gpsconupload.do
 4079 ?        S      0:00 gpscon --script runs=3
 4088 pts/0    S+     0:00 grep gps
[nemo@Dinghy ~]$
Note again the double entries. They cannot be explained by a bug in or a misconfiguration of cron since cron launches only sh ./gpsconupload, which in turn runs the .do file. Any idea what's going on here?
__________________
Русский военный корабль, иди нахуй!
 

The Following User Says Thank You to pichlo For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#28
Originally Posted by pichlo View Post

I have no idea where the double entries (pid 457/458 and 1221/1222) come from.

Any idea what's going on here?
No sorry I don't know Could be the shell from cron
Here a link to start with another shell. What shell does sailfish use?

Cron has several enviromental variables configured in /etc/crontab, specifically SHELL and PATH. The default value for SHELL is /bin/sh. So unless this is changed or otherwise specified in a script, cron will execute commands using sh.

Here is my scenario with N900.

In alarmed I write as command:
Code:
sh /opt/gps.sh
gps.sh
Code:
#!/bin/sh

gpscon runs=3 --script > /home/user/MyDocs/gps2.txt
or
Code:
#!/bin/sh

STR=`gpscon runs=3 --script`

LAT=`echo $STR | cut -d " " -f 2 | cut -d ";" -f 1`
LON=`echo $STR | cut -d " " -f 4 | cut -d ";" -f 1`
ALT=`echo $STR | cut -d " " -f 6`

STR={\"name\":\"`hostname`\",\"time\":`date +%s`,\"lon\":$LON,\"lat\":$LAT
echo $STR > /home/user/MyDocs/gps2.log
running without a problem with alarmed. If you not put sh infront it will not work.

Code:
14554 user      2084 S    /bin/ash -c sh /opt/gps.sh 
14555 user      2084 S    sh /opt/gps.sh 
14556 user     27632 S    gpscon runs=3 --script 
14560 user      2088 S    grep gps
Now comes the funny thing doesn't matter with or without cron.
When in the location settings the location supl. server is deactivated or when using posm=onlysat is set, there will be no output unless you have enough satellites in view.

Last edited by Halftux; 2016-02-29 at 18:53. Reason: added text in quotes
 

The Following User Says Thank You to Halftux For This Useful Post:
Halftux's Avatar
Posts: 862 | Thanked: 2,511 times | Joined on Feb 2012 @ Germany
#29
Maybe it has nothing to do with cron. I am working now on a debug version and try to avoid a qt event loop. It could be that there is spawning another instance?
I had with another application going from qt4 to qt5 problems with event loops. Stay tuned.
 

The Following User Says Thank You to Halftux For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#30
Good point, I will try launching another Qt app from cron and see what happens.

The curious bit is that it runs normally with runs=1, only gives incorrect results.
What is the difference between runs=1 and runs=3 that may cause the hang?
__________________
Русский военный корабль, иди нахуй!
 

The Following User Says Thank You to pichlo For This Useful Post:
Reply

Tags
console, location, position, shell

Thread Tools

 
Forum Jump


All times are GMT. The time now is 10:41.