![]() |
[Announce] gpscon gps position cli shell console
1 Attachment(s)
Gpscon is a command line tool to acquire the gps position with the qtmobility/qtlocation api.
In addition it has the ability to write a log file and to save a gpx file. Code:
gpscon v0.0.11 by halftux gpscon without parameter gpscon will be in endless loop and print to stdout: Latitude; Longitude; Altitude The application exits with:x+[enter] t+[enter]: will mark a new track in the logfile. [--fout] will enhance the output with additional values: Direction; Ground Speed; Vertical Speed; Horizontal Acc;Vertical Acc [--sat] with this option also the satellite status will be requested and printed out "Using x of x satellites" [posm=string] this will select the positioning method. Default is all. string=all |AllPositioningMethods string=onlysat |SatellitePositioningMethods string=nonesat |NonSatellitePositioningMethods [interval=integer] This property holds the requested interval in milliseconds between each update. If the update interval is not set (or is set to 0) the source will provide updates as often as necessary. If the update interval is set, the source will provide updates at an interval as close to the requested interval as possible. If the requested interval is less than the minimumUpdateInterval(), the minimum interval is used instead. [runs=integer] sets the amount on how many (shown) requests are made before exit [dumps=integer] sets the amount on how many first requests get dumped [limit=integer] sets the limit of the needed horizontal/vertical accuracy value before print out. There will be only one print out and after this the app is closing [log=string] writing to a log file string=txt |write/append gpscon.log to user dir string=gpx |write/append gpscon.log to user dir after last run or exit, the log file will be converted and written to gpscon.gpx in user dir string=log2gpx |convert log to gpx and exit. [tout=integer] sets the timeout for aquire a gps position in seconds. [--del] If log file exists it will be removed [--date] adds date to output [--time] adds time to output [--newtrack] will mark in the log file a new track. When converting to gpx old log file data and new data will be visible as separate track. [--lknv] This should output the last known value once at first (debug). If runs=1 it will only print the last known value out and quit. [--script] Will deactivate the user input which causes trouble with cron or python scripts. This option is recommended when using gpscon with scripts. [--help] prints help Available for: Sailfish Harmattan Fremantle Attached is the old source code in alpha stage, I commented out not tested code. It works same like the version before, it has only more options. New source in fremantle extra-devel repo. For sailfish create makefile by add this argument to qmake Code:
qmake "CONFIG+=sailfish" |
Re: [Announce] gpscon gps position cli shell console
Thanks, seem to work well in SFOS.
Some changes were needed to get it to compile though; I had to add " QT += positioning location" to the project file and comment out "using namespace QtMobility;" in gpspos.h This is pretty neat as now I can run it from cron every half an hour or so and push the position to my server. Just perfect in case I lose my device or it gets stolen. |
Re: [Announce] gpscon gps position cli shell console
1 Attachment(s)
Quote:
Quote:
Have fun. |
Re: [Announce] gpscon gps position cli shell console
Version for fremantle is available now.
Added log file option. When option is set to txt it will create a log file in /$userdir/gpscon.log When the option is set gpx it will create a gpx file from the log file. Only values with an altitude gets saved in gpx. When you interrupt the application with control+c no gpx file will be created instead use x+enter You will find the sources in fremantle extra repo. |
Re: [Announce] gpscon gps position cli shell console
Quote:
|
Re: [Announce] gpscon gps position cli shell console
Quote:
|
Re: [Announce] gpscon gps position cli shell console
Quote:
The gpx file will only get created when the application will exit normally. The gpx file gets created from the log file. So when your N900 suddenly reboots you can start gpscon again with gpx option and run=1 and you will have all data in the gpx file. This will work until you delete the log file. |
Re: [Announce] gpscon gps position cli shell console
With the new version 0.0.7 you can convert a log file to a gpx as follow:
Code:
/opt/gpscon/bin/gpscon log=log2gpx Now you can also mark new tracks in the log file. If you have an old recorded track in the log file and you would like to record another into the log file, you could start as follow: Code:
/opt/gpscon/bin/gpscon log=gpx --newtrack |
Re: [Announce] gpscon gps position cli shell console
Hi Halftux,
good job this. One of those programs that has utility beyond use of the n900 as a primary phone and more as a pocket computer. Do you have a roadmap for future features, if any and however vague at the mo'? |
Re: [Announce] gpscon gps position cli shell console
Quote:
|
Re: [Announce] gpscon gps position cli shell console
Quote:
CNT (Columbus Navigation Toolkit) provides such but 1) it has a GUI and does a whole lot more (resource hungry but very stylish) and 2) is unstable. I submit that the above is broadly consistent with gpscon current mission. Easy to write huh, as a non-coding, ageing smart-***, I know :-) |
Re: [Announce] gpscon gps position cli shell console
Quote:
|
Re: [Announce] gpscon gps position cli shell console
Quote:
The reason I ask... I have the following script running every 3 minutes from cron: Code:
#!/bin/sh I then experimented with gpscon a bit more and found that it always returns the same previous value if run only once. Only when run two or more times, it starts updating the value. Unfortunately, Code:
gpscon runs=x What am I doing wrong? |
Re: [Announce] gpscon gps position cli shell console
In addition to the above, I get strange results like:
Code:
[nemo@Dinghy ~]$ gpscon I would expect...
Moreover... I open two terminal windows, one with gpscon running permanently (I see the values changing in the last digit). In the other, I run gpscon runs=1 manually from time to time. I expect the manual run reflect the current values from the window with gpscon running permanently, but it is always the same. What is going on? (Experiments run on Sailfish if that makes a difference.) |
Re: [Announce] gpscon gps position cli shell console
Even better:
Code:
[nemo@Dinghy ~]$ gpscon However, Code:
[nemo@Dinghy ~]$ gpscon runs=3
The remaining £100 question is, why does gpscon runs=3 not terminate when run from a script triggered by cron when it quite happily terminates when the same script is run manually from the command line. |
Re: [Announce] gpscon gps position cli shell console
@ pichlo, sorry I do not have sailfish :(. But I will look into your posts and see if I can help you.
One thing is the position api can get different positions. So after some time you should get exact values when your gps signal is fixed. First I would set position method option to "posm=onlysat". Code:
Satellite-based positioning methods such as GPS. Set it to 80 and this would lead to one print out with a fixed gps position. |
Re: [Announce] gpscon gps position cli shell console
Hmm. Something is fishy here. I tried gpscon limit=80 and it never terminated (not in 5 minutes anyway). Neither did limit=10.
|
Re: [Announce] gpscon gps position cli shell console
Quote:
gpscon posm=onlysat --fout --sat Let it run and see how the values are changing. What is the minimum value for your accuarcy? |
Re: [Announce] gpscon gps position cli shell console
@pichlo By the way the altitude is nan this means the position doesn't come from the gps.
Quote:
Is it worth to try in another script after some timout. Code:
kill -SIGTERM $(pidof gpscon) It could be that the value will not change because it is a last known value (it shouldn't take it), or the value comes from a not very accurate positioning method. However the N900 and the N950 act different because of different qtmobility. Maybe Jolla also act different. P.S.: Maybe the first value is the lastknown value could be a bug in the last version, I will look into the source code. |
Re: [Announce] gpscon gps position cli shell console
Quote:
I ran it indoors but on the upper floor of a typical 2-story English house with thin wooden floors and ceilings. No concrete. It started off with 0 out of 19 satellites used, accuracy something like 67. Then I put it in the window while tucking the kids in the bed. I do not know long it took as I was busy but now, after 3894 runs, it says 5 out of 20 sats used, accuracy 4. Quote:
BTW the altitude was a number sometimes ;) |
Re: [Announce] gpscon gps position cli shell console
Quote:
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.:) Quote:
To safe power is priority number one. |
Re: [Announce] gpscon gps position cli shell console
@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. |
Re: [Announce] gpscon gps position cli shell console
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. |
Re: [Announce] gpscon gps position cli shell console
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? |
Re: [Announce] gpscon gps position cli shell console
Quote:
Quote:
This could solve your issue. |
Re: [Announce] gpscon gps position cli shell console
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. |
Re: [Announce] gpscon gps position cli shell console
Quote:
Sadly, no :( Code:
[nemo@Dinghy ~]$ ps ax | grep gps For a reference, I have made only a minimal change to the script. Adding --script and replacing curl with echo: Code:
#!/bin/sh Code:
#!/bin/sh Code:
[nemo@Dinghy ~]$ ps ax | grep gps |
Re: [Announce] gpscon gps position cli shell console
Quote:
Here a link to start with another shell. What shell does sailfish use? Quote:
Here is my scenario with N900. In alarmed I write as command: Code:
sh /opt/gps.sh Code:
#!/bin/sh Code:
#!/bin/sh Code:
14554 user 2084 S /bin/ash -c sh /opt/gps.sh 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. |
Re: [Announce] gpscon gps position cli shell console
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. |
Re: [Announce] gpscon gps position cli shell console
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? |
Re: [Announce] gpscon gps position cli shell console
Quote:
Quote:
I starting source->startupdates() and when it is set to positioning method all, the first value will be taken not from the gps. But now comes something which I do not understand there will be no further emited signal which calling the output slot. This happens for example when no new update could be aquired. Result is the application hangs and will never call quit. However when not set posm=onlysat it should fall back to a different position method but there comes no signal to call my slot. I would like to try source->requestupdate(timeout) to get at least a timeout. So I could reproduce your problem and could get rid of it by calling the script with sh. But the N900 uses ash instead of sh which could produce the problem. I think on sailfish it is sh already. So over all I don't know what is happening. Problem could be: - qt version behave different 2 instance maybe 2 event loops which can't catch all events from signal - cron problem (btw which user/rights runs cron task?), shell problem |
Re: [Announce] gpscon gps position cli shell console
Quote:
runs=1 posm=onlysat from the command line returns immediately, with the last (incorrect) result. runs=10 posm=onlysat just hangs. Definitely for more than 20 minutes anyway. Admittedly I only tried indoors, with the phone in the window. Too cold outside to stand there with a phone in an outstretched hand for 5 minutes :D It is also rather cloudy, so the GPS signal may not be that brilliant. The best I got with --fout --sat was 0 out of 3 satellites. The last time I tried it at home (the same way, phone in the window) I got a fix in just a few minutes. That runs=1 posm=onlysat returning immediately tells me that you are probably right about the API differences. I think the time has cometh for me to dig up the sources, build it myself and start debugging ;) |
Re: [Announce] gpscon gps position cli shell console
After my first try with Sailfish and vixie-cron it looks like that the api is not talking to the gps.
So I can get the value from run number one which is definitely some last known value. There will be no further runs because the update signal from the api will not be send because the gps is not active. You can see it because there is no icon blinking in sfos for active gps. So far I have no clue to fix or to debug this problem. For sure it is not my app it is maybe the console environment, cron or the api. |
Re: [Announce] gpscon gps position cli shell console
So here the environment from cron shell. Definitely different.
Quote:
|
Re: [Announce] gpscon gps position cli shell console
ok fixed it with by adding to the script:
Code:
source /home/nemo/.bash_profile |
Re: [Announce] gpscon gps position cli shell console
New version 0.0.9 will be out soon.
There you have a new option [tout=integer] for setting a timeout to aquire a gps position when you are in "onlysat" mode. When not setting a timeout the application could wait forever to get enough satellites. The timeout is in seconds, when this time is reached the application exits. For sailfish the onlysat mode will now dismiss the first value which was known to be a last known satellite value. So this example command should give you now the current position, if enough satellites are visible. (could be same for harmattan I need to check) Code:
gpscon runs=1 posm=onlysat |
Re: [Announce] gpscon gps position cli shell console
New version 0.0.10 will be out soon.
Added track segment and track name to gpx export. With s+[enter] you can mark the end of a segment in the log file. Some gpx viewer and editors need a starting and ending segment to properly open the gpx file. So now when a new track starts or ends a segment will be automatically opened and closed. |
Re: [Announce] gpscon gps position cli shell console
Found some link about gpstracker with gpscon, this example is for sailfish.
Online JGPSTracker systemctl Maybe this could be interesting for somebody. |
Re: [Announce] gpscon gps position cli shell console
Quote:
Code:
/usr/bin/gpscon tout=60 runs=1 posm=onlysat The C returns in about 15 seconds, the X returns almost straight away. Both return a stale fix which is never updated using this command form. (If I use runs=2 I get updated fix on the second pass) Even with this issue, many thanks for a great tool! |
Re: [Announce] gpscon gps position cli shell console
Quote:
For sure it behave different. It depends maybe also on the settings, or if you have a sim card or not, more last know values (from different methods), maybe different sailfish versions, wifi hmm what ever.:confused: Soon I will release a version where you can define how many positioning events you want to dump. But I will also suggest you to try out the limit option. This option specifies an accuracy threshold. It will have the first output with a better accuracy than the limit. With the right tuned limit you could be sure to get a satellite position. To determine a good limit I recommend to make some experience with --fout and maybe also with --sat. There you could see the accuracy and the correlation with satellites. With 6 satellites out of 25 I had an accuracy of 3 with the jolla c. Quote:
|
All times are GMT. The time now is 09:14. |
vBulletin® Version 3.8.8