Shop OBEX P1 Docs P2 Docs Learn Events
Combining data from multiple NMEA sources — Parallax Forums

Combining data from multiple NMEA sources

KidEKidE Posts: 29
edited 2012-04-17 09:28 in Propeller 1
Hi Guys,

I have 2 devices (both NMEA0183 compatible GPS + depthsounder) and i would like to merge both streams and output them as 1 serial stream to an xbee.
I've experimented with the NMEA parsers from the OBEX and found that i'm able to use the contents of the streams but i'm unable to output (route) the complete stream.

Obviously i overlooked something here so a small hint would be appreciated.

It's a newby talking here so have mercy ;-)

Regards,

Ernst

Comments

  • Mark_TMark_T Posts: 1,981
    edited 2012-04-17 02:04
    Two things:

    Is there any need to parse the streams other than to read whole lines from each source and preventing any interleaving between lines?

    Secondly will you need to identify the source for each line later? Tagging the output lines with a character prefix would be a simple way to achieve this?

    An NMEA sentence is a self contained message body, so seems the obvious granularity at which to combine the streams. Unfortunately the NMEA specification lacks an ID field in the sentences to identify the precise originating device (seems a silly oversight if you think about the design goal of NMEA to combine information from onboard navigation devices - clearly not designed by any expert in the field of network protocols!!)
  • KidEKidE Posts: 29
    edited 2012-04-17 02:35
    Hi Mark,

    The Sources have their own identification (not really individual ID but more message type ID) which has been specified in the NMEA protocol. GPS has e,g, INRMC or INGGA and the sounder has an INDPT

    INPUT Device 1: <ID>GGA......
    INPUT Device 2: <ID>DPT.......

    OUTPUT should contain both lines:
    <ID>GGA......
    <ID>DPT.......

    So the thing i need to accomplish is just forwarding the complete sentence to another port. Nothing more fancy as that.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-04-17 09:28
    The GGA sentence should appear once per second, probably interleaved with other sentences from your GPS. How often the depth data appears depends upon your sounder. This is how I would approach the problem:
    1. Have one cog monitoring the GPS and another monitoring the sounder.
    2. Whenever the GPS encounters a GGA string, put it in a buffer and set a flag, unless the flag is already set.
    3. Whenever the sounder encounters a DPT string, put it in another buffer and set a flag, unless the flag is already set.
    4. Yet another cog will monitor the flags, giving preference to the GGA flag. When it sees a flag that's set, it will send the data from the buffer, then reset the associated flag.

    The downside to this scheme is that neither sentence that's sent will be concurrent with the one being received, and the depth data, if it's sent at a rate faster than one per second, may not be the most recent value when it gets preempted by the GPS. But that's the price you have to pay for merging two asynchronous data streams.

    -Phil
Sign In or Register to comment.