/* * parse8k_aor_mode * don't care about aorwidth, * because there's no such BW command */ int parse8k_aor_mode(RIG *rig, char aormode, char aorwidth, rmode_t *mode, pbwidth_t *width) { *width = RIG_PASSBAND_NORMAL; switch (aormode) { case AR8K_AM: *mode = RIG_MODE_AM; break; case AR8K_NAM: *mode = RIG_MODE_AM; *width = rig_passband_narrow(rig, *mode); break; case AR8K_WAM: *mode = RIG_MODE_AM; *width = rig_passband_wide(rig, *mode); break; case AR8K_CW: *mode = RIG_MODE_CW; break; case AR8K_USB: *mode = RIG_MODE_USB; break; case AR8K_LSB: *mode = RIG_MODE_LSB; break; case AR8K_WFM: *mode = RIG_MODE_WFM; break; case AR8K_NFM: *mode = RIG_MODE_FM; break; case AR8K_SFM: *mode = RIG_MODE_FM; *width = rig_passband_narrow(rig, *mode); break; default: rig_debug(RIG_DEBUG_ERR,"%s: unsupported mode '%c'\n", __FUNCTION__, aormode); return -RIG_EINVAL; } if (*width == RIG_PASSBAND_NORMAL) *width = rig_passband_normal(rig, *mode); return RIG_OK; }
int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig) return -RIG_EINVAL; int err; char cmd_s[16]; switch (mode) { case RIG_MODE_PKTLSB: mode = RIG_MODE_RTTYR; strncpy(cmd_s, "DT0", 5); break; case RIG_MODE_PKTUSB: mode = RIG_MODE_RTTY; strncpy(cmd_s, "DT0", 5); break; case RIG_MODE_RTTY: case RIG_MODE_RTTYR: strncpy(cmd_s, "DT1", 5); break; default: break; } /* kenwood_set_mode() ignores width value for K2/K3/TS-570 */ err = kenwood_set_mode(rig, vfo, mode, width); if (err != RIG_OK) return err; /* Now set data sub-mode. K3 needs to be in a DATA mode before setting * the sub-mode. */ if (mode == RIG_MODE_PKTLSB || mode == RIG_MODE_PKTUSB || mode == RIG_MODE_RTTY || mode == RIG_MODE_RTTYR) { err = kenwood_simple_cmd(rig, cmd_s); if (err != RIG_OK) return err; } /* and set the requested bandwidth. On my K3, the bandwidth is rounded * down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth * to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values * between 0 and 4 round down to the nearest 100 Hz and values between 5 * and 9 round down to the nearest 50 Hz. * * width string value must be padded with leading '0' to equal four * characters. */ /* passband widths vary by mode so gather lower and upper limits */ pbwidth_t pb_nar = rig_passband_narrow(rig, mode); pbwidth_t pb_wid = rig_passband_wide(rig, mode); if (width < 0) width = labs(width); if (width == RIG_PASSBAND_NORMAL) width = rig_passband_normal(rig, mode); else if (width < pb_nar) width = pb_nar; else if (width > pb_wid) width = pb_wid; sprintf(cmd_s, "BW%04ld", width / 10); err = kenwood_simple_cmd(rig, cmd_s); if (err != RIG_OK) return err; return RIG_OK; }