kinisi / kinisi-agent-nodejs

Kinisi Agent written in NodeJS
MIT License
1 stars 0 forks source link

Support GPS Dongle on USB1 on Raspberry Pi Model B #6

Open aeratek opened 10 years ago

aeratek commented 10 years ago

It would be nice if the GPS dongle could also be used with the USB1 (top-most) USB slot. I have had issues, where I'll plug in the GPS dongle into USB1 and the Node.js agent will not gather data. The log files show that the agent is listening on USB0, when the GPS dongle is plugged into USB1 (example log pasted below). Making the agent smarter and able to determine which USB slot the GPS dongle is plugged into will make it easier for customers, so that they will not need to be told "it will only work if you plug it into USB0".

2014-07-10T00:20:54.519Z Got data: { class: 'TPV', tag: 'MID2', device: '/dev/ttyUSB0', mode: 1, time: '2014-07-10T13:15:03.340Z', ept: 0.005 } 2014-07-10T00:20:55.619Z Unwatching GPS. 2014-07-10T00:20:55.650Z Sending: echo 0 > /sys/class/leds/led0/brightness 2014-07-10T00:20:55.698Z child process exited with code 0 2014-07-10T00:21:00.660Z Read 0 data points. 2014-07-10T00:21:00.701Z Checkup error: getaddrinfo ENOTFOUND 2014-07-10T00:21:01.619Z Watching GPS... 2014-07-10T00:21:03.628Z Unwatching GPS. 2014-07-10T00:21:03.646Z Sending: echo 0 > /sys/class/leds/led0/brightness 2014-07-10T00:21:03.671Z child process exited with code 0 2014-07-10T00:21:09.635Z Watching GPS...

aeratek commented 10 years ago

Update: Moving this to Bug instead of Enhancement. Customer stated this past week that USB1 is working on older code and Raspberry Pi Model B. Additional internal testing by Jeff showed USB1 is working, as well. Issue may only be present on my setup. Will test further before closing this Bug/Issue as "unable to duplicate" as resolution.

sajacy commented 10 years ago

The agent code expects to find the GPS device writing to the file /dev/ttyUSB0 - and it seems the top slot is consistently assigned to /dev/ttyUSB0 when the following procedure is used (this was tested and worked consistently):

  1. Plugging Wifi dongle on bottom slot.
  2. Plugging GPS dongle on top slot.
  3. Turning on Pi.

The note on the GPSd FAQ page seems to provide an explanation for how to recreate the bug.

In a default Linux configuration, USB serial device name do not depend on which physical port you plug the USB/serial adaptor, but on what order you plug devices in: 1st device gets /dev/ttyUSB0, 2nd gets /dev/ttyUSB1, etc....

So the following procedure might recreate the issue:

1a. Turning on Pi without any USB devices, then plugging in Wifi dongle, into either slot, OR 1b. Plugging Wifi dongle first, into either slot, then turning on Pi (expect WiFi assigned as /dev/ttyUSB0)

  1. Plugging GPS after turning on Pi, into remaining slot (may result in being assigned to /dev/ttyUSB1)

I'll try it soon and comment again.

trevorcarlson commented 10 years ago

Guys,

I worked on this a few months ago. I added a file to the scripts directory (71-kinisi.rules) [1] that automatically assigns the GPS dongle that we use to /dev/gps0. It does this through identification of the model and product IDs. Did you try using this rules script and updating it for your GPS device? Once you do that, we can then setup the gpsd configuration to point to /dev/gps0 instead of USB0, 1, etc.

Trevor

[1] https://github.com/kinisi/kinisi-agent-nodejs/blob/master/scripts/71-kinisi.rules

sajacy commented 10 years ago

Where does this rules file get installed? Can you update the setup instructions in the POC Setup, GPSd Installation section?