pa1010d

package module
v0.0.0-...-26a46bd Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 2 Imported by: 0

README

go-pa1010d

A Go library to read GNSS (e.g. GPS) sensor data from a "CD-PA1010D GNSS patch antenna module".

This was written against the I2C interface of a Raspberry Pi using the github.com/d2r2/go-i2c library although it is not a dependency - you just have to provide a ReadBytes method.

Example usage
package main

import (
	"log"

	"github.com/g-wilson/go-pa1010d"

	"github.com/d2r2/go-i2c"
	"github.com/kr/pretty"
)

const sensorAddress = 0x10

func main() {
	bus, err := i2c.NewI2C(sensorAddress, 1)
	if err != nil {
		log.Fatal(err)
	}
	defer bus.Close()

	gnssReader := pa1010d.New(bus)

	results, errors := gnssReader.Listen()
	for {
		select {
		case err := <-errors:
			log.Println(err)
		case sentence := <-results:
			pretty.Println(sentence)
		}
	}
}

Known issues

The $PMTK011,MTKGPS*08 bootup message cannot be parsed by the go-nmea PMTK parser, because it expects integer commands - MTKGPS is a string. You will see an error on the errors channel, but it will happily continue.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	ReadBytes(buf []byte) (int, error)
}

type PA1010DReader

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

func New

func New(b Bus) *PA1010DReader

func (*PA1010DReader) Listen

func (r *PA1010DReader) Listen() (<-chan nmea.Sentence, <-chan error)

Listen continuously polls the bus for new nmea messages and broadcasts them to the returned channel(s)

Jump to

Keyboard shortcuts

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