schwehr / libais

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

Timestamp not decoded ("\\c:1628097600") #235

Open andyvan-trabus opened 2 years ago

andyvan-trabus commented 2 years ago

I'm seeing quite a few lines that have the timestamp ("\c:") present, but with an extra backslash. I'm not familiar enough with the standard to know whether this is valid or not, but I'm seeing thousands of them in a 10-minute capture.

This is the original line: \s:r1ACE0JVF*27\\c:1628097600,s:AS-SAM-BWBANK,n:27493*24\!ANVDM,1,1,,B,15N7R>d000qh6tJC94n=7oJ00D02,0*3F

Here's a test case:

from ais import tag_block

TEST_MESSAGES = ['\\s:r1ACE0JVF*27\\\\c:1628097600,s:AS-SAM-BWBANK,n:27493*24\\!ANVDM,1,1,,B,15N7R>d000qh6tJC94n=7oJ00D02,0*3F']

queue = tag_block.TagQueue()

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

msg = queue.get()
if msg['times'][0] is None:
    print('No timestamp deciphered')
andyvan-trabus commented 2 years ago

Hmm, this is probably NOT an error, the message TAG block looks invalid to me. It looks like "\c:" should be ",\c:". There's no comma at all. The backslash is allowed, but two of them are not.