0

New to this Pi world and what not but I know some JS and am using the Johnny-Five library.

I used raspi-config to disable Serial/USB Console and Enabled Serial interface. I've also added enable_uart=1 config.txt.

Running cat /dev/serial0 from the command like outputs a stream of data from the GPS unit and seems to be doing it's job. Nonetheless, I'm having an issue with Pin 10 receiving data from the GPS Unit. When I run my code below it throws the error:

Error: Pin "10" does not support mode "other"

var five = require("johnny-five");
var Raspi = require("raspi-io");
var board = new five.Board({
  io : new Raspi({ enableSerial : true /* apparently required as per raspi-io docs */ })
});

    board.on("ready", function() {
        const gps = new five.GPS({
            pins : {
                    rx : 'P1-10',
                    tx : 'P1-8',
            }
    });

    gps.on("data", () => {
            console.log("position");
            console.log(" latitude  : ", this.latitude);
            console.log(" longitude : ", this.longitude);
            console.log(" altitude  : ", this.altitude);
            console.log("———————————————————————————————————");
    });

});
heyron
  • 1
  • 1
  • With the GPS attached, do you get output when you do cat /dev/ttyS0? – stevieb May 24 '17 at 22:05
  • I do not. I get a response of :

    cat: /dev/ttyS0: Input/output error

    – heyron May 24 '17 at 22:41
  • I would suggest you ignore that rant you linked. If you want a technical explanation read How-do-i-make-serial-work-on-the-raspberry-pi3. You DO NOT need to fiddle with any files, raspi-config will enable serial. You have NOT told us what you actually did. NOTE you should use /dev/serial0 rather than any other designation. – Milliways May 24 '17 at 23:18
  • Thank you for that link. Will go through it more thoroughly. In short, I made the minor edits to config.txt - added "enable_uart=1" no changes to cmdline.txt. I went through raspi-config to enable serial.

    this might seem a bit ignorant but how do i use /dev/serial0 from within a node app?

    – heyron May 24 '17 at 23:45
  • Kind of answered my own question on where /dev/serial0 is accessed - they're pins 14/15 at physical locations 8 and 10.

    the issue still stands that the pin does not support mode 'other' which i can't seem to find a definitive answer for

    – heyron May 25 '17 at 00:01
  • You still haven't said what you did. Paste actual commands and files into your question NOT comments. /dev/serial0 is a character device. You open and read and write to the device. I have no idea how to do this in JS, but there are hundreds of examples for Python, C etc. Linux programs generally do not access hardware directly, but through the /devinterface. – Milliways May 25 '17 at 07:10
  • Got it. Added said info to post - pretty sure that covers it for what I've done up to this point. Thanks for the continued help. – heyron May 25 '17 at 19:54

0 Answers0