File: common.go

package info (click to toggle)
golang-github-la5nta-wl2k-go 0.11.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,856 kB
  • sloc: ansic: 14; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,541 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2015 Martin Hebnes Pedersen (LA5NTA). All rights reserved.
// Use of this source code is governed by the MIT-license that can be
// found in the LICENSE file.

// Package hamlib provides bindings for a _subset_ of hamlib.
// It provides both native cgo bindings and a rigctld client.
//
// Use build tag "libhamlib" to build with native C library support.
package hamlib

import "fmt"

// RigModel is the hamlib ID identifying a spesific tranceiver model.
type RigModel int

// Rig represents a receiver or tranceiver.
//
// It holds the data connection to the device.
type Rig interface {
	// Closes the connection to the Rig.
	Close() error

	// Returns the Rig's active VFO (for control).
	CurrentVFO() VFO

	// Returns the Rig's A-VFO (for control).
	VFOA() (VFO, error)

	// Returns the Rig's B-VFO (for control).
	VFOB() (VFO, error)
}

// VFO (Variable Frequency Oscillator) represents a tunable channel, from the radio operator's view.
//
// Also referred to as "BAND" (A-band/B-band) by some radio manufacturers.
type VFO interface {
	// Gets the dial frequency for this VFO.
	GetFreq() (int, error)

	// Sets the dial frequency for this VFO.
	SetFreq(f int) error

	// GetPTT returns the PTT state for this VFO.
	GetPTT() (bool, error)

	// Enable (or disable) PTT on this VFO.
	SetPTT(on bool) error
}

func Open(network, address string) (Rig, error) {
	switch network {
	case "tcp":
		return OpenTCP(address)
	case "serial":
		return OpenSerialURI(address)
	default:
		return nil, fmt.Errorf("Unknown network")
	}
}