goHamlib

package module
v0.0.0-...-3752aec Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 7 Imported by: 13

README

Hamlib binding for Golang

Go Report Card Build Status Coverage Status

This is a golang binding for Hamlib. The binding has been hand written in order to provide a golang idiomatic API but staying also close as possible to hamlib's C API. Except of Hamlib (C), goHamlib has no other external dependencies.

goHamlib is compatible with both, Hamlib 1.2.x and 3.x.

You might also want to checkout gorigctl which is a drop-in replacement for hamlib's rigctl, although it comes with a cli GUI and a modern, open network interface (implementing the shackbus specification using protocol buffers and MQTT).

Implementation status

Currently, goHamlib covers about 80% of the hamlib API. Basically (the rarely used) Channel API is still missing.

Supported Platforms

goHamlib has been tested on the following platforms:

  • AMD64
  • i386
  • ARMv7 (e.g. Raspberry Pi 2)
  • ARMv8 (e.g. Raspberry Pi 3)

and the following operating Systems:

  • Linux (Ubuntu, Raspian, Armbian)
  • MacOS (Sierra)
  • Windows 10

License

This library is published under the permissive MIT license. Although please keep in mind that Hamlib is published under the LGPL license.

Installation & Compilation

goHamlib depends on Hamlib which can be either installed through your OS packet manager or easily build from source. If you want the latest patches and support for the latest rigs, you might want to compile the latest stable release or directly from the git repository.

Make sure that you have installed the latest release of Go and set the GOPATH environment variable.

Linux Dependencies
$ sudo apt-get install -y libhamlib2 libhamlib-dev
MacOS Dependencies

You can install the hamlib package through homebrew

$ brew install hamlib
Compilation
$ go get github.com/dh1tw/goHamlib

Tests

Most of goHamlib's API is unit tested. In order to execute the unit tests, run:

$ cd $GOPATH/src/github.com/dh1tw/goHamlib
$ go test

Documentation

goHamlib's API is documented at go.dev

Example

Checkout the dummyrig_test.go in this repository to see how to use goHamlib.

Documentation

Index

Constants

View Source
const (
	RIG_PTT_OFF     = 0
	RIG_PTT_ON      = 1
	RIG_PTT_ON_MIC  = 2
	RIG_PTT_ON_DATA = 3
)

Hamlib PTT

View Source
const (
	RIG_ANT_NONE = 0
	RIG_ANT_1    = 1 << 0
	RIG_ANT_2    = 1 << 1
	RIG_ANT_3    = 1 << 2
	RIG_ANT_4    = 1 << 3
	RIG_ANT_5    = 1 << 4
)

Hamlib Antennas

View Source
const (
	RIG_SPLIT_OFF = 0
	RIG_SPLIT_ON  = 1
)

Hamlib Split

View Source
const (
	RIG_LEVEL_NONE       = 0
	RIG_LEVEL_PREAMP     = 1 << 0
	RIG_LEVEL_ATT        = 1 << 1
	RIG_LEVEL_VOX        = 1 << 2
	RIG_LEVEL_AF         = 1 << 3
	RIG_LEVEL_RF         = 1 << 4
	RIG_LEVEL_SQL        = 1 << 5
	RIG_LEVEL_IF         = 1 << 6
	RIG_LEVEL_APF        = 1 << 7
	RIG_LEVEL_NR         = 1 << 8
	RIG_LEVEL_PBT_IN     = 1 << 9
	RIG_LEVEL_PBT_OUT    = 1 << 10
	RIG_LEVEL_CWPITCH    = 1 << 11
	RIG_LEVEL_RFPOWER    = 1 << 12
	RIG_LEVEL_MICGAIN    = 1 << 13
	RIG_LEVEL_KEYSPD     = 1 << 14
	RIG_LEVEL_NOTCHF     = 1 << 15
	RIG_LEVEL_COMP       = 1 << 16
	RIG_LEVEL_AGC        = 1 << 17
	RIG_LEVEL_BKINDL     = 1 << 18
	RIG_LEVEL_BALANCE    = 1 << 19
	RIG_LEVEL_METER      = 1 << 20
	RIG_LEVEL_VOXGAIN    = 1 << 21
	RIG_LEVEL_VOXDELAY   = RIG_LEVEL_VOX
	RIG_LEVEL_ANTIVOX    = 1 << 22
	RIG_LEVEL_SLOPE_LOW  = 1 << 23
	RIG_LEVEL_SLOPE_HIGH = 1 << 24
	RIG_LEVEL_BKIN_DLYMS = 1 << 25
	RIG_LEVEL_RAWSTR     = 1 << 26
	RIG_LEVEL_SQLSTAT    = 1 << 27
	RIG_LEVEL_SWR        = 1 << 28
	RIG_LEVEL_ALC        = 1 << 29
	RIG_LEVEL_STRENGTH   = 1 << 30
)

Hamlib Levels

View Source
const (
	RIG_PARM_NONE      = 0
	RIG_PARM_ANN       = 1 << 0
	RIG_PARM_APO       = 1 << 1
	RIG_PARM_BACKLIGHT = 1 << 2
	RIG_PARM_BEEP      = 1 << 4
	RIG_PARM_TIME      = 1 << 5
	RIG_PARM_BAT       = 1 << 6
	RIG_PARM_KEYLIGHT  = 1 << 7
)

Hamlib Params

