analyzer

package
v0.0.0-...-e66aca5 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package analyzer analyzes NMEA 2000 PGN messages

Index

Constants

This section is empty.

Variables

RawFormats is the list of all supported/known raw formats.

Functions

func ParseMessageWithFormat

func ParseMessageWithFormat(msgData []byte, format RawFormat) (*common.Message, error)

ParseMessageWithFormat parses the given data into a message in the provided format.

func ParseRawMessageWithFormat

func ParseRawMessageWithFormat(msgData []byte, format RawFormat) (*common.RawMessage, error)

ParseRawMessageWithFormat parses the given data into a raw message in the provided format.

Types

type Analyzer

type Analyzer struct {
	Config
	// contains filtered or unexported fields
}

An Analyzer analyzes NMEA 2000 PGN messages.

func NewAnalyzer

func NewAnalyzer(conf *Config) (*Analyzer, error)

NewAnalyzer returns a new analyzer using the given config.

func (*Analyzer) ReadMessage

func (ana *Analyzer) ReadMessage() (*common.Message, error)

ReadMessage returns the next message read or io.EOF.

func (*Analyzer) ReadRawMessage

func (ana *Analyzer) ReadRawMessage() (*common.RawMessage, error)

ReadRawMessage returns the next raw message read or io.EOF.

func (*Analyzer) Run

func (ana *Analyzer) Run() error

Run performs analysis.

type Config

type Config struct {
	ShowRaw       bool
	ShowData      bool
	ShowBytes     bool
	ShowJSON      bool
	ShowJSONEmpty bool
	ShowJSONValue bool
	ShowVersion   bool

	ShowGeo        geoFormat
	OnlyPgn        int64
	OnlySrc        int64
	OnlyDst        int64
	ClockSrc       int64
	SelectedFormat RawFormat

	CamelCase  *bool
	InFile     io.Reader
	OutFile    io.Writer
	OutErrFile io.Writer
	Logger     *common.Logger
	// contains filtered or unexported fields
}

Config is used to configure an Analyzer.

func NewConfigForCLI

func NewConfigForCLI() *Config

NewConfigForCLI returns a config for use with a CLI.

func NewConfigForLibrary

func NewConfigForLibrary(
	logger *common.Logger,
) *Config

NewConfigForLibrary returns a config for use with a library.

func ParseArgs

func ParseArgs(args []string) (*Config, bool, error)

ParseArgs parses the args of a CLI program into a Config.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

A Parser is used to parse NMEA messages one by one.

func NewParser

func NewParser() (*Parser, error)

NewParser returns a new parser ready for use.

func NewParserWithFormat

func NewParserWithFormat(format RawFormat) (*Parser, error)

NewParserWithFormat returns a new parser that is expecting to read messages of the given format.

func (*Parser) ParseMessage

func (p *Parser) ParseMessage(msgData []byte) (*common.Message, error)

ParseMessage parses the given data into a message.

func (*Parser) ParseRawMessage

func (p *Parser) ParseRawMessage(msgData []byte) (*common.RawMessage, error)

ParseRawMessage parses the given data into a raw message.

type RawFormat

type RawFormat string

RawFormat is the format that raw data is serialized into.

const (
	RawFormatUnknown           RawFormat = "UNKNOWN"
	RawFormatPlain             RawFormat = "PLAIN"
	RawFormatFast              RawFormat = "FAST"
	RawFormatPlainOrFast       RawFormat = "PLAIN_OR_FAST"
	RawFormatAirmar            RawFormat = "AIRMAR"
	RawFormatChetco            RawFormat = "CHETCO"
	RawFormatGarminCSV1        RawFormat = "GARMIN_CSV1"
	RawFormatGarminCSV2        RawFormat = "GARMIN_CSV2"
	RawFormatYDWG02            RawFormat = "YDWG02"
	RawFormatNavLink2          RawFormat = "NAVLINK2"
	RawFormatActisenseN2KASCII RawFormat = "ACTISENSE_N2K_ASCII"
)

All supported/known raw formats.

func ParseMessage

func ParseMessage(msgData []byte) (*common.Message, RawFormat, error)

ParseMessage parses the given data into a message. It will attempt to detect the format of the message.

func ParseRawMessage

func ParseRawMessage(msgData []byte) (*common.RawMessage, RawFormat, error)

ParseRawMessage parses the given data into a raw message. It will attempt to detect the format of the message.

Jump to

Keyboard shortcuts

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