ais

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 3 Imported by: 1

README

go-ais

Build Status Coverage Status Go Report Card

Summary

This is a library written in Go to encode and decode Automatic Identification System packets. This is a VHF data system that is used for dependent tracking and identification of marine vessels. It is specified by the ITU-R M.1371-5 standard.

Rationale

There are a few other libraries offered on the internet, but all of them implement only a few messages (usually the position and static reports). In addition, very few libraries support encoding.

Many other libraries tightly integrate a NMEA (VDM/VDO) decoder with the AIS decoder. This is handy if you use a complete receiver that delivers NMEA sentences, but can be limiting. For example, you may have a low level RF receiver connected directly to an embedded system. I feel it is best to split NMEA and AIS coding as they are really two different functions. However, a convenience library is provided in this repository that combines this library with a golang NMEA decoder and a self-developed NMEA encoder.

How to use it

Start by getting an AIS packet from somewhere. It could for example come from AISHub or a local receiver. Extract the payload and convert it to a byte slice containing one bit per byte. Then call the DecodePacket function on it. It will return an object containing the decoded message. For example:

package main

import (
    "fmt"
    "encoding/json"

    ais "github.com/hootrhino/go-ais"
)

func main() {
    msg := []byte{0, 0, ... 1, 0, 0, 0, 0, 0, 0, 0}

    c := ais.CodecNew(false, false, false)
    c.DropSpace = true

    result := c.DecodePacket(msg)
    out, _ := json.MarshalIndent(result, "", "  ")
    fmt.Printf("%T: %s\n", result, out)
}

The output of this program could be as follows:

ais.ShipStaticData: { "MessageID": 5, "RepeatIndicator": 0, "UserID": 203999421, "Valid": true, "AisVersion": 0, "ImoNumber": 0, "CallSign": "OED3018", "Name": "PRIMADONNA", "Type": 69, "Dimension": { "A": 20, "B": 93, "C": 7, "D": 10 }, "FixType": 1, "Eta": { "Month": 1, "Day": 4, "Hour": 18, "Minute": 30 }, "MaximumStaticDraught": 1.7, "Destination": "LINZ", "Dte": false, "Spare": false }

To encode a packet, call the EncodePacket function. It works exactly in the opposite way of DecodePacket.

If you want to work with NMEA sentences you can use the following example to decode a packet:

package main

import (
    "fmt"
    "github.com/hootrhino/go-ais"
    "github.com/hootrhino/go-ais/aisnmea"
)

func main() {
    nm := aisnmea.NMEACodecNew(ais.CodecNew(false, false, false))

    decoded, _ := nm.ParseSentence("!AIVDM,1,1,,B,33aEP2hP00PBLRFMfCp;OOw<R>`<,0*49")
    if decoded != nil {
        fmt.Printf("%+v\n", decoded.Packet)
    }
}

Documentation

Overview

Package ais is an Automatic Identification System (ITU-R M.1371-5) packet decoder and encoder

Package ais WARNING: This file is generated by parser_generator/main.go do not edit directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddessedSafetyMessage

type AddessedSafetyMessage struct {
	Header         `aisWidth:"38"`
	Valid          bool   `aisEncodeMaxLen:"1008"`
	SequenceNumber uint8  `aisWidth:"2"`
	DestinationID  uint32 `aisWidth:"30"`
	Retransmission bool   `aisWidth:"1"`
	Spare          bool   `aisWidth:"1" aisEncodeAs:"0"`
	Text           string `aisWidth:"-1"`
}

AddessedSafetyMessage could be variable in length, based on the amount of safety related text. The length should vary between 1 and 5 slots.

type AddressedBinaryMessage

type AddressedBinaryMessage struct {
	Header         `aisWidth:"38"`
	Valid          bool                       `aisEncodeMaxLen:"1008"`
	SequenceNumber uint8                      `aisWidth:"2"`
	DestinationID  uint32                     `aisWidth:"30"`
	Retransmission bool                       `aisWidth:"1"`
	Spare          bool                       `aisWidth:"1" aisEncodeAs:"0"`
	ApplicationID  FieldApplicationIdentifier `aisWidth:"16"`
	BinaryData     []byte                     `aisWidth:"-1"`
}

AddressedBinaryMessage should be variable in length, based on the amount of binary data. The length should vary between 1 and 5 slots. See application identifiers in § 2.1, Annex 5.

type AidsToNavigationReport

type AidsToNavigationReport struct {
	Header           `aisWidth:"38"`
	Valid            bool            `aisEncodeMaxLen:"356"`
	Type             uint8           `aisWidth:"5"`
	Name             string          `aisWidth:"120"`
	PositionAccuracy bool            `aisWidth:"1"`
	Longitude        FieldLatLonFine `aisWidth:"28"`
	Latitude         FieldLatLonFine `aisWidth:"27"`
	Dimension        FieldDimension  `aisWidth:"30"`
	Fixtype          uint8           `aisWidth:"4"`
	Timestamp        uint8           `aisWidth:"6"`
	OffPosition      bool            `aisWidth:"1"`
	AtoN             uint8           `aisWidth:"8"`
	Raim             bool            `aisWidth:"1"`
	VirtualAtoN      bool            `aisWidth:"1"`
	AssignedMode     bool            `aisWidth:"1"`
	Spare            bool            `aisWidth:"1" aisEncodeAs:"0"`
	NameExtension    string          `aisWidth:"-1"`
}

AidsToNavigationReport should be used by an Aids to navigation (AtoN) AIS station. This station may be mounted on an aid-to-navigation or this message may be transmitted by a fixed station when the functionality of an AtoN station is integrated into the fixed station. This message should be transmitted autonomously at a Rr of once every three (3) min or it may be assigned by an assigned mode command (Message 16) via the VHF data link, or by an external command. This message should not occupy more than two slots.

type AssignedModeCommand

type AssignedModeCommand struct {
	Header   `aisWidth:"38"`
	Valid    bool                       `aisEncodeMaxLen:"144"`
	Spare    uint8                      `aisWidth:"2" aisEncodeAs:"0"`
	Commands [2]AssignedModeCommandData `aisWidth:"0"`
}

AssignedModeCommand be transmitted by a base station when operating as a controlling entity. Other stations can be assigned a transmission schedule, other than the currently used one. If a station is assigned a schedule, it will also enter assigned mode.

type AssignedModeCommandData

type AssignedModeCommandData struct {
	Valid         bool
	DestinationID uint32 `aisWidth:"30"`
	Offset        uint16 `aisWidth:"12"`
	Increment     uint16 `aisWidth:"10"`
}

AssignedModeCommandData is the data part of AssignedModeCommand

type BaseStationReport

type BaseStationReport struct {
	Header                    `aisWidth:"38"`
	Valid                     bool            `aisEncodeMaxLen:"168"`
	UtcYear                   uint16          `aisWidth:"14"`
	UtcMonth                  uint8           `aisWidth:"4"`
	UtcDay                    uint8           `aisWidth:"5"`
	UtcHour                   uint8           `aisWidth:"5"`
	UtcMinute                 uint8           `aisWidth:"6"`
	UtcSecond                 uint8           `aisWidth:"6"`
	PositionAccuracy          bool            `aisWidth:"1"`
	Longitude                 FieldLatLonFine `aisWidth:"28"`
	Latitude                  FieldLatLonFine `aisWidth:"27"`
	FixType                   uint8           `aisWidth:"4"`
	LongRangeEnable           bool            `aisWidth:"1"`
	Spare                     uint16          `aisWidth:"9" aisEncodeAs:"0"`
	Raim                      bool            `aisWidth:"1"`
	CommunicationStateNoItdma `aisWidth:"19"`
}

BaseStationReport should be used for reporting UTC time and date and, at the same time, position. A base station should use Message 4 in its periodical transmissions. Message 4 is used by AIS stations for determining if it is within 120 NM for response to Messages 20 and 23. A mobile station should output Message 11 only in response to interrogation by Message 10. Message 11 is only transmitted as a result of a UTC request message (Message 10). The UTC and date response should be transmitted on the channel, where the UTC request message was received. */

type BinaryAcknowledge

type BinaryAcknowledge struct {
	Header       `aisWidth:"38"`
	Valid        bool                     `aisEncodeMaxLen:"168"`
	Spare        uint8                    `aisWidth:"2" aisEncodeAs:"0"`
	Destinations [4]BinaryAcknowledgeData `aisWidth:"0"`
}

BinaryAcknowledge should be used as an acknowledgement of up to four Message 6 messages received (see § 5.3.1, Annex 2) and should be transmitted on the channel, where the addressed message to be acknowledged was received.

type BinaryAcknowledgeData

