Giter Club home page Giter Club logo

bancroft's Introduction

Bancroft

bancroft is a node client for the gps daemon providing configurable async location tracking featuring geojson geometries point format.

How it works

Upon object creation ( new Bancroft() ), bancroft connects to a running GPS daemon and send ?WATCH and ?POLL messages to receive messages (json type) back from the daemon, hence, from the GPS device itself. Upon connection, a connection event is emitted along with daemon version and release details object. A disconnect event is emitted once the daemon is found off grid.

At any time, bancroft keeps track of the current location along with information about current satellite status. A location event is emitted once a new location has been tracked, that is, whenever the latitude, longitude or altitude received from the device differs from the currently stored information. A satellite event is emitted whenever a given satellite (PRN) changes status.

Location Structure

{ 
  timestamp: 1311296682000,
  latitude: 45.456445,
  longitude: -73.569651667,
  altitude: 28.9,
  speed: 11,
  track: 10.3788,
  geometries: { 
    type: 'Point',
    coordinates: [ -73.569651667, 45.456445, 28.9 ] 
  } 
}

Examples

var Bancroft = require('bancroft');

var bancroft = new Bancroft();
bancroft.on('connect', function () {
  console.log('connected');
});
bancroft.on('location', function (location) {
  console.log('got new location');
});
bancroft.on('satellite', function (satellite) {
  console.log('got new satellite state');
});
bancroft.on('disconnect', function (err) {
  console.log('disconnected');
});

Features

  • Real-time location events.
  • Real-time satellite state events.
  • Location data includes geojson geometries Point format.

Installation

Requirements

This module assumes you have a working gps daemon accessible somewhere reacheable on the network along with a GPS tracking device up and running. This module has been tested with an old dusty Garmin eTrex Legend with a Serial->USB adapter cable using the NMEA data protocol. More devices have been reported to work with this modules.

Known Compatible Devices

  • Garmin eTrex Legend
  • GlobalSat BU-353

Mac OSX 64Bit

Support for gpsd is available from my own contribution to homebrew. However, as of this writing, pull request has yet to be merged into master.

Support for Serial-USB adapter also requires some special sauce. Basically,

wget -o osx-pl2303.kext.zip "http://sourceforge.net/tracker/download.php?group_id=157692&atid=804837&file_id=363913&aid=2952982"
unzip osx-pl2303.kext.zip
sudo cp -r ~/osx-pl2303.kext /System/Library/Extensions/
sudo kextload /System/Library/Extensions/osx-pl2303.kext
sudo ln -s /dev/tty.PL2303-* /dev/ttyUSB0 

Testing gpsd

$ sudo gpsd -D 2 -n -b -N -P /tmp/gpsd.pid /dev/ttyUSB0
$ gpspipe -w

Git Clone

$ git clone git://github.com/pdeschen/bancroft.git

Install from npm

$ sudo npm install bancroft [-g]

Todos

  • Hot swap device notify should be extracted in own module with emitter
  • Accumulate waypoints/route into kml?
  • Add options for non-moving position differential?
  • Extract message parser for better testability
  • Add mocha unit test
  • Automatic gpsd spawning with device hot-swapping

License

(The MIT License)

Copyright 2011-2012 Pascal Deschenes (pdeschen @ gmail . com) . All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bancroft's People

Contributors

iyogeshjoshi avatar jackwilsdon avatar pdeschen avatar tlhunter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bancroft's Issues

To provide other parameters

I'm using your module from long time now. It's really good and helpful thank you ๐Ÿ˜„ .
I need some extra parameters like ept, mode, epx, epv. I'm gettting them with the location data, I think you're filtering it out. Is it possible to add those parameters to the json object?

Reconnect option

Is there any option to reconnect if gpsd isn't running?

From my tests I see that if gpsd isn't running before brancroft there is no option to connect again..

Example not working

I have tried to run your example with a ND-100S GPS receiver, it displays 'connected' in the console however it does not show up message regarding location or satellites.

I have installed GPSD however it returns the following for the 'test':

$ sudo apt-get install gpsd
$ sudo gpsd -D 2 -n -b -N -P /tmp/gpsd.pid /dev/ttyUSB0
gpsd:INFO: launching (Version 3.6)
gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:ERROR: can't create IPv6 socket

The second test fails as well:

$ gpspipe -w
-bash: gpspipe: command not found

When running the app this is the output:

pi@raspberrypi ~/Desktop/pi $ sudo nodejs app.js
The "sys" module is now called "util". It should have a similar interface.
connected

Crashing when checking for location and no satellite/location available

It seems that after running my app a few times without establishing any GPS/satellite signal, when the location check runs it crashes and returns the following:

/home/pi/Desktop/picycle/node_modules/bancroft/bancroft.js:85
                for ( var index = 0; index < data.satellites.length; index++)
                                                            ^
TypeError: Cannot read property 'length' of undefined
    at Socket.<anonymous> (/home/pi/Desktop/picycle/node_modules/bancroft/bancroft.js:85:61)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)

Any ideas?

Sporadic bad message format

From time to time, message get splits between two poll. Should I look for \r along with \n?

error! { message: 'bad message format',
  cause: '{"class":"SKY","tag":"GSV","device":"/dev/ttyUSB0","xdop":2.11,"ydop":1.30,"vdop":3.10,"tdop":2.74,"hdop":2.00,"gdop":4.88,"pdop":3.70,"satellites":[{"PRN":2,"el":36,"az":254,"ss"',
  error:
   { stack: [Getter/Setter],
     arguments: [],
     type: 'unexpected_eos',
     message: [Getter/Setter] } }
error! { message: 'bad message format',
  cause: ':45,"used":true},{"PRN":4,"el":81,"az":288,"ss":41,"used":true},{"PRN":10,"el":39,"az":174,"ss":0,"used":false},{"PRN":12,"el":29,"az":313,"ss":39,"used":true},{"PRN":13,"el":5,"az":108,"ss":0,"used":false},{"PRN":17,"el":61,"az":101,"ss":44,"used":true},{"PRN":20,"el":24,"az":47,"ss":0,"used":false},{"PRN":23,"el":12,"az":80,"ss":0,"used":false},{"PRN":27,"el":5,"az":256,"ss":0,"used":false},{"PRN":28,"el":11,"az":165,"ss":0,"used":false}]}\r',
  error:
   { stack: [Getter/Setter],
     arguments: [ ':' ],
     type: 'unexpected_token',
     message: [Getter/Setter] } }

Time Sometimes String

With the device I'm using, a GlobalSat BU-353 the time reported by TPV events is actually a string. The device, not knowing the real time, seems to be starting at the date 2009-02-15 at midnight, and incrementing the seconds since the time the device first starts.

Here's some code I altered to log the data:
/* timestamp received is in seconds */ console.log('time', typeof(data.time), data.time); self.location.timestamp = data.time * 1000;

Here's the output:
time string 2009-02-15T00:13:47.050Z time string 2009-02-15T00:13:48.040Z time string 2009-02-15T00:13:49.040Z time string 2009-02-15T00:13:50.050Z

Once the string is multiplied by 1000, it of course becomes NaN.

I'm making this ticket here but I'll submit a fix myself via pull request.

I'm a little concerned about a fix though; my device always starts at the same date, but will other devices start at other arbitrary dates? Has anyone else used this module with different devices and had similar issues? Also, what is the timestamp supposed to be anyway, a UNIX time integer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.