Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing io.SERIAL_PORT_IDs implementation? #23

Open
joshunger opened this issue Oct 24, 2018 · 6 comments
Open

Missing io.SERIAL_PORT_IDs implementation? #23

joshunger opened this issue Oct 24, 2018 · 6 comments

Comments

@joshunger
Copy link

io.SERIAL_PORT_IDs is returning undefined for me. Is this supposed to be implemented?

TypeError: Cannot read property 'DEFAULT' of undefined
    at e.initialize (/tmp/remote-script/node_modules/johnny-five/lib/gps.js:1:2314)
    at new e (/tmp/remote-script/node_modules/johnny-five/lib/gps.js:1:1156)
    at t.<anonymous> (/tmp/remote-script/gps.js:1:227)
    at emitNone (events.js:111:20)
    at t.emit (events.js:208:7)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
@dtex
Copy link
Contributor

dtex commented Oct 24, 2018

Wow... that's weird. It is totally missing. I can't even find a time in github history when it existed and this code is over three years old... but it worked... I've used it.

I'll get back to the postmortem later. In the meantime, I'll get a fix for you ASAP.

I don't have a GPS or other serial device I can test with (or a T2 for that matter). If I send you a tweak for tessel-io/lib/index.js can you try it out for me?

@dtex
Copy link
Contributor

dtex commented Oct 24, 2018

If you're in a hurry, just change this line in node_modules/johnny-five/lib/gps.js

state.portId = opts.serialPort || opts.portId || opts.port || opts.bus || this.io.SERIAL_PORT_IDs.DEFAULT;

to

state.portId = opts.serialPort || opts.portId || opts.port || opts.bus;

and make sure you specify port: "A" in your GPS opts.

I need to noodle over wether this should be fixed in Johnny-Five or tessel-io.

@joshunger
Copy link
Author

Excellent, thanks for the help @dtex !

@joshunger
Copy link
Author

@dtex are there any big benefits of using GPS vs. just consuming the Tessel UART stream directly?

@dtex
Copy link
Contributor

dtex commented Oct 24, 2018

There is no black magic in the J5 GPS code. Configuration is a little easier and having the GPS be an event emitter is helpful. Also, you don't have to worry about parsing the NMEA sentences yourself.

@bart
Copy link

bart commented Jan 16, 2019

I got the exact same issue. Your quick fix solved it but now I'm getting this error here:

>> events.js:239
    throw new TypeError('"listener" argument must be a function');
    ^

TypeError: "listener" argument must be a function
    at _addListener (events.js:239:11)
    at UART.addListener (events.js:297:10)
    at UART.Readable.on (_stream_readable.js:772:35)
    at P.serialRead (/tmp/remote-script/node_modules/tessel-io/lib/index.js:1:8634)
    at e.listen (/tmp/remote-script/node_modules/johnny-five/lib/gps.js:1:2975)
    at e.<anonymous> (/tmp/remote-script/node_modules/johnny-five/lib/gps.js:1:2640)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

@dtex Do you have any idea? My code is super basic:

"use strict";

const five = require("johnny-five");
const Tessel = require("tessel-io");
const board = new five.Board({
  io: new Tessel()
});

board.on("ready", () => {
  var gps = new five.GPS({
  	port: 'A',
    pins: {rx: 6, tx: 5}
  });

  // If latitude, longitude change log it
  gps.on("change", function() {
    console.log("position");
    console.log("  latitude   : ", this.latitude);
    console.log("  longitude  : ", this.longitude);
    console.log("  altitude   : ", this.altitude);
    console.log("--------------------------------------");
  });
  // If speed, course change log it
  gps.on("navigation", function() {
    console.log("navigation");
    console.log("  speed   : ", this.speed);
    console.log("  course  : ", this.course);
    console.log("--------------------------------------");
  });
});

rwaldron pushed a commit to rwaldron/johnny-five that referenced this issue Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants