Giter Site home page Giter Site logo

ricardoboss / dart_nmea Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 95 KB

An extensible NMEA0183 parser written 100% in dart.

Home Page: https://pub.dev/packages/nmea

License: MIT License

Dart 100.00%
cross-platform flutter library nmea nmea-parser nmea0183 dart

dart_nmea's Introduction

Pipeline

dart_nmea Logo nmea

An extensible NMEA0183 parser.

Take a look at the example to see how to use it.

Usage

// 1. declare your sentences (use TalkerSentence and ProprietarySentence)
class AbcSentence extends TalkerSentence {
  AbcSentence({required super.raw});
  
  String get data => fields[1];
  
  @override
  bool get valid => super.valid && fields.length == 2;
}

// 2. register your sentences
final decoder = NmeaDecoder()
  ..registerTalkerSentence("ABC", (line) => AbcSentence(raw: line));

// 3. decode a line
final sentence = decoder.decode("\$--ABC,123456789*5D");

// 4. consume your sentences
print(sentence.valid); // true
print(sentence.checksum); // 5D
print(sentence.source); // --
if (sentence is AbcSentence) {
  print(sentence.data); // 123456789
}

You can also use it as a StreamTransformer for a stream of Strings:

final stream = Stream.fromIterable(["\$--ABC,123456789*5D", "\$--DEF,987654321*5D"]);
final transformed = stream.transform(decoder);
transformed.listen((sentence) {
  print(sentence.valid); // true
  print(sentence.checksum); // 5D
  print(sentence.source); // --
  if (sentence is AbcSentence) {
    print(sentence.data); // 123456789
  }
});

dart_nmea's People

Contributors

ricardoboss avatar wackymax avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wackymax rightfs

dart_nmea's Issues

Support for custom sentences (non-standard)

From my discussion with @Wackymax at: 91a5d73#commitcomment-81132865

Data sent from some devices deviate from the NMEA0183 standard and provide sentences in a different format than what is expected (i.e. talker sentences without talker ID, sentences without $ in the beginning?).

While this is not great, it would be nice to at least add basic support for handling these cases.

Add support for split messages

Some sentences like GSV are split up into multiple messages.

The decoder could buffer those until all messages are received and then forward them as a single sentence.

I think a special MultipartNmeaSentence class is needed, which can access fields from multiple NmeaSentence instances. It should at least be able to aggregate multiple data fields.

Extensibility is also important. For example if the user wants to implement a custom message, it should be easy to re-use this MultipartNmeaSentence.

Limit size of `_incompleteSentences` in `NmeaDecoder`

Currently, the number of incomplete MultipartSentences held in NmeaDecoder and filled in bind, is unlimited.

This, however, could lead to a possible memory leak if the input stream produces only incomplete sentences (e.g., sent by a defective NMEA0183 device).

A solution would be to convert the _incompleteSentences field from a List<MultipartSentence<dynamic>> to a data structure which has a limited backlog and acts as a FIFO buffer (circular buffer).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.