schwehr / libais

C++ decoder for Automatic Identification System for tracking ships and decoding maritime information
Other
215 stars 94 forks source link

KeyError: 'decoded' in DecodeTagMultiple #234

Open andyvan-trabus opened 2 years ago

andyvan-trabus commented 2 years ago

I saw the following exception:

python3 test_234.py Traceback (most recent call last): File "test_234.py", line 9, in queue.put(line, line_no) File "/home/avanpelt/git/TMP/FORK/libais-fork/ais/tag_block.py", line 171, in put decoded = DecodeTagMultiple(entry) File "/home/avanpelt/git/TMP/FORK/libais-fork/ais/tag_block.py", line 225, in DecodeTagMultiple return msg['decoded'] KeyError: 'decoded'

Here are the lines exactly as they were in the original test file:

10/07/19 17:36:42:075 \s:49\g:1-2-11262,n:235196,s:r17MDUT1,c:157046979849!AIVDM,2,1,9,A,55Na3b400001L@W;3GTu84<hF22000000000000N0p:,078 10/07/19 17:36:42:075 \s:49\g:2-2-11262,n:23519718!AIVDM,2,2,9,A,44t0Ht:000000000000000000000,,041

Here's my test code:

from ais import tag_block

TEST_MESSAGES = ['10/07/19 17:36:42:075 \s:49\g:1-2-11262,n:235196,s:r17MDUT1,c:157046979849\!AIVDM,2,1,9,A,55Na3b400001L@W;3GTu84<hF22000000000000N0p:,078', '10/07/19 17:36:42:075 \s:49\g:2-2-11262,n:23519718\!AIVDM,2,2,9,A,44t0Ht:000000000000000000000,,041']

queue = tag_block.TagQueue()

for line_no, line in enumerate(TEST_MESSAGES): queue.put(line, line_no)

msgs = [] while not queue.empty(): msgs.append(queue.get())

Here's what msg was: {'line_nums': [2], 'lines': ['!AIVDM,2,2,9,A,44t0Ht:000000000000000000000,,0*41']}

andyvan-trabus commented 2 years ago

I just realized that the quote tag didn't exactly preserve things, so here's the test code again, but with the code tag:

from ais import tag_block

TEST_MESSAGES = ['10/07/19 17:36:42:075 \\s:*49\\g:1-2-11262,n:235196,s:r17MDUT1,c:1570469798*49\\!AIVDM,2,1,9,A,55Na3b400001L@W;3GTu84<hF22000000000000N0p:,0*78',
                 '10/07/19 17:36:42:075 \\s:*49\\g:2-2-11262,n:235197*18\\!AIVDM,2,2,9,A,44t0Ht:000000000000000000000,,0*41']

queue = tag_block.TagQueue()

for line_no, line in enumerate(TEST_MESSAGES):
    queue.put(line, line_no)

msgs = []
while not queue.empty():
    msgs.append(queue.get())