View Source
const (
	RIG_FUNC_NONE    = 0
	RIG_FUNC_FAGC    = 1 << 0
	RIG_FUNC_NB      = 1 << 1
	RIG_FUNC_COMP    = 1 << 2
	RIG_FUNC_VOX     = 1 << 3
	RIG_FUNC_TONE    = 1 << 4
	RIG_FUNC_TSQL    = 1 << 5
	RIG_FUNC_SBKIN   = 1 << 6
	RIG_FUNC_FBKIN   = 1 << 7
	RIG_FUNC_ANF     = 1 << 8
	RIG_FUNC_NR      = 1 << 9
	RIG_FUNC_AIP     = 1 << 10
	RIG_FUNC_APF     = 1 << 11
	RIG_FUNC_MON     = 1 << 12
	RIG_FUNC_MN      = 1 << 13
	RIG_FUNC_RF      = 1 << 14
	RIG_FUNC_ARO     = 1 << 15
	RIG_FUNC_LOCK    = 1 << 16
	RIG_FUNC_MUTE    = 1 << 17
	RIG_FUNC_VSC     = 1 << 18
	RIG_FUNC_REV     = 1 << 19
	RIG_FUNC_SQL     = 1 << 20
	RIG_FUNC_ABM     = 1 << 21
	RIG_FUNC_BC      = 1 << 22
	RIG_FUNC_MBC     = 1 << 23
	RIG_FUNC_RIT     = 1 << 24
	RIG_FUNC_AFC     = 1 << 25
	RIG_FUNC_SATMODE = 1 << 26
	RIG_FUNC_SCOPE   = 1 << 27
	RIG_FUNC_RESUME  = 1 << 28
	RIG_FUNC_TBURST  = 1 << 29
	RIG_FUNC_TUNER   = 1 << 30
	RIG_FUNC_XIT     = 1 << 31
)

Hamlib Functions

View Source
const (
	RIG_METER_NONE = 0
	RIG_METER_SWR  = 1 << 0
	RIG_METER_COMP = 1 << 1
	RIG_METER_ALC  = 1 << 2
	RIG_METER_IC   = 1 << 3
	RIG_METER_DB   = 1 << 4
	RIG_METER_PO   = 1 << 5
	RIG_METER_VDD  = 1 << 6
)

Rig Meter

View Source
const (
	RIG_STATUS_ALPHA    = 0
	RIG_STATUS_UNTESTED = 1
	RIG_STATUS_BETA     = 2
	RIG_STATUS_STABLE   = 3
	RIG_STATUS_BUGGY    = 4
)
View Source
const (
	RIG_PTT_NONE        = 0
	RIG_PTT_RIG         = 1
	RIG_PTT_SERIAL_DTR  = 2
	RIG_PTT_SERIAL_RTS  = 3
	RIG_PTT_PARALLEL    = 4
	RIG_PTT_RIG_MICDATA = 5
	RIG_PTT_CM108       = 6
)
View Source
const (
	RIG_DCD_NONE       = 0
	RIG_DCD_RIG        = 1
	RIG_DCD_SERIAL_DSR = 2
	RIG_DCD_SERIAL_CTS = 3
	RIG_DCD_SERIAL_CAR = 4
	RIG_DCD_PARALLEL   = 5
	RIG_DCD_CM108      = 6
)
View Source
const (
	TOK_FAST_SET_CMD = 1
)

configuration Token

Variables

View Source
var AntName = map[int]string{
	RIG_ANT_1: "ANT1",
	RIG_ANT_2: "ANT2",
	RIG_ANT_3: "ANT3",
	RIG_ANT_4: "ANT4",
	RIG_ANT_5: "ANT5",
}
View Source
var AntValue = map[string]int{
	"ANT1": RIG_ANT_1,
	"ANT2": RIG_ANT_2,
	"ANT3": RIG_ANT_3,
	"ANT4": RIG_ANT_4,
	"ANT5": RIG_ANT_5,
}
View Source
var DebugLevelName = map[DebugLevel]string{
	DebugNone:    "NONE",
	DebugBug:     "BUG",
	DebugErr:     "ERROR",
	DebugWarn:    "WARN",
	DebugVerbose: "VERBOSE",
	DebugTrace:   "TRACE",
}

DebugLevelName maps DebugLevel to a name string

View Source
var DebugLevelValue = map[string]DebugLevel{
	"NONE":    DebugNone,
	"BUG":     DebugBug,
	"ERROR":   DebugErr,
	"WARN":    DebugWarn,
	"VERBOSE": DebugVerbose,
	"TRACE":   DebugTrace,
}

DebugLevelValue maps strings to DebugLevel

View Source
var FuncName = map[uint32]string{
	RIG_FUNC_NONE:    "",
	RIG_FUNC_FAGC:    "FAGC",
	RIG_FUNC_NB:      "NB",
	RIG_FUNC_COMP:    "COMP",
	RIG_FUNC_VOX:     "VOX",
	RIG_FUNC_TONE:    "TONE",
	RIG_FUNC_TSQL:    "TSQL",
	RIG_FUNC_SBKIN:   "SBKIN",
	RIG_FUNC_FBKIN:   "FBKIN",
	RIG_FUNC_ANF:     "ANF",
	RIG_FUNC_NR:      "NR",
	RIG_FUNC_AIP:     "AIP",
	RIG_FUNC_APF:     "APF",
	RIG_FUNC_MON:     "MON",
	RIG_FUNC_MN:      "MN",
	RIG_FUNC_RF:      "RF",
	RIG_FUNC_ARO:     "ARO",
	RIG_FUNC_LOCK:    "LOCK",
	RIG_FUNC_MUTE:    "MUTE",
	RIG_FUNC_VSC:     "VSC",
	RIG_FUNC_REV:     "REV",
	RIG_FUNC_SQL:     "SQL",
	RIG_FUNC_ABM:     "ABM",
	RIG_FUNC_BC:      "BC",
	RIG_FUNC_MBC:     "MBC",
	RIG_FUNC_RIT:     "RIT",
	RIG_FUNC_AFC:     "AFC",
	RIG_FUNC_SATMODE: "SATMODE",
	RIG_FUNC_SCOPE:   "SCOPE",
	RIG_FUNC_RESUME:  "RESUME",
	RIG_FUNC_TBURST:  "TBURST",
	RIG_FUNC_TUNER:   "TUNER",
	RIG_FUNC_XIT:     "XIT",
}
View Source
var FuncValue = map[string]uint32{
	"":        RIG_FUNC_NONE,
	"FAGC":    RIG_FUNC_FAGC,
	"NB":      RIG_FUNC_NB,
	"COMP":    RIG_FUNC_COMP,
	"VOX":     RIG_FUNC_VOX,
	"TONE":    RIG_FUNC_TONE,
	"TSQL":    RIG_FUNC_TSQL,
	"SBKIN":   RIG_FUNC_SBKIN,
	"FBKIN":   RIG_FUNC_FBKIN,
	"ANF":     RIG_FUNC_ANF,
	"NR":      RIG_FUNC_NR,
	"AIP":     RIG_FUNC_AIP,
	"APF":     RIG_FUNC_APF,
	"MON":     RIG_FUNC_MON,
	"MN":      RIG_FUNC_MN,
	"RF":      RIG_FUNC_RF,
	"ARO":     RIG_FUNC_ARO,
	"LOCK":    RIG_FUNC_LOCK,
	"MUTE":    RIG_FUNC_MUTE,
	"VSC":     RIG_FUNC_VSC,
	"REV":     RIG_FUNC_REV,
	"SQL":     RIG_FUNC_SQL,
	"ABM":     RIG_FUNC_ABM,
	"BC":      RIG_FUNC_BC,
	"MBC":     RIG_FUNC_MBC,
	"RIT":     RIG_FUNC_RIT,
	"AFC":     RIG_FUNC_AFC,
	"SATMODE": RIG_FUNC_SATMODE,
	"SCOPE":   RIG_FUNC_SCOPE,
	"RESUME":  RIG_FUNC_RESUME,
	"TBURST":  RIG_FUNC_TBURST,
	"TUNER":   RIG_FUNC_TUNER,
	"XIT":     RIG_FUNC_XIT,
}
View Source
var LevelName = map[uint32]string{
	RIG_LEVEL_NONE:    "",
	RIG_LEVEL_PREAMP:  "PREAMP",
	RIG_LEVEL_ATT:     "ATT",
	RIG_LEVEL_VOX:     "VOX",
	RIG_LEVEL_AF:      "AF",
	RIG_LEVEL_RF:      "RF",
	RIG_LEVEL_SQL:     "SQL",
	RIG_LEVEL_IF:      "IF",
	RIG_LEVEL_APF:     "APF",
	RIG_LEVEL_NR:      "NR",
	RIG_LEVEL_PBT_IN:  "PBT_IN",
	RIG_LEVEL_PBT_OUT: "PBT_OUT",
	RIG_LEVEL_CWPITCH: "CWPITCH",
	RIG_LEVEL_RFPOWER: "RFPOWER",
	RIG_LEVEL_MICGAIN: "MICGAIN",
	RIG_LEVEL_KEYSPD:  "KEYSPD",
	RIG_LEVEL_NOTCHF:  "NOTCHF",
	RIG_LEVEL_COMP:    "COMP",
	RIG_LEVEL_AGC:     "AGC",
	RIG_LEVEL_BKINDL:  "BKINDL",
	RIG_LEVEL_BALANCE: "BALANCE",
	RIG_LEVEL_METER:   "METER",
	RIG_LEVEL_VOXGAIN: "VOXGAIN",

	RIG_LEVEL_ANTIVOX:    "ANTIVOX",
	RIG_LEVEL_SLOPE_LOW:  "SLOPE_LOW",
	RIG_LEVEL_SLOPE_HIGH: "SLOPE_HIGH",
	RIG_LEVEL_BKIN_DLYMS: "BKIN_DLYMS",
	RIG_LEVEL_RAWSTR:     "RAWSTR",
	RIG_LEVEL_SQLSTAT:    "SQLSTAT",
	RIG_LEVEL_SWR:        "SWR",
	RIG_LEVEL_ALC:        "ALC",
	RIG_LEVEL_STRENGTH:   "STRENGTH",
}
View Source
var LevelValue = map[string]uint32{
	"":        RIG_LEVEL_NONE,
	"PREAMP":  RIG_LEVEL_PREAMP,
	"ATT":     RIG_LEVEL_ATT,
	"VOX":     RIG_LEVEL_VOX,
	"AF":      RIG_LEVEL_AF,
	"RF":      RIG_LEVEL_RF,
	"SQL":     RIG_LEVEL_SQL,
	"IF":      RIG_LEVEL_IF,
	"APF":     RIG_LEVEL_APF,
	"NR":      RIG_LEVEL_NR,
	"PBT_IN":  RIG_LEVEL_PBT_IN,
	"PBT_OUT": RIG_LEVEL_PBT_OUT,
	"CWPITCH": RIG_LEVEL_CWPITCH,
	"RFPOWER": RIG_LEVEL_RFPOWER,
	"MICGAIN": RIG_LEVEL_MICGAIN,
	"KEYSPD":  RIG_LEVEL_KEYSPD,
	"NOTCHF":  RIG_LEVEL_NOTCHF,
	"COMP":    RIG_LEVEL_COMP,
	"AGC":     RIG_LEVEL_AGC,
	"BKINDL":  RIG_LEVEL_BKINDL,
	"BALANCE": RIG_LEVEL_BALANCE,
	"METER":   RIG_LEVEL_METER,
	"VOXGAIN": RIG_LEVEL_VOXGAIN,

	"ANTIVOX":    RIG_LEVEL_ANTIVOX,
	"SLOPE_LOW":  RIG_LEVEL_SLOPE_LOW,
	"SLOPE_HIGH": RIG_LEVEL_SLOPE_HIGH,
	"BKIN_DLYMS": RIG_LEVEL_BKIN_DLYMS,
	"RAWSTR":     RIG_LEVEL_RAWSTR,
	"SQLSTAT":    RIG_LEVEL_SQLSTAT,
	"SWR":        RIG_LEVEL_SWR,
	"ALC":        RIG_LEVEL_ALC,
	"STRENGTH":   RIG_LEVEL_STRENGTH,
}
View Source
var ModeName = map[Mode]string{
	ModeNONE:    "",
	ModeAM:      "AM",
	ModeCW:      "CW",
	ModeUSB:     "USB",
	ModeLSB:     "LSB",
	ModeRTTY:    "RTTY",
	ModeFM:      "FM",
	ModeWFM:     "WFM",
	ModeCWR:     "CWR",
	ModeRTTYR:   "RTTYR",
	ModeAMS:     "AMS",
	ModePKTLSB:  "PKTLSB",
	ModePKTUSB:  "PKTUSB",
	ModePKTFM:   "PKTFM",
	ModeECSSUSB: "ECSSUSB",
	ModeECSSLSB: "ECSSLSB",
	ModeFAX:     "FAX",
	ModeSAM:     "SAM",
	ModeSAL:     "SAL",
	ModeSAH:     "SAH",
	ModeDSB:     "DSB",
	ModeFMN:     "FMN",
}