type BinaryAcknowledgeData struct {
	Valid          bool
	DestinationID  uint32 `aisWidth:"30"`
	SequenceNumber uint8  `aisWidth:"2"`
}

BinaryAcknowledgeData is the data part of BinaryAcknowledge

type BinaryBroadcastMessage

type BinaryBroadcastMessage struct {
	Header        `aisWidth:"38"`
	Valid         bool                       `aisEncodeMaxLen:"1008"`
	Spare         uint8                      `aisWidth:"2" aisEncodeAs:"0"`
	ApplicationID FieldApplicationIdentifier `aisWidth:"16"`
	BinaryData    []byte                     `aisWidth:"-1"`
}

BinaryBroadcastMessage will be variable in length, based on the amount of binary data. The length should vary between 1 and 5 slots.

type ChannelManagement

type ChannelManagement struct {
	Header               `aisWidth:"38"`
	Valid                bool                           `aisEncodeMaxLen:"168"`
	Spare1               uint8                          `aisWidth:"2" aisEncodeAs:"0"`
	ChannelA             uint16                         `aisWidth:"12"`
	ChannelB             uint16                         `aisWidth:"12"`
	TxRxMode             uint8                          `aisWidth:"4"`
	LowPower             bool                           `aisWidth:"1"`
	Area                 ChannelManagementBroadcastData `aisWidth:"70" aisDependsBit:"~139" aisDependsField:"~IsAddressed"`
	Unicast              ChannelManagementUnicastData   `aisWidth:"70" aisDependsBit:"139" aisDependsField:"IsAddressed"`
	IsAddressed          bool                           `aisWidth:"1"`
	BwA                  bool                           `aisWidth:"1"`
	BwB                  bool                           `aisWidth:"1"`
	TransitionalZoneSize uint8                          `aisWidth:"3"`
	Spare4               uint32                         `aisWidth:"23" aisEncodeAs:"0"`
}

ChannelManagement should be transmitted by a base station (as a broadcast message) to command the VHF data link parameters for the geographical area designated in this message and should be accompanied by a Message 4 transmission for evaluation of the message within 120 NM. The geographical area designated by this message should be as defined in § 4.1, Annex 2. Alternatively, this message may be used by a base station (as an addressed message) to command individual AIS mobile stations to adopt the specified VHF data link parameters. When interrogated and no channel management performed by the interrogated base station, the not available and/or international default settings should be transmitted (see § 4.1, Annex 2).

type ChannelManagementBroadcastData

type ChannelManagementBroadcastData struct {
	Longitude1 FieldLatLonCoarse `aisWidth:"18"`
	Latitude1  FieldLatLonCoarse `aisWidth:"17"`
	Longitude2 FieldLatLonCoarse `aisWidth:"18"`
	Latitude2  FieldLatLonCoarse `aisWidth:"17"`
}

ChannelManagementBroadcastData contains the boundrary for a broadcasted channel mangement packet.

type ChannelManagementUnicastData

type ChannelManagementUnicastData struct {
	AddressStation1 uint32 `aisWidth:"30"`
	Spare2          uint8  `aisWidth:"5" aisEncodeAs:"0"`
	AddressStation2 uint32 `aisWidth:"30"`
	Spare3          uint8  `aisWidth:"5" aisEncodeAs:"0"`
}

ChannelManagementUnicastData contains the destination addresses for a unicast channel mangement packet.

type Codec

type Codec struct {
	StrictByteAlignment bool

	// DecoderCheckFixedValues will validate that spare values are zero. This is only for debugging
	// and should not be used as newer protocl versions may use the spares for something.
	DecoderCheckFixedValues bool

	// FloatWithoutConversion will disable float conversion, making re-encoding the decoded output yield
	// an identical bitstream.
	FloatWithoutConversion bool

	// DropSpace will drop spaces at the end of strings. Many encoders pad strings
	// with spaces instead of @.
	DropSpace bool

	// FastParse is a non-reflection based parsing method
	FastParse bool
	// contains filtered or unexported fields
}

Codec encodes and decodes AIS messages (ITU-R M.1371-5)

func CodecNew

func CodecNew(acceptShortAck bool, acceptShortShipStaticData bool, parseFast bool) *Codec

CodecNew creates and initializes the AIS parser. The two parameters allow accepting messages that a few types of existing encoders seem to transmit with invalid length. This is very rare, passing false to both should be fine.

func (*Codec) ChannelToFrequency

func (t *Codec) ChannelToFrequency(channel uint16) uint

ChannelToFrequency converts an AIS channel number into its frequency in Hz

func (*Codec) DecodePacket

func (t *Codec) DecodePacket(payload []byte) Packet

DecodePacket will convert a []byte containing 0 and 1 to an object containing the decoded packet. It will return nil if decoding failed.

func (*Codec) EncodePacket

func (t *Codec) EncodePacket(message Packet) []byte

EncodePacket encodes a valid AIS object to a binary []byte. nil is returned if encoding failed.

type CommunicationStateItdma

type CommunicationStateItdma struct {
	CommunicationStateIsItdma bool   `aisWidth:"1"`
	CommunicationState        uint32 `aisWidth:"19"`
}

CommunicationStateItdma represents the encoding of the communication state if the ITDMA type is included in the message

func (CommunicationStateItdma) GetState

func (c CommunicationStateItdma) GetState() uint32

GetState will return the communication state

func (CommunicationStateItdma) IsItdma

func (c CommunicationStateItdma) IsItdma() int

IsItdma indicates if Itdma is used.

type CommunicationStateNoItdma

type CommunicationStateNoItdma struct {
	CommunicationState uint32 `aisWidth:"19"`
}

CommunicationStateNoItdma represents the encoding of the communication state if the type is fixed

func (CommunicationStateNoItdma) GetState

func (c CommunicationStateNoItdma) GetState() uint32

GetState will return the communication state

func (CommunicationStateNoItdma) IsItdma

func (c CommunicationStateNoItdma) IsItdma() int

IsItdma indicates if Itdma is used. Return -1 for unknown as it depends on the message

type CoordinatedUTCInquiry

type CoordinatedUTCInquiry struct {
	Header        `aisWidth:"38"`
	Valid         bool   `aisEncodeMaxLen:"72"`
	Spare1        uint8  `aisWidth:"2" aisEncodeAs:"0"`
	DestinationID uint32 `aisWidth:"30"`
	Spare2        uint8  `aisWidth:"2" aisEncodeAs:"0"`
}

CoordinatedUTCInquiry should be used when a station is requesting UTC and date from another station.

type DataLinkManagementMessage

type DataLinkManagementMessage struct {
	Header `aisWidth:"38"`
	Valid  bool                             `aisEncodeMaxLen:"160"`
	Spare  uint8                            `aisWidth:"2" aisEncodeAs:"0"`
	Data   [4]DataLinkManagementMessageData `aisWidth:"0"`
}

DataLinkManagementMessage should be used by base station(s) to pre-announce the fixed allocation schedule (FATDMA) for one or more base station(s) and it should be repeated as often as required. This way the system can provide a high level of integrity for base station(s). This is especially important in regions where several base stations are located adjacent to each other and mobile station(s) move between these different regions. These reserved slots cannot be autonomously allocated by mobile stations.

type DataLinkManagementMessageData

type DataLinkManagementMessageData struct {
	Valid         bool
	Offset        uint16 `aisWidth:"12"`
	NumberOfSlots uint8  `aisWidth:"4"`
	TimeOut       uint8  `aisWidth:"3"`
	Increment     uint16 `aisWidth:"11"`
}

DataLinkManagementMessageData is the data part of DataLinkManagementMessage

type ExtendedClassBPositionReport

type ExtendedClassBPositionReport struct {
	Header           `aisWidth:"38"`
	Valid            bool            `aisEncodeMaxLen:"312"`
	Spare1           uint8           `aisWidth:"8" aisEncodeAs:"0"`
	Sog              Field10         `aisWidth:"10"`
	PositionAccuracy bool            `aisWidth:"1"`
	Longitude        FieldLatLonFine `aisWidth:"28"`
	Latitude         FieldLatLonFine `aisWidth:"27"`
	Cog              Field10         `aisWidth:"12"`
	TrueHeading      uint16          `aisWidth:"9"`
	Timestamp        uint8           `aisWidth:"6"`
	Spare2           uint8           `aisWidth:"4" aisEncodeAs:"0"`
	Name             string          `aisWidth:"120"`
	Type             uint8           `aisWidth:"8"`
	Dimension        FieldDimension  `aisWidth:"30"`
	FixType          uint8           `aisWidth:"4"`
	Raim             bool            `aisWidth:"1"`
	Dte              bool            `aisWidth:"1"`
	AssignedMode     bool            `aisWidth:"1"`
	Spare3           uint8           `aisWidth:"4" aisEncodeAs:"0"`
}

ExtendedClassBPositionReport should be transmitted once every 6 min in two slots allocated by the use of Message 18 in the ITDMA communication state. This message should be transmitted immediately after the following parameter values change: dimension of ship/reference for position or type of electronic position fixing device.

For future equipment: this message is not needed and should not be used. All content is covered by
Message 18, Message 24A and 24B.
For legacy equipment: this message should be used by Class B shipborne mobile equipment.

type Field10

type Field10 float64

Field10 represents an unsigned value multiplied by 10

type FieldApplicationIdentifier

type FieldApplicationIdentifier struct {
	Valid              bool
	DesignatedAreaCode uint16 `aisWidth:"10"`
	FunctionIdentifier uint8  `aisWidth:"6"`
}

FieldApplicationIdentifier represents the encoding of the application identifier

type FieldDimension

type FieldDimension struct {
	A uint16 `aisWidth:"9"`
	B uint16 `aisWidth:"9"`
	C uint8  `aisWidth:"6"`
	D uint8  `aisWidth:"6"`
}

FieldDimension represents the encoding of the dimension

type FieldETA

type FieldETA struct {
	Month  uint8 `aisWidth:"4"`
	Day    uint8 `aisWidth:"5"`
	Hour   uint8 `aisWidth:"5"`
	Minute uint8 `aisWidth:"6"`
}

FieldETA represents the encoding of the estimated time of arrival

type FieldLatLonCoarse

type FieldLatLonCoarse float64

FieldLatLonCoarse represents a 1/10' position

type FieldLatLonFine

type FieldLatLonFine float64

FieldLatLonFine represents a 1/10000' position

type GnssBroadcastBinaryMessage

type GnssBroadcastBinaryMessage struct {
	Header    `aisWidth:"38"`
	Valid     bool              `aisEncodeMaxLen:"816"`
	Spare1    uint8             `aisWidth:"2" aisEncodeAs:"0"`
	Longitude FieldLatLonCoarse `aisWidth:"18"`
	Latitude  FieldLatLonCoarse `aisWidth:"17"`
	Spare2    uint8             `aisWidth:"5" aisEncodeAs:"0"`
	Data      []byte            `aisWidth:"-1"`
}

GnssBroadcastBinaryMessage should be transmitted by a base station, which is connected to a DGNSS reference source, and configured to provide DGNSS data to receiving stations. The contents of the data should be in accordance with Recommendation ITU-R M.823, excluding preamble and parity formatting.

type GroupAssignmentCommand

type GroupAssignmentCommand struct {
	Header            `aisWidth:"38"`
	Valid             bool              `aisEncodeMaxLen:"160"`
	Spare1            uint8             `aisWidth:"2" aisEncodeAs:"0"`
	Longitude1        FieldLatLonCoarse `aisWidth:"18"`
	Latitude1         FieldLatLonCoarse `aisWidth:"17"`
	Longitude2        FieldLatLonCoarse `aisWidth:"18"`
	Latitude2         FieldLatLonCoarse `aisWidth:"17"`
	StationType       uint8             `aisWidth:"4"`
	ShipType          uint8             `aisWidth:"8"`
	Spare2            uint32            `aisWidth:"22" aisEncodeAs:"0"`
	TxRxMode          uint8             `aisWidth:"2"`
	ReportingInterval uint8             `aisWidth:"4"`
	QuietTime         uint8             `aisWidth:"4"`
	Spare3            uint8             `aisWidth:"6" aisEncodeAs:"0"`
}

GroupAssignmentCommand is transmitted by a base station when operating as a controlling entity(see § 4.3.3.3.2 Annex 7 and § 3.20). This message should be applied to a mobile station within the defined region and as selected by “Ship and Cargo Type” or “Station type”. The receiving station should consider all selector fields concurrently. It controls the following operating parameters of a mobile station: * transmit/receive mode; * reporting interval; * the duration of a quiet time. Station type 10 should be used to define the base station coverage area for control of Message 27 transmissions by Class A and Class B “SO” mobile stations. When station type is 10 only the fields latitude, longitude are used, all other fields should be ignored. This information will be relevant until three minutes after the last reception of controlling Message 4 from the same base station (same MMSI).

type HasCommunicationState

type HasCommunicationState interface {
	IsItdma() int
	GetState() uint32
}

HasCommunicationState indicates that a message contains commuication state

type Header struct {
	MessageID       uint8  `aisWidth:"6"`
	RepeatIndicator uint8  `aisWidth:"2"`
	UserID          uint32 `aisWidth:"30"`
}

Header contains the header prepended to each packet

func (Header) GetHeader

func (h Header) GetHeader() *Header

GetHeader returns the header of the packet

type Interrogation

type Interrogation struct {
	Header       `aisWidth:"38"`
	Valid        bool                          `aisEncodeMaxLen:"160"`
	Spare        uint8                         `aisWidth:"2" aisEncodeAs:"0"`
	Station1Msg1 InterrogationStation1Message1 `aisWidth:"48"`
	Station1Msg2 InterrogationStation1Message2 `aisWidth:"0"`
	Station2     InterrogationStation2         `aisWidth:"0"`
}

Interrogation should be used for interrogations via the TDMA (not DSC) VHF data link except for requests for UTC and date. The response should be transmitted on the channel where the interrogation was received.

type InterrogationStation1Message1

type InterrogationStation1Message1 struct {
	Valid      bool
	StationID  uint32 `aisWidth:"30"`
	MessageID  uint8  `aisWidth:"6"`
	SlotOffset uint16 `aisWidth:"12"`
}

InterrogationStation1Message1 is the station 1 part of Interrogation

type InterrogationStation1Message2

type InterrogationStation1Message2 struct {
	Valid      bool   `aisOptional:"1"`
	Spare      uint8  `aisWidth:"2" aisEncodeAs:"0"`
	MessageID  uint8  `aisWidth:"6"`
	SlotOffset uint16 `aisWidth:"12"`
}

InterrogationStation1Message2 is the second station 1 part of interrogation

type InterrogationStation2

type InterrogationStation2 struct {
	Valid      bool   `aisOptional:"1"`
	Spare1     uint8  `aisWidth:"2" aisEncodeAs:"0"`
	StationID  uint32 `aisWidth:"30"`
	MessageID  uint8  `aisWidth:"6"`
	SlotOffset uint16 `aisWidth:"12"`
	Spare2     uint8  `aisWidth:"2" aisEncodeAs:"0"`
}

InterrogationStation2 is the station 2 part of Interrogation

type LongRangeAisBroadcastMessage

type LongRangeAisBroadcastMessage struct {
	Header             `aisWidth:"38"`
	Valid              bool              `aisEncodeMaxLen:"96"`
	PositionAccuracy   bool              `aisWidth:"1"`
	Raim               bool              `aisWidth:"1"`
	NavigationalStatus uint8             `aisWidth:"4"`
	Longitude          FieldLatLonCoarse `aisWidth:"18"`
	Latitude           FieldLatLonCoarse `aisWidth:"17"`
	Sog                uint8             `aisWidth:"6"`
	Cog                uint16            `aisWidth:"9"`
	PositionLatency    bool              `aisWidth:"1"`
	Spare              bool              `aisWidth:"1" aisEncodeAs:"0"`
}

LongRangeAisBroadcastMessage is primarily intended for long-range detection of AIS Class A and Class B “SO” equipped vessels (typically by satellite). This message has a similar content to Messages 1, 2 and 3, but the total number of bits has been compressed to allow for increased propagation delays associated with long-range detection. Refer to Annex 4 for details on Long-Range applications.

type MultiSlotBinaryMessage

type MultiSlotBinaryMessage struct {
	Header                  `aisWidth:"38"`
	Valid                   bool                       `aisEncodeMaxLen:"1064"`
	DestinationIDValid      bool                       `aisWidth:"1"`
	ApplicationIDValid      bool                       `aisWidth:"1"`
	DestinationID           uint32                     `aisWidth:"30" aisDependsBit:"38" aisDependsField:"DestinationIDValid"`
	Spare1                  uint8                      `aisWidth:"2" aisDependsBit:"38" aisDependsField:"DestinationIDValid" aisEncodeAs:"0"`
	ApplicationID           FieldApplicationIdentifier `aisWidth:"16" aisDependsBit:"39" aisDependsField:"ApplicationIDValid"`
	Payload                 []byte                     `aisWidth:"-1"`
	Spare2                  uint8                      `aisWidth:"4" aisEncodeAs:"0"`
	CommunicationStateItdma `aisWidth:"20"`
}

MultiSlotBinaryMessage is primarily intended for scheduled binary data transmissions by applying either the SOTDMA or ITDMA access scheme. This multiple slot binary message can contain up to 1 004 data- bits (using 5 slots) depending on the coding method used for the contents, and the destination indication of broadcast or addressed. See application identifiers in § 2.1, Annex 5.

type Packet

type Packet interface {
	GetHeader() *Header
}

Packet is an interface describing coded and decoded ais packets

type PositionReport

type PositionReport struct {
	Header                    `aisWidth:"38"`
	Valid                     bool            `aisEncodeMaxLen:"168"`
	NavigationalStatus        uint8           `aisWidth:"4"`
	RateOfTurn                int16           `aisWidth:"8"`
	Sog                       Field10         `aisWidth:"10"`
	PositionAccuracy          bool            `aisWidth:"1"`
	Longitude                 FieldLatLonFine `aisWidth:"28"`
	Latitude                  FieldLatLonFine `aisWidth:"27"`
	Cog                       Field10         `aisWidth:"12"`
	TrueHeading               uint16          `aisWidth:"9"`
	Timestamp                 uint8           `aisWidth:"6"`
	SpecialManoeuvreIndicator uint8           `aisWidth:"2"`
	Spare                     uint8           `aisWidth:"3" aisEncodeAs:"0"`
	Raim                      bool            `aisWidth:"1"`
	CommunicationStateNoItdma `aisWidth:"19"`
}

PositionReport should be output periodically by mobile stations. The message ID is 1, 2 or 3 depending on the system mode.

type SafetyBroadcastMessage

type SafetyBroadcastMessage struct {
	Header `aisWidth:"38"`
	Valid  bool   `aisEncodeMaxLen:"1008"`
	Spare  uint8  `aisWidth:"2" aisEncodeAs:"0"`
	Text   string `aisWidth:"-1"`
}

SafetyBroadcastMessage could be variable in length, based on the amount of safety related text. The length should vary between 1 and 5 slots.

type ShipStaticData

type ShipStaticData struct {
	Header               `aisWidth:"38"`
	Valid                bool           `aisEncodeMaxLen:"424"`
	AisVersion           uint8          `aisWidth:"2"`
	ImoNumber            uint32         `aisWidth:"30"`
	CallSign             string         `aisWidth:"42"`
	Name                 string         `aisWidth:"120"`
	Type                 uint8          `aisWidth:"8"`
	Dimension            FieldDimension `aisWidth:"30"`
	FixType              uint8          `aisWidth:"4"`
	Eta                  FieldETA       `aisWidth:"20"`
	MaximumStaticDraught Field10        `aisWidth:"8"`
	Destination          string         `aisWidth:"120"`
	Dte                  bool           `aisWidth:"1"`
	Spare                bool           `aisWidth:"1" aisEncodeAs:"0"`
}

ShipStaticData should only be used by Class A shipborne and SAR aircraft AIS stations when reporting static or voyage related data.

type SingleSlotBinaryMessage

type SingleSlotBinaryMessage struct {
	Header             `aisWidth:"38"`
	Valid              bool                       `aisEncodeMaxLen:"168"`
	DestinationIDValid bool                       `aisWidth:"1"`
	ApplicationIDValid bool                       `aisWidth:"1"`
	DestinationID      uint32                     `aisWidth:"30" aisDependsBit:"38" aisDependsField:"DestinationIDValid"`
	Spare              uint8                      `aisWidth:"2" aisDependsBit:"38" aisDependsField:"DestinationIDValid" aisEncodeAs:"0"`
	ApplicationID      FieldApplicationIdentifier `aisWidth:"16" aisDependsBit:"39" aisDependsField:"ApplicationIDValid"`
	Payload            []byte                     `aisWidth:"-1"`
}

SingleSlotBinaryMessage is primarily intended short infrequent data transmissions. The single slot binary message can contain up to 128 data-bits depending on the coding method used for the contents, and the destination indication of broadcast or addressed. The length should not exceed one slot. See application identifiers in § 2.1, Annex 5.

type StandardClassBPositionReport

type StandardClassBPositionReport struct {
	Header                  `aisWidth:"38"`
	Valid                   bool            `aisEncodeMaxLen:"168"`
	Spare1                  uint8           `aisWidth:"8" aisEncodeAs:"0"`
	Sog                     Field10         `aisWidth:"10"`
	PositionAccuracy        bool            `aisWidth:"1"`
	Longitude               FieldLatLonFine `aisWidth:"28"`
	Latitude                FieldLatLonFine `aisWidth:"27"`
	Cog                     Field10         `aisWidth:"12"`
	TrueHeading             uint16          `aisWidth:"9"`
	Timestamp               uint8           `aisWidth:"6"`
	Spare2                  uint8           `aisWidth:"2" aisEncodeAs:"0"`
	ClassBUnit              bool            `aisWidth:"1"`
	ClassBDisplay           bool            `aisWidth:"1"`
	ClassBDsc               bool            `aisWidth:"1"`
	ClassBBand              bool            `aisWidth:"1"`
	ClassBMsg22             bool            `aisWidth:"1"`
	AssignedMode            bool            `aisWidth:"1"`
	Raim                    bool            `aisWidth:"1"`
	CommunicationStateItdma `aisWidth:"20"`
}

StandardClassBPositionReport should be output periodically and autonomously instead of Messages 1, 2, or 3 by Class B shipborne mobile equipment, only. The reporting interval should default to the values given in Table 2, Annex 1, unless otherwise specified by reception of a Message 16 or 23; and depending on the current SOG and navigational status flag setting.

type StandardSearchAndRescueAircraftReport

type StandardSearchAndRescueAircraftReport struct {
	Header                  `aisWidth:"38"`
	Valid                   bool            `aisEncodeMaxLen:"168"`
	Altitude                uint16          `aisWidth:"12"`
	Sog                     uint16          `aisWidth:"10"`
	PositionAccuracy        bool            `aisWidth:"1"`
	Longitude               FieldLatLonFine `aisWidth:"28"`
	Latitude                FieldLatLonFine `aisWidth:"27"`
	Cog                     Field10         `aisWidth:"12"`
	Timestamp               uint8           `aisWidth:"6"`
	AltFromBaro             bool            `aisWidth:"1"`
	Spare1                  uint8           `aisWidth:"7" aisEncodeAs:"0"`
	Dte                     bool            `aisWidth:"1"`
	Spare2                  uint8           `aisWidth:"3" aisEncodeAs:"0"`
	AssignedMode            bool            `aisWidth:"1"`
	Raim                    bool            `aisWidth:"1"`
	CommunicationStateItdma `aisWidth:"20"`
}

StandardSearchAndRescueAircraftReport should be used as a standard position report for aircraft involved in SAR operations. Stations other than aircraft involved in SAR operations should not transmit this message. The default reporting interval for this message should be 10 s.

type StaticDataReport

type StaticDataReport struct {
	Header     `aisWidth:"38"`
	Valid      bool              `aisEncodeMaxLen:"168"`
	Reserved   uint8             `aisWidth:"1" aisEncodeAs:"0" aisCheckValue:"0"`
	PartNumber bool              `aisWidth:"1"`
	ReportA    StaticDataReportA `aisWidth:"120" aisDependsBit:"~39" aisDependsField:"~PartNumber"`
	ReportB    StaticDataReportB `aisWidth:"120" aisDependsBit:"39" aisDependsField:"PartNumber"`
}

StaticDataReport part A shall transmit once every 6 min alternating between channels. Message 24 Part A may be used by any AIS station to associate a MMSI with a name. Message 24 Part A and Part B should be transmitted once every 6 min by Class B “CS” and Class B “SO” shipborne mobile equipment. The message consists of two parts. Message 24B should be transmitted within 1 min following Message 24A.

type StaticDataReportA

type StaticDataReportA struct {
	Valid bool
	Name  string `aisWidth:"120"`
}

StaticDataReportA is the A part of message 24

type StaticDataReportB

type StaticDataReportB struct {
	Valid          bool
	ShipType       uint8          `aisWidth:"8"`
	VendorIDName   string         `aisWidth:"18"`
	VenderIDModel  uint8          `aisWidth:"4"`
	VenderIDSerial uint32         `aisWidth:"20"`
	CallSign       string         `aisWidth:"42"`
	Dimension      FieldDimension `aisWidth:"30"`
	FixType        uint8          `aisWidth:"4"`
	Spare          uint8          `aisWidth:"2" aisEncodeAs:"0"`
}

StaticDataReportB is the B part of message 24

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL