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

failed parse some MessageType5 data , it throw 'MissingMultipartMessageException' #85

Closed
icoco opened this issue Oct 8, 2022 · 6 comments
Labels
question Further information is requested

Comments

@icoco
Copy link

icoco commented Oct 8, 2022

face this problem, the decode.py code logic bellow:

# Make sure provided parts assemble a single (multiline message)
  if len(args) > frag_cnt:
      raise TooManyMessagesException(f"Got {len(args)} messages, but fragment count is {frag_cnt}")

while parse string :
!AIVDM,2,1,6,A,55MwgS`00001L@?;OK80b022220l1@:44vT4,0*6B

it throw exception:

 raise MissingMultipartMessageException(f"Missing fragment numbers: {diff}")
pyais.exceptions.MissingMultipartMessageException: Missing fragment numbers: [2]

what is the reason ?

if I comment the check logic , then all things works fine , anyone can give tip for this case ?

@mihermans
Copy link

Like the message indicates, it misses the second part of the multipart message.
This message should start with !AIVDM,2,2,6..... in this case (the first digit indicates it is a multipart and the second digit if it is the first or second part of the message, the third digit indicates which messages belong together)

@icoco
Copy link
Author

icoco commented Oct 8, 2022

I use other way then no error report, the code below:
```
data = b'!AIVDM,2,1,6,A,55MwgS`00001L@?;OK80b022220l1@:44vT4,0*6B'
message = NMEAMessage(data)
decoded = message.decode()


@mihermans 
so, your meaning is the original data is wrong format ? 

@M0r13n
Copy link
Owner

M0r13n commented Oct 8, 2022

@mihermans is totally right. The error is pretty clear: You are trying to decode a multi fragment message. Such messages are too big to fit into the 82 character maximum of NMEA 0183 messages. Therefore, long messages are fragmented into multiple fragments. In order to decode a fragmented message, all fragments need to be assembled before the message is decoded.

Imagine that you want to send a very big package to someone. Your package is too big to fit into a single parcel. Therefore, you split the package into multiple smaller packages. Each package can then be shipped in its own parcel. The receiver of the packages then needs to receive all packages before he can reassemble the original package. Otherwise the package would be incomplete.

In your case the message !AIVDM,2,1,6,A,55MwgS00001L@?;OK80b022220l1@:44vT4,0*6B starts with !AIVDM,2,1, which means that the message is fragmented into two (2) NMEA messages and you are trying to decode only the first (1) part of it. Instead you need to pass all parts to the decode() method.

I use other way then no error report, the code below:

This may not raise an exception. But it is still wrong. The decoded message is invalid, because half of it is missing.

@M0r13n M0r13n added the question Further information is requested label Oct 8, 2022
@M0r13n M0r13n closed this as completed Oct 8, 2022
@icoco
Copy link
Author

icoco commented Oct 8, 2022

so then, how to solve this issue ? sorry maybe my question is stupid :-|

@M0r13n
Copy link
Owner

M0r13n commented Oct 8, 2022

This is not an issue. This is expected behavior. You need to pass both parts the decode function - not just the first

@icoco
Copy link
Author

icoco commented Oct 9, 2022

got it... thanks all

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

No branches or pull requests

3 participants