View Single Post
  #7   Report Post  
posted to rec.boats.electronics
Paul
 
Posts: n/a
Default how to read AIS data from encapsulated NMEA VDO sentence


"tcdang714" wrote in message
...

Wrote:
Terry, you're making this sound alot more complicated than it really
is.

The 6-bit encoded part of a VDM sentence is simply a bitstream, packed
using a special code. Each character represents 6 bits of data from
0x00 ot 0x3F. It starts with the message ID (6 bits), repeat (2 bits),
MMSI (30 bits), etc. This is all defined in m.1371 and 61993-2, even
if
it is a bit confusing at first.

The first 6 bits being a character and the message ID make it easy to
tell that the example string above is a message 1.



Hi guys,

I'm actually working on a similar project right now except I have to do
the ENCODE part of the VDM message. At first I thought every character
represents 6-bit but that is not true. As you can see in the message
there are lowered case alphabet characters (i.e. 'e') and the ascii
value for 'e' is more than 6-bits. I'm a little stuck on my project
right now too, can someone give me more info. Perhaps an example in C
or C++. Thanks.


--
tcdang714


I realize that you've asked about *encoding*, but here's an example of a
decoder written in visual basic, from a program I wrote for my pocket PC.
Perhaps you will be able to reverse-engineer something from this.
------------------
Function AsciiToHex6(AsciiIn)
AsciiToHex6 = A2H6(Asc(AsciiIn))
End Function

Dim A2H6(128)
Sub InitA2H6
Dim i, h
For i = 0 To 127
h = i
If i 48 Then
h = -1
ElseIf i 88 Then
h = h - 48
ElseIf i 119 Then
h = -1
ElseIf i 96 Then
h = -1
Else h = h - 56
End If
A2H6(i) = h
Next
End Sub

InitA2H6
------------------
The array A2H6() contains the hex6 value of the ascii input character, using
the character as an index. I put "-1" in the illegal positions, and ought
to do a little more defensive error-checking (but I probably won't ever get
around to it). The function AsciiToHex6(AsciiIn) just looks up the code and
returns it.

The IEC documents that describe the messages and coding aren't free, but
while I was googling around I did find this one:
http://www.gicoms.go.kr/knowledge/download.asp?filename=IEC%20standard%2061993(class %20A%20AIS).pdf&filepath=D:%5CGICOMS_FILE%5Cupdown %5CIEC%20standard%2061993(class%20A%20AIS).pdf

This contains a decent description of the 6-bit ascii encoding, as well as
the message structure. Note that the AIS data elements are not necessarily
six-bits long, so there will be an arbitrary alignment of the various
parameters across the 6-bit-ascii character stream. Also, some of the AIS
messages are longer than allowed in the NMEA sentence, so the messages have
to be split into multiple NMEA sentence. I can post my code for decoding
the arbitrary data if you think it would be instructive.

Be aware that some of the earlier discussions of 6-bit ascii encoding for
AIS show a different encoding (don't ask me how long I struggled with that
issue!). The one in my code sample, and the document above seem to be the
encoding actually used.

Good Luck,
Paul