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


Paul wrote:
wrote in message
oups.com...
Actually, I re-read what I posted and it didn't really make sense.

1. Start with the array of ascii characters
2. Convert to the 6 bit binary value.
3. Convert this byte array to a 6 bit bitstream.
4. Then just pull out the bits yuo want using the various bit
operators. I tried to use a bit-field, but it didn't seem to work in
Windows.

As I said, it all works until I get to character arrays (call sign etc)


Here is a portion of the code i wrote to handle message type 5 (I'm only
handling the "Ship Static and Voyage Related Data
" variant for now). My comments follow the code. Pay attention to my
function H6StrToAsc, and how I manipulate the ascii.


I'll assume Paul's code is right He's skipping the intermediate step
which may be where the confusion lies. There are several layers of
things happening here.

0. Bits over the air: 9600bps GMSK data.
1. Demodulated bitstream, eg. 168 bits for a message 1.
2. Actual message content like Message ID, MMSI, Ship Name.
3. Serial output of bitstream using 6-bit encoding.

The data you see in the VDM sentence is a 6-bit encoded representation
of the raw bitstream, first bit on the left, last bit on the right (as
God intended things!).

To get the ship name you need to either skip ahead like Paul did, or
convert the 6-bit back to its bitstream. Then you grab the bits in the
name position and apply the m.1371 ASCII encoding rules to those bits.
BUT! That conversion is DIFFERENT from the 6-bit encode/decode. That is
probably what was tripping you up.

..cp