github.com/la5nta/wl2k-go@v0.11.8/rigcontrol/hamlib/common.go (about)

     1  // Copyright 2015 Martin Hebnes Pedersen (LA5NTA). All rights reserved.
     2  // Use of this source code is governed by the MIT-license that can be
     3  // found in the LICENSE file.
     4  
     5  // Package hamlib provides bindings for a _subset_ of hamlib.
     6  // It provides both native cgo bindings and a rigctld client.
     7  //
     8  // Use build tag "libhamlib" to build with native C library support.
     9  package hamlib
    10  
    11  import "fmt"
    12  
    13  // RigModel is the hamlib ID identifying a spesific tranceiver model.
    14  type RigModel int
    15  
    16  // Rig represents a receiver or tranceiver.
    17  //
    18  // It holds the data connection to the device.
    19  type Rig interface {
    20  	// Closes the connection to the Rig.
    21  	Close() error
    22  
    23  	// Returns the Rig's active VFO (for control).
    24  	CurrentVFO() VFO
    25  
    26  	// Returns the Rig's A-VFO (for control).
    27  	VFOA() (VFO, error)
    28  
    29  	// Returns the Rig's B-VFO (for control).
    30  	VFOB() (VFO, error)
    31  }
    32  
    33  // VFO (Variable Frequency Oscillator) represents a tunable channel, from the radio operator's view.
    34  //
    35  // Also referred to as "BAND" (A-band/B-band) by some radio manufacturers.
    36  type VFO interface {
    37  	// Gets the dial frequency for this VFO.
    38  	GetFreq() (int, error)
    39  
    40  	// Sets the dial frequency for this VFO.
    41  	SetFreq(f int) error
    42  
    43  	// GetPTT returns the PTT state for this VFO.
    44  	GetPTT() (bool, error)
    45  
    46  	// Enable (or disable) PTT on this VFO.
    47  	SetPTT(on bool) error
    48  }
    49  
    50  func Open(network, address string) (Rig, error) {
    51  	switch network {
    52  	case "tcp":
    53  		return OpenTCP(address)
    54  	case "serial":
    55  		return OpenSerialURI(address)
    56  	default:
    57  		return nil, fmt.Errorf("Unknown network")
    58  	}
    59  }