Giter Site home page Giter Site logo

go-ais's People

Contributors

bertoldvdb avatar fhedberg avatar quartercastle avatar simeonmiteff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-ais's Issues

Handle multipart messages

Looks like this package is having issues with multi part messages. This test can be added to nmea_test.go to show the issue:

func TestMultiMessage(t *testing.T) {
	nm := NMEACodecNew(ais.CodecNew(false, false))
	_, err := nm.ParseSentence("!AIVDM,2,1,0,B,539S:k40000000c3G04PPh63<00000000080000o1PVG2uGD:00000000000,0*34\n!AIVDM,2,2,0,B,00000000000,2*27")

	if err != nil {
		t.Error(err)
		t.Error("Can't handle multipart message")
	}
}

PositionReport.RateOfTurn is I3, which is different than int8.

The PositionReport struct defines RateOfTurn as int8. This precludes the value of 128, which is used for "no turn information available". The source of the problem is a difference in interpretation of an AIS data type. Eric Raymond's documentation for AIVDM messages defines this field as I3, which, if I'm understanding correctly, means "signed three digit decimal integer", which could (and does) have values that don't fit into an int8.

Failure to decode some static data reports

go-ais fails decode a number of Static Data Report (type 24) messages that I am able to decode using other AIS decoders. Example code is shown below. DecodePacket returns null for all of the failed messages.

package main

import (
	"encoding/json"
	"fmt"
	"github.com/BertoldVdb/go-ais"
	"github.com/adrianmo/go-nmea"
	"log"
	"time"
)

