Skip to content

Commit

Permalink
fix problem with error handling and trunked messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeschen committed Jul 26, 2011
1 parent 11904e6 commit a361e73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions bancroft.js
Expand Up @@ -39,7 +39,13 @@ var Bancroft =
var info = payload.split('\n');
for ( var index = 0; index < info.length; index++) {
if (info[index]) {
try {
var data = JSON.parse(info[index]);
}
catch(error) {
emitter.emit('error', {message: "bad message format", cause: info[index], error: error});
continue;
}
if (data.class === 'VERSION') {
emitter.emit('connect', {
'release' : data.release,
Expand Down
18 changes: 18 additions & 0 deletions issues.textile
@@ -0,0 +1,18 @@
# bad message format

From time to time, message get splits between to 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] } }
7 changes: 6 additions & 1 deletion readme.textile
Expand Up @@ -26,7 +26,7 @@ h3. Location Structure
h2. Examples

<pre>
var Bancroft = require('./bancroft.js');
var Bancroft = require('bancroft');

var bancroft = new Bancroft();
bancroft.on('connect', function () {
Expand Down Expand Up @@ -56,6 +56,11 @@ h3. Requirements

This module assumes you have a working "gps daemon":http://gpsd.berlios.de 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.

h4. Testing gpsd

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

h3. Git Clone

@$ git clone git://github.com/pdeschen/bancroft.git@
Expand Down

0 comments on commit a361e73

Please sign in to comment.