addressmapper

package
v0.0.0-...-75bc78b Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressMapper

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

func NewAddressMapper

func NewAddressMapper(nmeaDevice nmea.RawMessageWriter) *AddressMapper

NewAddressMapper creates new instance of AddressMapper with default configuration

func NewAddressMapperWithConfig

func NewAddressMapperWithConfig(nmeaDevice nmea.RawMessageWriter, config Config) *AddressMapper

NewAddressMapperWithConfig creates new instance of AddressMapper with given configuration

func (*AddressMapper) BroadcastIsoAddressClaimRequest

func (m *AddressMapper) BroadcastIsoAddressClaimRequest()

func (*AddressMapper) Nodes

func (m *AddressMapper) Nodes() Nodes

Nodes returns all known (current and previous) nodes from NMEA bus

func (*AddressMapper) NodesInUseBySource

func (m *AddressMapper) NodesInUseBySource() map[uint8]Node

NodesInUseBySource returns list of Nodes that are currently in use (assigned valid source address).

func (*AddressMapper) Process

func (m *AddressMapper) Process(raw nmea.RawMessage) (bool, error)

func (*AddressMapper) Run

func (m *AddressMapper) Run(ctx context.Context) error

Run starts AddressMapper process and block until context is cancelled or error occurs

func (*AddressMapper) ToggleWrite

func (m *AddressMapper) ToggleWrite()

type Config

type Config struct {
	// RequestProductInfo decides if Product Info (126996) is requested after processing AddressClaim (60928)
	RequestProductInfo bool
	// RequestConfigurationInformation decides if Configuration Information (126998) is requested after processing Product Info (126996)
	RequestConfigurationInformation bool
	// RequestPGNList decides if PGN List (126464) is requested after processing Configuration Information (126998)
	RequestPGNList bool
}

Config configures how AddressMapper instance behaves

type ConfigurationInfo

type ConfigurationInfo struct {
	InstallationDesc1 string
	InstallationDesc2 string
	ManufacturerInfo  string
}

func PGN126998ToConfigurationInfo

func PGN126998ToConfigurationInfo(raw nmea.RawMessage) (ConfigurationInfo, error)

type Node

type Node struct {
	Source uint8

	NAME      uint64
	Name      NodeName
	ValidName bool

	ProductInfo      ProductInfo
	ValidProductInfo bool

	ConfigurationInfo      ConfigurationInfo
	ValidConfigurationInfo bool
}

type NodeName

type NodeName struct {
	UniqueNumber        uint32 // ISO Identity Number (21 bits)
	Manufacturer        uint16 // Device Manufacturer (11 bits)
	DeviceInstanceLower uint8  // J1939 ECU Instance (3 bits)
	DeviceInstanceUpper uint8  // J1939 Function Instance (5 bits)
	DeviceFunction      uint8  // (8 bits)
	// reserved (1 bit)
	DeviceClass    uint8 // (7 bits)
	SystemInstance uint8 // ISO Device Class Instance (4 bits)
	IndustryGroup  uint8 // (3 bits)

	// Quote from https://embeddedflakes.com/network-management-in-sae-j1939/:
	// "This 1 bit field indicate whether the CA is arbitrary field capable or not. It is used to resolve address claim
	//  conflict. If this bit is set to 1, this CA will resolve the address conflict with the one whose NAME have higher
	//  priority (lower numeric value) by selecting address from range 128 to 247."
	ArbitraryAddressCapable uint8 // arbitrary address capable (1 bit)
}

NodeName holds information about node/device to identify it in the NMEA bus. Is acquired by requesting PGN 60928 (ISO Address Claim) from device. Related info about SAE1939 Addresses https://embeddedflakes.com/network-management-in-sae-j1939/

func PGN60928ToNodeName

func PGN60928ToNodeName(raw nmea.RawMessage) (NodeName, error)

func (NodeName) Bytes

func (n NodeName) Bytes() []byte

func (NodeName) Uint64

func (n NodeName) Uint64() uint64

type Nodes

type Nodes []Node

type ProductInfo

type ProductInfo struct {
	NMEA2000Version uint16 // (16 bits)
	ProductCode     uint16 // (16 bits)

	ModelID             string // (32 bytes)
	SoftwareVersionCode string // (32 bytes)
	ModelVersion        string // (32 bytes)
	ModelSerialCode     string // (32 bytes)

	CertificationLevel uint8 // (8 bits)
	LoadEquivalency    uint8 // (8 bits)
}

func PGN126996ToProductInfo

func PGN126996ToProductInfo(raw nmea.RawMessage) (ProductInfo, error)

Jump to

Keyboard shortcuts

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