Originally Posted by prof_mariner
I'm developing a simulator for training purposes. I've already implemented NMEA out so it can talk (via serial
coms) to external instruments and chart plotters (like OpenCPN). In basic terms, what I want to do is convert: vessel name, position, course, speed into an AIS string. Ideally, I'd prefer not to have to encode anything, so if AIS "type 3" allows me to do that, then that would be perfect. Where might I find more info on this?
There are two messages you will be interested in: First is the "Dynamic" report (Type 3), which contains position, course, and speed, but not name, callsign, etc. Then there is the "Static" report (Type 5), which has name, callsign, destination
port, ETA, dimensions, etc, but not position, course, or speed. You will need to encode either of these.
The specs are not generally free, but there are some back-rev versions available on the web. Here's a link to a collection of these: DownloadLibrary
. Document #1 (the ITU spec) is quite useful, but it doesn't reflect the current
"Class-B" messages, and a few others. The Class-A stuff is good. A caveat: I design to the "official" specs, but I am not allowed to distribute these. The "escaped" documents may not be completely accurate.
Download the ITU document and look at Table 13. This lists the AIS message types. You probably want Types 3 and 5.
Table 14 shows the Message 3 format, and table 16 shows Message 5.
Figure 15 shows how the ship's dimensions are measured.
Table 17 shows how the ship type and cargo are encoded. There have been changes since this document was published
Document #3 (IEC Draft) has more info, including the encoding you will need to convert all the AIS message bits into the ascii subset is used in the NMEA sentence. Look at "Annex G", especially Table 7.
You still need to know how to encode text (ship name, etc) to bits. I know this is available in an escaped document somewhere , but here it is in a nutshell:
"Char" (ASCII decimal): 6-bit (decimal)
"@" (64) : 0
"A" (65) : 1
"B" (66) : 2
"Y" (89) : 25
"Z" (90) : 26
"[ "(91) : 27
"_" (95) : 31
--- note the gap here ---
"space" (32) : 32
"!" (33) : 33
"/" (47) 47
"0" (48) : 48
">" (62) : 62
"?" (63) : 63
Note that only upper-case characters are valid.
To practice your coding and decoding, here is a Type-5 message carried in a NMEA !AIVDM sentence (note that for some reason this hasn't been split into two halves):
The AIS message portion is:
This decodes as follows:
Type: Cargo, carrying DG or pollutant cat A
Note that bitfields such as dimensions and ETA need to be broken into sub-fields.
It's all kind of messy, designed to cram the most information into a small space without breaking the legacy definitions.