Coder Social home page Coder Social logo

Panic when parsing message about nmea-parser HOT 1 OPEN

zaari avatar zaari commented on July 19, 2024
Panic when parsing message

from nmea-parser.

Comments (1)

matt24smith avatar matt24smith commented on July 19, 2024

This is a challenging issue, as far as I can tell, the code in this package is correct and the issue arises with malformed messages and dependent libraries.

The panics appear to be caused by malformed UTC date response and binary application messages - I only care about vessel data, so in my case, I can safely discard these before decoding using the following function.

/// discard UTC date response and binary application payloads before decoding them
pub fn msgfilter(msg: &str) -> Option<&str> {
    if &msg.chars().count() >= &15 && &msg[..12] == "!AIVDM,1,1,," {
        match &msg[12..13] {
            "0" | "1" | "2" | "3" | "A" | "B" => match &msg[14..15] {
                ";" | "I" | "J" => None,
                _ => Some(msg),
            },
            _ => Some(msg),
        }
    } else {
        Some(msg)
    }
}

I imagine not everybody will need the binary application messages, would it make sense to skip these by default with an option to decode?

from nmea-parser.

Related Issues (14)

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.