Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

processing multiline / segmented messages #98

Open
metemaad opened this issue Aug 11, 2022 · 6 comments
Open

processing multiline / segmented messages #98

metemaad opened this issue Aug 11, 2022 · 6 comments

Comments

@metemaad
Copy link

I could not find an example for processing AIS 5 message here. This type of message has more than one line for example:

\g:1-2-3730,s:43576,c:1654340281,t:165434038119!AIVDM,2,1,7,,569EH`8000009aGUB20IF1UD4r1UF3OK7>22220N4PT38t0000000000,042

\g:2-2-37305A!AIVDM,2,2,7,,000000000000000,262

Is there any way to process such cases?

@nilsmagnus
Copy link

Same here, I am not able to parse AIS 5 messages of this kind

@nilsmagnus
Copy link

Since this issue is solved in the master branch, could you add a new tag?

@icholy
Copy link
Collaborator

icholy commented Aug 17, 2023

cc @adrianmo

@kimgr
Copy link

kimgr commented Mar 16, 2024

Since this issue is solved in the master branch, could you add a new tag?

@nilsmagnus Could you point me to where this is solved? I haven't found any facilities in go-nmea for multiline reassembly, and I'm curious if I've just been looking in the wrong places. Thanks!

@aldas
Copy link
Collaborator

aldas commented Mar 16, 2024

Try this

func TestName(t *testing.T) {
	var tagBlocks []TagBlock
	p := SentenceParser{
		OnTagBlock: func(tb TagBlock) error { // one way
			tagBlocks = append(tagBlocks, tb)
			return nil
		},
	}
	m, err := p.Parse("\\g:1-2-73874,n:157036,s:r003669945,c:1241544035*4A\\!AIVDM,1,1,,B,15N4cJ`005Jrek0H@9n`DW5608EP,0*13")
	if err != nil {
		t.Fatal(err)
	}
	bs, ok := m.(BaseSentence) // another way
	if ok {
		fmt.Printf("Tagblock: %+v\n", bs.TagBlock)
	}

	fmt.Printf("Tagblocks: %+v\n", tagBlocks)
}

This should output that single parsed tag block as

[{Time:1241544035 RelativeTime:0 Destination: Grouping:1-2-73874 LineCount:157036 Source:r003669945 Text:}]

assembly is up to you to implement.

@kimgr
Copy link

kimgr commented Mar 16, 2024

@aldas Thanks --

assembly is up to you to implement.

Ah, yeah, then I hadn't missed anything. I got the impression from above that there was reassembly support built in somewhere. Thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants