Ejemplo n.º 1
0
func setFreq(rig hamlib.Rig, freq string) (newFreq, oldFreq int, err error) {
	oldFreq, err = rig.CurrentVFO().GetFreq()
	if err != nil {
		return 0, 0, fmt.Errorf("Unable to get rig frequency: %s", err)
	}

	f, err := strconv.ParseFloat(freq, 32)
	if err != nil {
		return 0, 0, err
	}

	newFreq = int(f * 1e3)
	err = rig.CurrentVFO().SetFreq(newFreq)
	return
}
Ejemplo n.º 2
0
func freq(param string) {
	parts := strings.SplitN(param, ":", 2)

	var rig hamlib.Rig
	var ok bool
	switch parts[0] {
	case MethodWinmor:
		rig, ok = rigs[config.Winmor.Rig]
	case MethodArdop:
		rig, ok = rigs[config.Ardop.Rig]
	case "":
		fmt.Println("Need freq method.")
		return
	default:
		fmt.Printf("'%s' not a supported freq method.\n", parts[0])
		return
	}

	if !ok {
		log.Printf("Hamlib rig not loaded.")
		return
	}

	if len(parts) < 2 {
		freq, err := rig.CurrentVFO().GetFreq()
		if err != nil {
			log.Printf("Unable to get frequency: %s", err)
		}
		fmt.Printf("%.3f\n", float64(freq)/1e3)
		return
	}

	if _, _, err := setFreq(rig, parts[1]); err != nil {
		log.Printf("Unable to set frequency: %s", err)
	}
}