Active Topics

 



Notices


Reply
Thread Tools
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#181
rc5 is out now. Updates will NOT kill the hildon desktop to update the icons (I don't know how else to do this) automatically. Shutting off and restarting, or using an xterm to "killall hildon-desktop" will work.

I wanted to wait to have a python-efficient interface, but I managed to do it early. The icon is updated in the python app/applet now. And adding very fast updates to other applications will be very easy.

(Note I put logging first, so if kml is enabled, that will be saved first and most accurately, but the UI will also update rapidly, just not at the highest priority)

I am writing out a structure to /tmp/mgpstate upon change and idle, but generally it will reflect any changes. There is a header file which defines the structure and contains all the position and fix information.

For general use, all you need to do is open the file and mmap it to a structure pointer, then just use the data. Python can use struct to access it. To update the data in an application, all that is needed is a copy and convert.

Here is the structure:

Code:
struct satinfo {
  // satellite number, elevation, azmuith, and signal
  // satellite number is NEGATIVE if used
    short num, el, az, sn;
};

struct gpsstate {
  // latitude, longitude in micro-degrees.  Altitude in feet * 1000
    int llat, llon, alt;
  // dilution of precision * 1000
    int pdop, hdop, vdop;
  // speed, mph * 1000, track, degrees * 1000
    int gspd, gtrk;
  // year (in century, 08 not 2008), month, day, hour, minute, second, thousanths
    int yr, mo, dy, hr, mn, sc, scth;
  // lock, 0-1.  fix from GPGSA
    int lock, fix;
  // -1 if device not connected
    int gpsfd, obdfd;
  // number of sats visible, number being used in fix
    int nsats, nused;
  // satellite table
    struct satinfo sats[20];
};
And a sample in Python:
Code:
#!/usr/bin/env python

import struct
import mmap
import time

file = open("/tmp/mgpstate", "r+")

data = mmap.mmap(file.fileno(), 244)

print "lat,lon"
while True:
    gpstate = struct.unpack("21i80h",data)

    print "lat=",float(gpstate[0])/1000000
    print "lon=",float(gpstate[1])/1000000
    print "alt=",float(gpstate[2])/1000

    print "pdop=",float(gpstate[3])/1000
    print "hdop=",float(gpstate[4])/1000
    print "vdop=",float(gpstate[5])/1000

    print "spd=",float(gpstate[6])/1000
    print "trk=",float(gpstate[7])/1000

    print gpstate[10],"/", gpstate[9], "/",gpstate[8]
    print gpstate[11],":", gpstate[12], ":",gpstate[13], ".", str(gpstate[14]).zfill(3)

    print "lock=",gpstate[15]
    print "fix=", gpstate[16]

# BT gps, obd status    print gpstate[17], gpstate[18]

    sats = gpstate[19]
    print "sats=", sats," used=", gpstate[20]

    for i in range(sats):
        j=21+i*4
        print gpstate[j],gpstate[j+1],gpstate[j+2],gpstate[j+3]

    time.sleep(1) #use 0.2 for 5hz, etc.

Last edited by tz1; 2008-11-18 at 15:55. Reason: mention reset hildon desktop
 
Posts: 27 | Thanked: 0 times | Joined on Oct 2008 @ Munich, Germany
#182
Originally Posted by tz1 View Post
rc5 is out now.

I am writing out a structure to /tmp/mgpstate upon change and idle, but generally it will reflect any changes. There is a header file which defines the structure and contains all the position and fix information.
Out of curiosity: Is this intended for cooperation with carman ?


Regards,
Hakan
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#183
Carman was what motivated me since I already did half of the work to get the minimal test working.

I also needed a way to do a python UI that didn't do a lot of complex sending and receiving of data with minigpsd - mainly for a dashboard application similar to carman (how fast does carman update - Mine was doing 16fps but using over 50% cpu using my NMEA style socket interface).

It should also work with MaemoMapper and anything else without all the ugly decode logic duplication (I have to do it once in minigpsd, then everyone else seems to duplicate it if they don't use the gpsd api directly like gpxview).

Redoing the carman glue should be just slightly bigger than the very simple version since I now have to convert my integers to their floats. But if I do a mmap, carman won't have to read the file, just access the information from the structure periodically.
 
Posts: 28 | Thanked: 16 times | Joined on Sep 2008
#184
Originally Posted by tz1 View Post
rc5 is out now. Updates will NOT kill the hildon desktop to update the icons (I don't know how else to do this) automatically. Shutting off and restarting, or using an xterm to "killall hildon-desktop" will work.
Hey tz1,

If you want to update the hildon icon cache automatically without rebooting add this to your postinst script, or run it manually from xterm, etc.

Code:
gtk-update-icon-cache -f /usr/share/icons/hicolor
jbk
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#185
JBK - thanks, but it isn't the icon cache (I draw them in real-time). I need to RELOAD the taskbar and statusbar applets (written in Python) so they will use the new python code. Disabling and re-enabling them in the control panel would work too.

rc6 is coming shortly. The SOURCE archive contains an example program in C that will use the mmap interface to print out GPS data repeatedly. (It also has the python version). Neither of these are built or installed in the armel deb, but for those who want to integrate support into their own programs this is where to start. Also note I don't fully protect things (check if file exists, etc.) in the examples, but do in mgsetuplib.py

The only functional update in rc6 is if you have the logging directory set to a memory card, and the memory card is not inserted, it prints a message that logging is disabled instead of something else (like filling the internal flash). I also cleaned up the icon update handling code a bit.
 
allnameswereout's Avatar
Posts: 3,397 | Thanked: 1,212 times | Joined on Jul 2008 @ Netherlands
#186
For the icons: can someone try to see if killall -HUP hildon-desktop works?

OR this solution proposed here http://www.internettablettalk.com/fo...ad.php?t=25141 -- similar problem?
__________________
Goosfraba! All text written by allnameswereout is public domain unless stated otherwise. Thank you for sharing your output!

Last edited by allnameswereout; 2008-11-24 at 14:42. Reason: OR [...]
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#187
0.30.0 is in process to be moving to Extras. Bluez-utils-test should be moving there around the same time

0.31-pre0c is in Extras-devel. Please use that thread for questions, comments, etc.

http://www.internettablettalk.com/fo...ad.php?t=25142
 
grog's Avatar
Posts: 546 | Thanked: 85 times | Joined on Feb 2008 @ Winnipeg, Canada
#188
Does minigpsd use the a-gpsd data?
__________________
GROG!
N900 | ZAGG Body Armour | 16Gb A-DATA micro-sd
N810 | 2 x Patriot 8gb mini-SD | Boxwave Crystal Clear SS | Black Aluminum case | OTG dongle
N800 | 2 x 8gb OCX SD | Boxwave Anti-glare SS | PDAir book-style case
Holux M-1200 bluetooth GPS | iGo 4-row bluetooth keyboard | Linksys USB 10/100 ethernet | Plantronics Voyager 855 BT Headset
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#189
The AGPS stuff applies (so far) ONLY to the internal n810 GPS chip, and will be used (or not) automatically when that chip is activated. (At least minigpsd is activating the chip using a high enough level command that the gpsdriver program will query agps/supld for satellite info).

minigpsd will use the internal n810 gps if instructed to.

If AGPS is installed and set up properly, the internal n810 gps will use that data.

If the n810 internal GPS is not being used, then the AGPS will not be used.
 

The Following User Says Thank You to tz1 For This Useful Post:
Posts: 27 | Thanked: 0 times | Joined on Oct 2008 @ Munich, Germany
#190
Originally Posted by tz1 View Post
The OBD adapters I know get 12 volts through the 16 pin J1962 connector since it is supposed to go to the battery. I added a passthrough wire to power the bluetooth adapter (pin 9, 3-12v for aircable and many others). On my harley, it has a 4 pin connector, only 3 used, ground, switched 12v, and j1850. The problem with cars and "forget about it" is that it will still draw power - only a little, but enough you wouldn't want to leave it for a week.
Just for completeness: I bought a ELM327 Bluetooth OBD2 CAN-BUS Interface Scanner elm_327 ( http://cgi.ebay.com/ws/eBayISAPI.dll...m=370109454632 ) . If I remove the ignition key from the car, the OBD2 interface is not visible anymore in the bluetooth scan.

I'll leave the interface plugged into the car for a few days, let's see whether my battery dies


Regards,
Hakan
 
Reply

Tags
gps, obd2


 
Forum Jump


All times are GMT. The time now is 09:38.