gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-users] Hoe to send GPS data from GPSD to remote Server/databas


From: O'Connor, Daniel
Subject: Re: [gpsd-users] Hoe to send GPS data from GPSD to remote Server/database server
Date: Thu, 9 Apr 2015 20:33:00 +0930

> On 9 Apr 2015, at 17:34, Monali Bhattacharya <address@hidden> wrote:
> Is there any existing example program for this? I'm a beginner and it will be 
> helpful if get some examples.

Here's some sample code I wrote..

[midget 20:11] ~ >psql -U pgsql template1
psql (9.3.6, server 9.4.0)
WARNING: psql major version 9.3, server major version 9.4.
         Some psql features might not work.
Type "help" for help.

template1=# create user gps;
CREATE ROLE
template1=# create database gps with owner gps;
cCREATE DATABASE
template1=# \q
[midget 20:11] ~ >psql -U gps gps
psql (9.3.6, server 9.4.0)
WARNING: psql major version 9.3, server major version 9.4.
         Some psql features might not work.
Type "help" for help.

gps=> create table gps ( time timestamp not null, longitude float not null, 
latitude float not null );
CREATE TABLE

import datetime
import gps
import psycopg2

con = psycopg2.connect(database = 'gps', user = 'gps')
c = con.cursor()

g = gps.gps()
g.stream()

for ev in g:
        if ev['type'] != 'TPV':
                continue
        tmp = ev['time'].split('.')
        d = datetime.datetime.strptime(d[0])
        d.replace(microsecond = int(tmp[1][0:3]) * 1000)
        c.execute('insert into gps (time, longitude, latitude) values (%1, %1, 
%1)', (d, ev['lon'], ev['lat']))
        con.commit()


> -----Original Message-----
> From: Chris Kuethe [mailto:address@hidden
> Sent: Thursday, April 09, 2015 12:16 PM
> To: Monali Bhattacharya
> Cc: address@hidden
> Subject: Re: [gpsd-users] Hoe to send GPS data from GPSD to remote 
> Server/database server
> 
> http://www.catb.org/gpsd/gpsd_json.html
> 
> The gpsd protocol can include device ID. Connect your receivers and run gpsd, 
> then use gpsmon to view the devices...
> 
> On Wed, Apr 8, 2015 at 11:24 PM, Monali Bhattacharya <address@hidden> wrote:
>> Thanks for the input. But I'm having this confusion. As I'm having 5( gps + 
>> gpsd )running embedded device, in the single server side PC how can I get 
>> the log of each separately and identify them.
>> 
>> 
>> -----Original Message-----
>> From: Chris Kuethe [mailto:address@hidden
>> Sent: Thursday, April 09, 2015 11:11 AM
>> To: Monali Bhattacharya
>> Cc: address@hidden
>> Subject: Re: [gpsd-users] Hoe to send GPS data from GPSD to remote
>> Server/database server
>> 
>> It's dead easy.
>> 
>> You can do this in a couple of screens of python, perl, or php; open socket 
>> to gpsd, create a connection to your chosen database, read lines of json, 
>> parse json into dict/hash, sql insert (or update) items in the hash into the 
>> database. repeat.
>> 
>> Wacky thought: maybe you want to look at mongodb, since it takes json input 
>> and gpsd emits json output.
>> Larsen & Toubro Limited
>> 
>> www.larsentoubro.com
>> 
>> This Email may contain confidential or privileged information for the 
>> intended recipient (s). If you are not the intended recipient, please do not 
>> use or disseminate the information, notify the sender and delete it from 
>> your system.
> 
> 
> 
> --
> GDB has a 'break' feature; why doesn't it have 'fix' too?
> Larsen & Toubro Limited
> 
> www.larsentoubro.com
> 
> This Email may contain confidential or privileged information for the 
> intended recipient (s). If you are not the intended recipient, please do not 
> use or disseminate the information, notify the sender and delete it from your 
> system.

--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
 -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C




reply via email to

[Prev in Thread] Current Thread [Next in Thread]