ModeName is a map containing Strings for Modes

View Source
var ModeValue = map[string]Mode{
	"":        ModeNONE,
	"AM":      ModeAM,
	"CW":      ModeCW,
	"USB":     ModeUSB,
	"LSB":     ModeLSB,
	"RTTY":    ModeRTTY,
	"FM":      ModeFM,
	"WFM":     ModeWFM,
	"CWR":     ModeCWR,
	"RTTYR":   ModeRTTYR,
	"AMS":     ModeAMS,
	"PKTLSB":  ModePKTLSB,
	"PKTUSB":  ModePKTUSB,
	"PKTFM":   ModePKTFM,
	"ECSSUSB": ModeECSSUSB,
	"ECSSLSB": ModeECSSLSB,
	"FAX":     ModeFAX,
	"SAM":     ModeSAM,
	"SAL":     ModeSAL,
	"SAH":     ModeSAH,
	"DSB":     ModeDSB,
	"FMN":     ModeFMN,
}

ModeValue is a map containing Values for Modes

View Source
var ParmName = map[uint32]string{
	RIG_PARM_NONE:      "",
	RIG_PARM_ANN:       "ANN",
	RIG_PARM_APO:       "APO",
	RIG_PARM_BACKLIGHT: "BACKLIGHT",
	RIG_PARM_BEEP:      "BEEP",
	RIG_PARM_TIME:      "TIME",
	RIG_PARM_BAT:       "BAT",
	RIG_PARM_KEYLIGHT:  "KEYLIGHT",
}
View Source
var ParmValue = map[string]uint32{
	"":          RIG_PARM_NONE,
	"ANN":       RIG_PARM_ANN,
	"APO":       RIG_PARM_APO,
	"BACKLIGHT": RIG_PARM_BACKLIGHT,
	"BEEP":      RIG_PARM_BEEP,
	"TIME":      RIG_PARM_TIME,
	"BAT":       RIG_PARM_BAT,
	"KEYLIGHT":  RIG_PARM_KEYLIGHT,
}
View Source
var PttName = map[int]string{
	RIG_PTT_OFF:     "OFF",
	RIG_PTT_ON:      "ON",
	RIG_PTT_ON_MIC:  "ON_MIC",
	RIG_PTT_ON_DATA: "ON_DATA",
}
View Source
var PttValue = map[string]int{
	"OFF":     RIG_PTT_OFF,
	"ON":      RIG_PTT_ON,
	"ON_MIC":  RIG_PTT_ON_MIC,
	"ON_DATA": RIG_PTT_ON_DATA,
}
View Source
var RigDcdName = map[int]string{
	RIG_DCD_NONE:       "NONE",
	RIG_DCD_RIG:        "RIG",
	RIG_DCD_SERIAL_DSR: "DSR",
	RIG_DCD_SERIAL_CTS: "CTS",
	RIG_DCD_SERIAL_CAR: "CAR",
	RIG_DCD_PARALLEL:   "PARALLEL",
	RIG_DCD_CM108:      "GPIO",
}
View Source
var RigDcdValue = map[string]int{
	"NONE":     RIG_DCD_NONE,
	"RIG":      RIG_DCD_RIG,
	"DSR":      RIG_DCD_SERIAL_DSR,
	"CTS":      RIG_DCD_SERIAL_CTS,
	"CAR":      RIG_DCD_SERIAL_CAR,
	"PARALLEL": RIG_DCD_PARALLEL,
	"GPIO":     RIG_DCD_CM108,
}
View Source
var RigPortName = map[RigPort]string{
	RigPortNone:       "RIG_PORT_NONE",
	RigPortSerial:     "RIG_PORT_SERIAL",
	RigPortNetwork:    "RIG_PORT_NETWORK",
	RigPortDevice:     "RIG_PORT_DEVICE",
	RigPortPacket:     "RIG_PORT_PACKET",
	RigPortDTMF:       "RIG_PORT_DTMF",
	RigPortUltra:      "RIG_PORT_ULTRA",
	RigPortRPC:        "RIG_PORT_RPC",
	RigPortParallel:   "RIG_PORT_PARALLEL",
	RigPortUSB:        "RIG_PORT_USB",
	RigPortUDPNetwork: "RIG_PORT_UDP_NETWORK",
	RigPortCM108:      "RIG_PORT_CM108",
}

RigPortValue is a map of RigPort to names

View Source
var RigPortValue = map[string]RigPort{
	"RIG_PORT_NONE":        RigPortNone,
	"RIG_PORT_SERIAL":      RigPortSerial,
	"RIG_PORT_NETWORK":     RigPortNetwork,
	"RIG_PORT_DEVICE":      RigPortDevice,
	"RIG_PORT_PACKET":      RigPortPacket,
	"RIG_PORT_DTMF":        RigPortDTMF,
	"RIG_PORT_ULTRA":       RigPortUltra,
	"RIG_PORT_RPC":         RigPortRPC,
	"RIG_PORT_PARALLEL":    RigPortParallel,
	"RIG_PORT_USB":         RigPortUSB,
	"RIG_PORT_UDP_NETWORK": RigPortUDPNetwork,
	"RIG_PORT_CM108":       RigPortCM108,
}

RigPortValue is a map of names to RigPort

View Source
var RigPowerName = map[Power]string{
	PowerOff:     "OFF",
	PowerOn:      "ON",
	PowerStandby: "STANDBY",
}
View Source
var RigPowerValue = map[string]Power{
	"OFF":     PowerOff,
	"ON":      PowerOn,
	"STANDBY": PowerStandby,
}
View Source
var RigPttName = map[int]string{
	RIG_PTT_NONE:        "NONE",
	RIG_PTT_RIG:         "CAT",
	RIG_PTT_SERIAL_DTR:  "DTR",
	RIG_PTT_SERIAL_RTS:  "RTS",
	RIG_PTT_PARALLEL:    "PARALLEL",
	RIG_PTT_RIG_MICDATA: "MIC",
	RIG_PTT_CM108:       "GPIO",
}
View Source
var RigPttValue = map[string]int{
	"NONE":     RIG_PTT_NONE,
	"CAT":      RIG_PTT_RIG,
	"DTR":      RIG_PTT_SERIAL_DTR,
	"RTS":      RIG_PTT_SERIAL_RTS,
	"PARALLEL": RIG_PTT_PARALLEL,
	"MIC":      RIG_PTT_RIG_MICDATA,
	"GPIO":     RIG_PTT_CM108,
}
View Source
var RigStatusName = map[int]string{
	RIG_STATUS_ALPHA:    "ALPHA",
	RIG_STATUS_UNTESTED: "UNTESTED",
	RIG_STATUS_BETA:     "BETA",
	RIG_STATUS_STABLE:   "STABLE",
	RIG_STATUS_BUGGY:    "BUGGY",
}
View Source
var RigStatusValue = map[string]int{
	"ALPHA":    RIG_STATUS_ALPHA,
	"UNTESTED": RIG_STATUS_UNTESTED,
	"BETA":     RIG_STATUS_BETA,
	"STABLE":   RIG_STATUS_STABLE,
	"BUGGY":    RIG_STATUS_BUGGY,
}
View Source
var VFOName = map[VFOType]string{
	VFONone:    "NONE",
	VFOA:       "VFOA",
	VFOB:       "VFOB",
	VFOC:       "VFOC",
	VFOCurrent: "CURR",
	VFOMemory:  "MEM",
	VFOLastVFO: "VFO",
	VFOTX:      "TX",

	VFOMain: "MAIN",
	VFOSub:  "SUB",
}

VFOName is a map containing Strings for VFOs

View Source
var VFOOperationName = map[VFOOp]string{
	VFOOpNone:        "",
	VFOOpCopy:        "CPY",
	VFOOpExchange:    "XCHG",
	VFOOpFromVFO:     "FROM_VFO",
	VFOOpToVFO:       "TO_VFO",
	VFOOpMemoryClear: "MCL",
	VFOOpUp:          "UP",
	VFOOpDown:        "DOWN",
	VFOOpBandUp:      "BAND_UP",
	VFOOpBandDown:    "BAND_DOWN",
	VFOOpLeft:        "LEFT",
	VFOOpRight:       "RIGHT",
	VFOOpTune:        "TUNE",
	VFOOpToggle:      "TOGGLE",
}

VFOOperationName is a map of VFO operation values to names

View Source
var VFOOperationValue = map[string]VFOOp{
	"":          VFOOpNone,
	"CPY":       VFOOpCopy,
	"XCHG":      VFOOpExchange,
	"FROM_VFO":  VFOOpFromVFO,
	"TO_VFO":    VFOOpToVFO,
	"MCL":       VFOOpMemoryClear,
	"UP":        VFOOpUp,
	"DOWN":      VFOOpDown,
	"BAND_UP":   VFOOpBandUp,
	"BAND_DOWN": VFOOpBandDown,
	"LEFT":      VFOOpLeft,
	"RIGHT":     VFOOpRight,
	"TUNE":      VFOOpTune,
	"TOGGLE":    VFOOpToggle,
}

VFOOperationValue is a map of VFO operation names to values

View Source
var VFOValue = map[string]VFOType{
	"NONE": VFONone,
	"VFOA": VFOA,
	"VFOB": VFOB,
	"VFOC": VFOC,
	"CURR": VFOCurrent,
	"MAIN": VFOMain,
	"SUB":  VFOSub,
	"MEM":  VFOMemory,
	"VFO":  VFOLastVFO,
	"TX":   VFOTX,
}

VFOValue is a map from VFO names to values

Functions

func BoolToCint

func BoolToCint(myBool bool) (C.int, error)

BoolToCint ...

func CIntToBool

func CIntToBool(myInt C.int) (bool, error)

CIntToBool ....

func SetDebugCallback

func SetDebugCallback(fn func(level DebugLevel, msg string))

SetDebugCallback replaces the function that handles debug messages, preventing them from being written to STDOUT

func SetDebugLevel

func SetDebugLevel(dbgLevel DebugLevel)

Set Debug level

Types

type Caps

type Caps struct {
	RigModel        int
	ModelName       string
	MfgName         string
	Version         string
	Copyright       string
	Status          int
	RigType         int
	PttType         int
	DcdType         int
	PortType        int
	SerialRateMin   int
	SerialRateMax   int
	SerialDataBits  int
	SerialStopBits  int
	SerialParity    int
	SerialHandshake int
	WriteDelay      int
	PostWriteDelay  int
	Timeout         int
	Retry           int
	Preamps         []int
	Attenuators     []int
	MaxRit          int
	MaxXit          int
	MaxIfShift      int
	Vfos            []string
	Operations      []string
	Modes           []string
	GetFunctions    []string
	SetFunctions    []string
	GetLevels       Values
	SetLevels       Values
	GetParameters   Values
	SetParameters   Values
	TargetableVfo   int
	TargetableVfos  []int
	Transceive      int
	BankQty         int
	ChannelDescSz   int
	ChannelList     []Channel
	Filters         map[string][]int //mode + List of supported filter bandwidths
	TuningSteps     map[string][]int // mode + List of supported tuning steps
	ExtParms        []ConfParams
	ExtLevels       []ConfParams
	CtcssList       []uint
	DcsList         []uint
	Announces       int
	ScanOperations  []string
	CfgParams       []ConfParams
	HasGetPowerStat bool
	HasSetPowerStat bool
	HasGetVfo       bool
	HasSetVfo       bool
	HasSetFreq      bool
	HasGetFreq      bool
	HasSetMode      bool
	HasGetMode      bool
	HasSetPtt       bool
	HasGetPtt       bool
	HasSetRit       bool
	HasGetRit       bool
	HasSetXit       bool
	HasGetXit       bool
	HasSetSplitVfo  bool
	HasGetSplitVfo  bool
	HasSetSplitMode bool
	HasGetSplitMode bool
	HasSetSplitFreq bool
	HasGetSplitFreq bool
	HasSetAnt       bool
	HasGetAnt       bool
	HasSetTs        bool
	HasGetTs        bool
	HasGetConf      bool
	HasSetConf      bool
}

type Channel

type Channel struct {
	ChannelNum  int
	BankNum     int
	Vfo         uint32
	Ant         int
	Freq        float64
	Mode        uint32
	Width       int
	TxFreq      float64
	TxMode      uint32
	TxWidth     int
	Split       int
	TxVfo       uint32
	RptrShift   int
	RptrOffset  int
	TuningStep  int
	Rit         int
	Xit         int
	Funcs       uint32
	Levels      Value
	CtcssTone   uint
	CtcssSql    uint
	DcsCode     uint
	DcsSql      uint
	ScanGroup   int
	Flags       int
	Description string
	ExtLevels   []ExtList
}

type ConfParams

type ConfParams struct {
	Token    int64
	Name     string
	Label    string
	Tooltip  string
	Dflt     string
	RigConfE int
}

type DebugLevel

type DebugLevel byte

DebugLevel is the Hamlib Debug level type

const (
	DebugNone    DebugLevel = 0
	DebugBug     DebugLevel = 1
	DebugErr     DebugLevel = 2
	DebugWarn    DebugLevel = 3
	DebugVerbose DebugLevel = 4
	DebugTrace   DebugLevel = 5
)

Hamlib debug level constants

type Error

type Error struct {
	Operation       string
	UnderlyingError error
}

func (*Error) Error

func (e *Error) Error() string

type ExtList

type ExtList struct {
	Token int64
	Value Value
}

type HamlibError

type HamlibError struct {
	Operation   string
	Errorcode   HamlibErrorCode
	Description string
}

func (*HamlibError) Error

func (e *HamlibError) Error() string

type HamlibErrorCode

type HamlibErrorCode int

HamlibErrorCode is an error code returned from libhamlib

const (
	HamlibErrOK        HamlibErrorCode = 0
	HamlibErrEINVAL    HamlibErrorCode = -1
	HamlibErrECONF     HamlibErrorCode = -2
	HamlibErrENOMEM    HamlibErrorCode = -3
	HamlibErrENIMPL    HamlibErrorCode = -4
	HamlibErrETIMEOUT  HamlibErrorCode = -5
	HamlibErrEIO       HamlibErrorCode = -6
	HamlibErrEINTERNAL HamlibErrorCode = -7
	HamlibErrEPROTO    HamlibErrorCode = -8
	HamlibErrERJCTED   HamlibErrorCode = -9
	HamlibErrETRUNC    HamlibErrorCode = -10
	HamlibErrENAVAIL   HamlibErrorCode = -11
	HamlibErrENTARGET  HamlibErrorCode = -12
	HamlibErrBUSERROR  HamlibErrorCode = -13
	HamlibErrBUSBUSY   HamlibErrorCode = -14
	HamlibErrEARG      HamlibErrorCode = -15
	HamlibErrEVFO      HamlibErrorCode = -16
	HamlibErrEDOM      HamlibErrorCode = -17
)

Hamlib Error Codes

type Handshake

type Handshake byte

Handshake is a serial port handshake type

const (
	HandshakeNone   Handshake = 0
	HandshakeRTSCTS Handshake = 1
)

Serial port handshake constants

type Mode

type Mode uint32

Mode is the rig operation mode

const (
	ModeNONE    Mode = 0
	ModeAM      Mode = 1 << 0
	ModeCW      Mode = 1 << 1
	ModeUSB     Mode = 1 << 2
	ModeLSB     Mode = 1 << 3
	ModeRTTY    Mode = 1 << 4
	ModeFM      Mode = 1 << 5
	ModeWFM     Mode = 1 << 6
	ModeCWR     Mode = 1 << 7
	ModeRTTYR   Mode = 1 << 8
	ModeAMS     Mode = 1 << 9
	ModePKTLSB  Mode = 1 << 10
	ModePKTUSB  Mode = 1 << 11
	ModePKTFM   Mode = 1 << 12
	ModeECSSUSB Mode = 1 << 13
	ModeECSSLSB Mode = 1 << 14
	ModeFAX     Mode = 1 << 15
	ModeSAM     Mode = 1 << 16
	ModeSAL     Mode = 1 << 17
	ModeSAH     Mode = 1 << 18
	ModeDSB     Mode = 1 << 19
	ModeFMN     Mode = 1 << 21
	ModeTESTS_MAX
)

Hamlib modes

type Parity

type Parity byte

Parity is the serial port parity

const (
	ParityNone Parity = 0
	ParityEven Parity = 1
	ParityOdd  Parity = 2
)

Serial port parity constants

type Port

type Port struct {
	RigPortType RigPort
	Portname    string
	Baudrate    int
	Databits    int
	Stopbits    int
	Parity      Parity
	Handshake   Handshake
}

type Power

type Power byte

Power is the hamlib power state

const (
	PowerOff     Power = 0
	PowerOn      Power = 1
	PowerStandby Power = 2
)

type Rig

type Rig struct {
	Caps Caps
	// contains filtered or unexported fields
}

func (*Rig) Cleanup

func (rig *Rig) Cleanup() error

Grabage collect Radio and free up memory

func (*Rig) Close

func (rig *Rig) Close() error

Close the Communication with the Radio

func (*Rig) GetAnt

func (rig *Rig) GetAnt(vfo VFOType) (ant int, err error)

Get Antenna

func (*Rig) GetConf

func (rig *Rig) GetConf(token string) (val string, err error)

Get configuration token

func (*Rig) GetFreq

func (rig *Rig) GetFreq(vfo VFOType) (freq float64, err error)

Get Frequency from a VFO

func (*Rig) GetFunc

func (rig *Rig) GetFunc(vfo VFOType, function uint32) (value bool, err error)

get Function

func (*Rig) GetInfo

func (rig *Rig) GetInfo() (info string, err error)

Get Rig info

func (*Rig) GetLevel

func (rig *Rig) GetLevel(vfo VFOType, level uint32) (value float32, err error)

get Level

func (*Rig) GetLevelGran

func (rig *Rig) GetLevelGran(level uint32) (step float32, min float32, max float32, err error)

Get granularity (stepsize, minimum, maximum) for a Level

func (*Rig) GetMode

func (rig *Rig) GetMode(vfo VFOType) (mode Mode, pb_width int, err error)

GetMode gets the Mode and Passband width for a VFO

func (*Rig) GetParm

func (rig *Rig) GetParm(vfo VFOType, parm uint32) (value float32, err error)

get Parameter

func (*Rig) GetParmGran

func (rig *Rig) GetParmGran(parm uint32) (step float32, min float32, max float32, err error)

Get granularity (stepsize, minimum, maximum) for a Parameter

func (*Rig) GetPbNarrow

func (rig *Rig) GetPbNarrow(mode Mode) (int, error)

Find the next suitable narrow available filter

func (*Rig) GetPbNormal

func (rig *Rig) GetPbNormal(mode Mode) (int, error)

Find the next suitable normal available filter

func (*Rig) GetPbWide

func (rig *Rig) GetPbWide(mode Mode) (int, error)

Find the next suitable wide available filter

func (*Rig) GetPowerState

func (rig *Rig) GetPowerState() (status Power, err error)

GetPowerStat gets the Rig Power On/Off/Standby state

func (*Rig) GetPtt

func (rig *Rig) GetPtt(vfo VFOType) (ptt int, err error)

Get Ptt state

func (*Rig) GetRigResolution

func (rig *Rig) GetRigResolution(mode Mode) (resolution int, err error)

get the best frequency resolution for this rig (minimum step size)

func (*Rig) GetRit

func (rig *Rig) GetRit(vfo VFOType) (offset int, err error)

Get Rit offset value

func (*Rig) GetSplit

func (rig *Rig) GetSplit(vfo VFOType) (split int, txVfo VFOType, err error)

Get Split (shortcut for GetSplitVfo)

func (*Rig) GetSplitFreq

func (rig *Rig) GetSplitFreq(vfo VFOType) (txFreq float64, err error)

Get Split Frequency

func (*Rig) GetSplitMode

func (rig *Rig) GetSplitMode(vfo VFOType) (txMode Mode, txWidth int, err error)

Get Split Mode

func (*Rig) GetSplitVfo

func (rig *Rig) GetSplitVfo(vfo VFOType) (split int, txVfo VFOType, err error)

Get Split Vfo

func (*Rig) GetTs

func (rig *Rig) GetTs(vfo VFOType) (ts int, err error)

Get Tuning step

func (*Rig) GetVfo

func (rig *Rig) GetVfo() (VFOType, error)

GetVfo returns the default VFO

func (*Rig) GetXit

func (rig *Rig) GetXit(vfo VFOType) (offset int, err error)

Get Xit offset value

func (*Rig) HasGetFunc

func (rig *Rig) HasGetFunc(function uint32) (res uint32, err error)

has supports getting a specific function

func (*Rig) HasGetLevel

func (rig *Rig) HasGetLevel(level uint32) (res uint32, err error)

has supports getting a specific level

func (*Rig) HasGetParm

func (rig *Rig) HasGetParm(parm uint32) (res uint32, err error)

has supports getting a specific parameter

func (*Rig) HasSetFunc

func (rig *Rig) HasSetFunc(function uint32) (res uint32, err error)

has supports setting a specific function

func (*Rig) HasSetLevel

func (rig *Rig) HasSetLevel(level uint32) (res uint32, err error)

has supports setting a specific level

func (*Rig) HasSetParm

func (rig *Rig) HasSetParm(parm uint32) (res uint32, err error)

has supports setting a specific parameter

func (*Rig) HasToken

func (rig *Rig) HasToken(token string) bool

HasToken checks if the rig supports a given token

func (*Rig) Init

func (rig *Rig) Init(rigModel RigModelID) error

Initialize Rig

func (*Rig) Open

func (rig *Rig) Open() error

Open Radio / Port

func (*Rig) SetAnt

func (rig *Rig) SetAnt(vfo VFOType, ant int) error

Set Antenna

func (*Rig) SetConf

func (rig *Rig) SetConf(token string, val string) error

Set configuration token

func (*Rig) SetFreq

func (rig *Rig) SetFreq(vfo VFOType, freq float64) error

SetFreq sets the Frequency for a VFO

func (*Rig) SetFunc

func (rig *Rig) SetFunc(vfo VFOType, function uint32, value bool) error

set Function

func (*Rig) SetLevel

func (rig *Rig) SetLevel(vfo VFOType, level uint32, value float32) error

set Level

func (*Rig) SetMode

func (rig *Rig) SetMode(vfo VFOType, mode Mode, pbWidth int) error

SetMode sets the Mode for a VFO

func (*Rig) SetParm

func (rig *Rig) SetParm(vfo VFOType, parm uint32, value float32) error

set Parameter

func (*Rig) SetPort

func (rig *Rig) SetPort(p Port) error

Set Port of Rig

func (*Rig) SetPowerState

func (rig *Rig) SetPowerState(status Power) error

SetPowerState sets the Rig Power On/Off/Standby state

func (*Rig) SetPtt

func (rig *Rig) SetPtt(vfo VFOType, ptt int) error

Set Ptt

func (*Rig) SetRit

func (rig *Rig) SetRit(vfo VFOType, offset int) error

Set Rit offset value

func (*Rig) SetSplitFreq

func (rig *Rig) SetSplitFreq(vfo VFOType, txFreq float64) error

Set Split Frequency

func (*Rig) SetSplitMode

func (rig *Rig) SetSplitMode(vfo VFOType, txMode Mode, txWidth int) error

Set Split Mode

func (*Rig) SetSplitVfo

func (rig *Rig) SetSplitVfo(vfo VFOType, split int, txVfo VFOType) error

Set Split Vfo

func (*Rig) SetTs

func (rig *Rig) SetTs(vfo VFOType, ts int) error

Set Tuning step

func (*Rig) SetVfo

func (rig *Rig) SetVfo(vfo VFOType) error

SetVfo sets the default VFO

func (*Rig) SetXit

func (rig *Rig) SetXit(vfo VFOType, offset int) error

Set Xit offset value

func (*Rig) VfoOp

func (rig *Rig) VfoOp(vfo VFOType, op VFOOp) error

Execute VFO Operation

type RigModel

type RigModel struct {
	Manufacturer string
	Model        string
	ModelID      RigModelID
}

RigModel is a supported rig in hamlib

func ListModels

func ListModels() []RigModel

ListModels enumerates all of the hamlib supported rigs

type RigModelID

type RigModelID int

RigModelID is a unique ID that identifies a particular rig driver

type RigPort

type RigPort byte

RigPortType is the port connection type for the rig

const (
	RigPortNone       RigPort = 0
	RigPortSerial     RigPort = 1
	RigPortNetwork    RigPort = 2
	RigPortDevice     RigPort = 3
	RigPortPacket     RigPort = 4
	RigPortDTMF       RigPort = 5
	RigPortUltra      RigPort = 6
	RigPortRPC        RigPort = 7
	RigPortParallel   RigPort = 8
	RigPortUSB        RigPort = 9
	RigPortUDPNetwork RigPort = 10
	RigPortCM108      RigPort = 11
)

Rig Port constants

type VFOOp

type VFOOp int

VFOOp is a VFO operation

const (
	VFOOpNone        VFOOp = 0
	VFOOpCopy        VFOOp = 1 << 0
	VFOOpExchange    VFOOp = 1 << 1
	VFOOpFromVFO     VFOOp = 1 << 2
	VFOOpToVFO       VFOOp = 1 << 3
	VFOOpMemoryClear VFOOp = 1 << 4
	VFOOpUp          VFOOp = 1 << 5
	VFOOpDown        VFOOp = 1 << 6
	VFOOpBandUp      VFOOp = 1 << 7
	VFOOpBandDown    VFOOp = 1 << 8
	VFOOpLeft        VFOOp = 1 << 9
	VFOOpRight       VFOOp = 1 << 10
	VFOOpTune        VFOOp = 1 << 11
	VFOOpToggle      VFOOp = 1 << 12
)

VFO Operation constants

type VFOType

type VFOType int

VFOType is used to specify a particular VFO

const (
	VFONone    VFOType = 0
	VFOCurrent VFOType = 1 << 29
	VFOMemory  VFOType = 1 << 28
	VFOLastVFO VFOType = 1 << 27
	//	VFOTX_VFO 			//TBD Macro
	VFOTX   VFOType = VFOCurrent | vfoTXFlag
	VFORX           = VFOCurrent
	VFOMain VFOType = 1 << 26
	VFOSub  VFOType = 1 << 25
	VFOA    VFOType = 1 << 0
	VFOB    VFOType = 1 << 1
	VFOC    VFOType = 1 << 2
)

Hamlib VFOs

type Value

type Value struct {
	Name string
	Step float32
	Min  float32
	Max  float32
}

type Values

type Values []Value

func (Values) Len

func (slice Values) Len() int

implement interface for Sorting Levels

func (Values) Less

func (slice Values) Less(i, j int) bool

implement interface for Sorting Levels

func (Values) Swap

func (slice Values) Swap(i, j int)

implement interface for Sorting Levels