func scanMessages() {
	sentences := []string{
		// A couple of good (decodable) messages for reference
		"\\s:66,c:1636156800*34\\!AIVDM,1,1,,,34hA4u0P00PDW7BMeJJPCOwn23U3,0*54",
		"\\s:66,c:1636156800*34\\!AIVDM,1,1,,,14eGsMw000G;;U0KdwfaBG`02400,0*17",
		// All of these remaining messages fail to decode
		// Although they all decode successfully using http://ais.tbsalling.dk/
		"\\s:66,c:1635752275*3D\\!AIVDM,1,1,,,HpuGhQ5G653hhhiJBniqnP02@0p,2*57",
		"\\s:66,c:1635784819*36\\!AIVDM,1,1,,,Hcwo0G?8=aOCkl`k:v?Flhve4@7`,0*79",
		"\\s:66,c:1635794719*38\\!AIVDM,1,1,,,HofeSn4U653hhhi5mEjnqh03008,2*17",
		"\\s:66,c:1635801587*3E\\!AIVDM,1,1,,,H6`U8m=<0oes>>g8j6UEmPR9wNdk,0*42",
		"\\s:66,c:1635801603*31\\!AIVDM,1,1,,,Hks<bFcb:7HFeVsm8D:qA:20Njai,0*62",
		"\\s:66,c:1635801633*32\\!AIVDM,1,1,,,H>LKae;muCahwBwtHgNcFrehwKEI,0*46",
		"\\s:66,c:1635801699*32\\!AIVDM,1,1,,,HHsNBIsW<cSVppkL3v>@otg@=QsT,0*44",
		"\\s:66,c:1635801743*34\\!AIVDM,1,1,,,Hv?eMg<jmmwN=gowL94@DRwmOULj,0*35",
		"\\s:66,c:1635801787*3C\\!AIVDM,1,1,,,HudKH=Nwv7JW@fVi;IbV`i?Gs1la,0*04",
		"\\s:66,c:1635801845*3D\\!AIVDM,1,1,,,H3w65Weu;U4biowGKqdo2dNp8R:b,0*4A",
		"\\s:66,c:1635807283*3B\\!AIVDM,1,1,,,Hq9D:bH?J9nvT8ptm>C1aqrGN8:L,0*0B",
		"\\s:66,c:1635807331*33\\!AIVDM,1,1,,,HsqF@Nw4PKaa9t8=lT;V?=4RG2MS,0*2F",
		"\\s:66,c:1636157735*3C\\!AIVDM,1,1,,,Hfdmqq`JtNMtbj<kKS`sfKfwusw?,0*4F",
		"\\s:66,c:1636185526*33\\!AIVDM,1,1,,,HmBhv256>hhhhhh8@nkoj005@0l,2*42",
		"\\s:66,c:1636185666*34\\!AIVDM,1,1,,,HofeSn4U653hhhi5mEjnqh03008,2*17",
		"\\s:66,c:1636201729*31\\!AIVDM,1,1,,,HG`k1qf?Vw=k5fHphLpcw;>cvdl;,0*05",
		"\\s:66,c:1636206977*33\\!AIVDM,1,1,,,HopN@TK<n?W45I49N4J9@2ljdpn0,0*69",
		"\\s:66,c:1636207057*39\\!AIVDM,1,1,,,HQ>s17u4NBTBw`wVBANq>hGGdMEu,0*2B",
		"\\s:66,c:1636207065*38\\!AIVDM,1,1,,,H:`AD`KLUSb2B=OQ5=L9rkSW;1ej,0*45",
		"\\s:66,c:1636234777*3C\\!AIVDM,1,1,,,HW<AV>;Wvk8M:ObuVLaqdB1gVvT1,0*34",
		"\\s:66,c:1636234779*32\\!AIVDM,1,1,,,HVuEL8tf<kS60UTb4Be@H?1im@ls,0*00",
		"\\s:66,c:1636234783*37\\!AIVDM,1,1,,,H?O5=MuFtu@PJsJc28TrC4THnl7:,0*60",
		"\\s:66,c:1636234798*3D\\!AIVDM,1,1,,,HCNiwp<d<4Ghd2Cp2kNmh6NAf9nW,0*1B",
		"\\s:66,c:1636234803*30\\!AIVDM,1,1,,,Hfr<;DcJ7o@ccqc`tnanMImBVSrQ,0*23",
		"\\s:66,c:1636234875*31\\!AIVDM,1,1,,,HRu6baIn`@VVPNg9I0;`bnbiNrtA,0*56",
		"\\s:66,c:1636234889*32\\!AIVDM,1,1,,,HO9G<hfhWWlD>J4QU>t5o06hbO77,0*7B",
		"\\s:66,c:1636234937*36\\!AIVDM,1,1,,,H3uVqHJ<4d9D6ldUEb=3BW;sUU42,0*44",
		"\\s:66,c:1636234953*34\\!AIVDM,1,1,,,HVep8kw<A>WKCo;OG92=3GL26NCG,0*48",
		"\\s:66,c:1636235011*3A\\!AIVDM,1,1,,,HawEMMpEkTTa7wfQmmWbBkH<ASV9,0*21",
		"\\s:66,c:1636235071*3C\\!AIVDM,1,1,,,H6do9?tAlK94dUB4Keainou4UmK=,0*64",
		"\\s:66,c:1636235165*38\\!AIVDM,1,1,,,H2JTKGccrJe19rw=UQ<n2uV682sM,0*27",
		"\\s:66,c:1636235245*39\\!AIVDM,1,1,,,HqN;>M8EFTrLlwKRMuvH7@D6;Md<,0*26",
	}

	c := ais.CodecNew(false, false)
	c.DropSpace = true

	for _, sentence := range sentences {
		s, err := nmea.Parse(sentence)
		if err != nil {
			log.Fatalf("parsing error %d\n", err)
		}
		parsed := s.(nmea.VDMVDO)
		log.Printf("TAG Block timestamp: %v\n", time.Unix(parsed.TagBlock.Time, 0))
		log.Printf("TAG Block source:    %v\n", parsed.TagBlock.Source)

		msg := parsed.Payload
		result := c.DecodePacket(msg)
		out, _ := json.MarshalIndent(result, "", "  ")
		fmt.Printf("%T: %s\n", result, out)
	}
}

func main() {
	scanMessages()
}

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.