Esempio n. 1
0
func main() {
	p := geospatial.NewPoint()
	p.Lat = 24.910
	p.Lon = -114.301
	p.Alt = 2000
	fmt.Printf("point: %#v\n", p)

	p2 := geospatial.NewPoint()
	p2.Lat = 25.109
	p2.Lon = -112.121
	p2.Alt = 89
	fmt.Printf("point: %#v\n", p2)

	d := p.DistanceTo(p2)
	fmt.Printf("Distance from p to p2: %v\n", d)
}
Esempio n. 2
0
func main() {
	p := geospatial.NewPoint()
	p.Lat = 24.910
	p.Lon = -114.301
	p.Altitude = 10004
	fmt.Printf("point: %#v\n", p)

	position := aprs.CreateCompressedPositionReport(p, '/', 'O')
	fmt.Printf("Compressed position: %v\n", position)

	dp, st, sc, remains, err := aprs.DecodeCompressedPositionReport(position)

	fmt.Printf("Decoded compressed position: %+v\n", dp)
	fmt.Printf("symtable: %v   symcode: %v\n", st, sc)
	fmt.Printf("remains: %v\n", remains)

	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}

	u_pos, err := aprs.CreateUncompressedPositionReportWithoutTimestamp(p, '/', 'O', true)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}
	fmt.Printf("Uncompressed position: %v\n", u_pos)

	upos_dec, sym_t, sym_c, remains, err := aprs.DecodeUncompressedPositionReportWithoutTimestamp(u_pos)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	} else {
		fmt.Printf("Decoded uncompressed position:  %+v\n", upos_dec)
		fmt.Printf("symtable: %v   symcode: %v\n", sym_t, sym_c)
		fmt.Printf("remains: %v\n", remains)
	}

	upos_time_dec, sym_t, sym_c, remains, err := aprs.DecodeUncompressedPositionReportWithTimestamp("@092345z4903.50N/07201.75W>")
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	} else {
		fmt.Printf("Decoded uncompressed position with timestamp:  %+v\n", upos_time_dec)
		fmt.Printf("symtable: %v   symcode: %v\n", sym_t, sym_c)
		fmt.Printf("remains: %v\n", remains)
	}
}
Esempio n. 3
0
func main() {

	port := flag.String("port", "/dev/ttyUSB0", "Serial port device (defaults to /dev/ttyUSB0)")
	flag.Parse()

	c := &serial.Config{Name: *port, Baud: 4800}

	s, err := serial.OpenPort(c)
	if err != nil {
		log.Fatal(err)
	}

	psource := ax25.APRSAddress{
		Callsign: "NW5W",
		SSID:     7,
	}

	pdest := ax25.APRSAddress{
		Callsign: "APZ001",
		SSID:     0,
	}

	var path []ax25.APRSAddress

	path = append(path, ax25.APRSAddress{
		Callsign: "WIDE1",
		SSID:     1,
	})

	path = append(path, ax25.APRSAddress{
		Callsign: "WIDE2",
		SSID:     1,
	})

	point := geospatial.NewPoint()
	point.Lat = 47.262347
	point.Lon = -122.46988
	point.Alt = 1702

	position := aprs.CreateCompressedPosition(point, '/', 'O')
	body := fmt.Sprint(position, "GoBalloon Test http://nw5w.com")

	a := ax25.APRSPacket{
		Source: psource,
		Dest:   pdest,
		Path:   path,
		Body:   body,
	}

	packet, err := ax25.EncodeAX25Command(a)
	if err != nil {
		log.Fatalf("Unable to create packet: %v", err)
	}

	s.Write(packet)

	err = s.Close()
	if err != nil {
		log.Fatalf("Error closing port: %v", err)
	}

	// Let's decode our own packet to make sure tht it's bueno
	buf := bytes.NewReader(packet)
	d := ax25.NewDecoder(buf)
	msg, err := d.Next()
	fmt.Printf("%+v\n", msg)

}