aplicom

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MIT

README

Aplicom Go

PkgGoDev GoReportCard Codecov

Go SDK for Aplicom telematics devices.

Installing

$ go get go.einride.tech/aplicom

Documentation

See the Aplicom Extranet for device-specific and protocol-specific documentation.

Examples

Listening for D protocol packets
package main

import (
	"fmt"
	"net"
	"time"

	"go.einride.tech/aplicom/dprotocol"
)

func main() {
	// Bind a TCP listener.
	lis, err := net.Listen("tcp", "localhost:8080")
	if err != nil {
		panic(err) // TODO: Handle error.
	}
	// Accept D protocol connections.
	for {
		conn, err := lis.Accept()
		if err != nil {
			panic(err) // TODO: Handle error.
		}
		// Scan D protocol packets.
		go func() {
			sc := dprotocol.NewScanner(conn)
			for sc.ScanPacket() {
				fmt.Printf(
					"Unit ID: %d Event ID: %d GPS Time: %s\n",
					sc.Packet().Header.UnitID,
					sc.Packet().EventID,
					sc.Packet().GPSTime.Format(time.RFC3339),
        )
			}
			if sc.Err() != nil {
				panic(err) // TODO: Handle error.
			}
		}()
	}
}

Directories

Path Synopsis
nolint: lll
nolint: lll

Jump to

Keyboard shortcuts

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