bertoldvdb / go-ais Goto Github PK
View Code? Open in Web Editor NEWAutomatic Identification System (ITU-R M.1371-5) packet decoder and encoder written in Go
License: MIT License
Automatic Identification System (ITU-R M.1371-5) packet decoder and encoder written in Go
License: MIT License
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")
}
}
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()
}
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
.
There is a typo in 2 field names in StaticDataReportB
https://github.com/BertoldVdb/go-ais/blob/master/messages.go#L306-L307
s/vender/vendor/
Hey,
Thanks for go-ais!
I ran into a little surprise this week when we noticed that type 9 StandardSearchAndRescueAircraftReport
does not encode its Sog
field like the others:
Line 126 in fd4fd5b
It has a plain uint16
rather than a Field10
which decodes to scaled float.
Fixing this is a breaking change, but it also seems like a better experience to be able to count on all 10-bit SOG fields being handled the same (Type 27 6-bit SOG is obviously an exception).
Thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.