Code Monkey home page Code Monkey logo

Comments (8)

M0r13n avatar M0r13n commented on August 28, 2024 1

Should be fixed with version 2.2.1

from pyais.

M0r13n avatar M0r13n commented on August 28, 2024

@bgercken Thank you for bringing this up. I will look at this but as soon as time allows. But it might take a couple of days.

from pyais.

bgercken avatar bgercken commented on August 28, 2024

No hurry on my part. Thank you very much.

from pyais.

M0r13n avatar M0r13n commented on August 28, 2024

@bgercken

Could you provide me some example that led to this issue? I am not able to reproduce the described behavior.

from pyais.

bgercken avatar bgercken commented on August 28, 2024

Below is output for encoding the following data.

data: {'type': 5, 'repeat': 0, 'mmsi': '538008122', 'ais_version': 1, 'imo': 9500091, 'callsign': 'V7GS3', 'shipname': 'CLIPPER BAROLO', 'shiptype': 70, 'to_bow': 166, 'to_stern': 30, 'to_port': 22, 'to_starboard': 10, 'epfd': 1, 'month': 5, 'day': 16, 'hour': 0, 'minute': 30, 'draught': 6.6, 'destination': 'BALTIMORE', 'dte': 0}

sentence: !AIVDO,2,1,0,A,5815J>T2@uKeKLM?<00<hU10E:0858tht0000000DhNF:5H0N@PPC52CClQ@0,0*28 (81)

sentence: !AIVDO,2,2,0,A,0000000000,2*16 (30)

UPDATE: actually 81 is too long. When you append the NMEA terminator it exceeds the max sentence length.

from pyais.

bgercken avatar bgercken commented on August 28, 2024

I had closed this but it still appears to be an issue.

Updated test fails:

from pyais import encode_dict

data = {
    'type': 5, 'repeat': 0, 'mmsi': '259725000', 'ais_version': 1, 'imo': 9103128, 'callsign': 'LAXP4',
    'shipname': 'STAR HANSA', 'shiptype': 70, 'to_bow': 177, 'to_stern': 22, 'to_port': 17, 'to_starboard': 14,
    'epfd': 1, 'month': 5, 'day': 20, 'hour': 6, 'minute': 0, 'draught': 7.4, 'destination': 'US BAL', 'dte': 0
}


# Maximum sentence length, including the $ and <CR><LF> is 82 bytes.
NMEA_MAX_LEN = 82
NMEA_TERMINATOR = "\r\n"


def test_encode_type5():
    encoded = encode_dict(data)
    for i in range(len(encoded)):
        encoded[i] += NMEA_TERMINATOR
        assert len(encoded[i]) <= NMEA_MAX_LEN


if __name__ == "__main__":
    test_encode_type5()

from pyais.

M0r13n avatar M0r13n commented on August 28, 2024

Thank you. I am pretty sure that I forgot to include the final <LF> terminator when calculating the total length of a message. I will fix this tomorrow.

from pyais.

M0r13n avatar M0r13n commented on August 28, 2024

@bgercken

You were right. The max payload length should be set to 60 and not 61. The docstring of the relevant method actually mentions this:

This method takes care of splitting large payloads (larger than 60 characters)
into multiple sentences. With a total of 80 maximum chars excluding end of line
per sentence, and 20 chars head + tail in the nmea 0183 carrier protocol, 60
chars remain for the actual payload.

But then the implementation sets max_len to 61 (see).

from pyais.

Related Issues (20)

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.