diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c index fa2814a5c..a59939c34 100644 --- a/amplifiers/elecraft/kpa.c +++ b/amplifiers/elecraft/kpa.c @@ -68,7 +68,7 @@ int kpa_init(AMP *amp) } amp->state.priv = (struct kpa_priv_data *) - calloc(1,sizeof(struct kpa_priv_data)); + calloc(1, sizeof(struct kpa_priv_data)); if (!amp->state.priv) { diff --git a/amplifiers/gemini/gemini.c b/amplifiers/gemini/gemini.c index ef5638b79..b105cdcdc 100644 --- a/amplifiers/gemini/gemini.c +++ b/amplifiers/gemini/gemini.c @@ -44,7 +44,7 @@ int gemini_init(AMP *amp) } amp->state.priv = (struct gemini_priv_data *) - calloc(1,sizeof(struct gemini_priv_data)); + calloc(1, sizeof(struct gemini_priv_data)); if (!amp->state.priv) { @@ -207,20 +207,23 @@ int gemini_set_freq(AMP *amp, freq_t freq) char *cmd; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (freq < 1.0) cmd = "B472KHZ\n"; - else if (freq < 2.0) cmd = "B1.8MHZ\n"; - else if (freq < 4.0) cmd = "B3.5MHZ\n"; - else if (freq < 6.0) cmd = "B50MHZ\n"; - else if (freq < 9.0) cmd = "B70MHZ\n"; - else if (freq < 12.0) cmd = "B10MHZ\n"; - else if (freq < 16.0) cmd = "B14MHZ\n"; - else if (freq < 19.0) cmd = "B18MHZ\n"; - else if (freq < 22.0) cmd = "B21MHZ\n"; - else if (freq < 26.0) cmd = "B24MHZ\n"; - else cmd = "B50MHZ\n"; + + if (freq < 1.0) { cmd = "B472KHZ\n"; } + else if (freq < 2.0) { cmd = "B1.8MHZ\n"; } + else if (freq < 4.0) { cmd = "B3.5MHZ\n"; } + else if (freq < 6.0) { cmd = "B50MHZ\n"; } + else if (freq < 9.0) { cmd = "B70MHZ\n"; } + else if (freq < 12.0) { cmd = "B10MHZ\n"; } + else if (freq < 16.0) { cmd = "B14MHZ\n"; } + else if (freq < 19.0) { cmd = "B18MHZ\n"; } + else if (freq < 22.0) { cmd = "B21MHZ\n"; } + else if (freq < 26.0) { cmd = "B24MHZ\n"; } + else { cmd = "B50MHZ\n"; } + retval = gemini_transaction(amp, cmd, NULL, 0); if (retval != RIG_OK) { return retval; } + return RIG_OK; } diff --git a/android/ltdl.c b/android/ltdl.c index c73dd5591..be24c0aab 100644 --- a/android/ltdl.c +++ b/android/ltdl.c @@ -62,7 +62,7 @@ char *getlibpath(void) if (!c) { continue; } - libpath = calloc(1,strlen(c) + 1); + libpath = calloc(1, strlen(c) + 1); strcpy(libpath, c); break; } @@ -115,7 +115,7 @@ lt_dlhandle adlopen(const char *filename) if (libpath == NULL || filename == NULL) { return NULL; } - c = calloc(1,strlen(libpath) + strlen(APREFIX) + strlen(filename) + strlen( + c = calloc(1, strlen(libpath) + strlen(APREFIX) + strlen(filename) + strlen( ASUFFIX) + 1); strcpy(c, libpath); strcat(c, APREFIX); diff --git a/lib/cJSON.c b/lib/cJSON.c index a420d993b..4df0485e3 100644 --- a/lib/cJSON.c +++ b/lib/cJSON.c @@ -168,7 +168,7 @@ typedef struct internal_hooks /* work around MSVC error C2322: '...' address of dllimport '...' is not static */ static void *CJSON_CDECL internal_malloc(size_t size) { - return calloc(1,size); + return calloc(1, size); } static void CJSON_CDECL internal_free(void *pointer) { diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 99efab3d4..723ced002 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -96,7 +96,7 @@ int getaddrinfo(const char *node, const char *service, return -1; } - p = calloc(1,sizeof(struct addrinfo)); + p = calloc(1, sizeof(struct addrinfo)); if (!p) { @@ -108,7 +108,7 @@ int getaddrinfo(const char *node, const char *service, p->ai_socktype = ai_socktype; p->ai_protocol = ai_protocol; p->ai_addrlen = sizeof(struct sockaddr_in); - p->ai_addr = calloc(1,p->ai_addrlen); + p->ai_addr = calloc(1, p->ai_addrlen); if (!p->ai_addr) { diff --git a/lib/getopt.c b/lib/getopt.c index ecef3bcb1..28adf28bd 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -223,7 +223,7 @@ exchange(argv) char **argv; { int nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *); - char **temp = (char **) calloc(1,nonopts_size); + char **temp = (char **) calloc(1, nonopts_size); /* Interchange the two blocks of data in ARGV. */ diff --git a/lib/termios.c b/lib/termios.c index cdaa32613..0b9088e7f 100644 --- a/lib/termios.c +++ b/lib/termios.c @@ -1208,7 +1208,7 @@ static struct termios_list *add_port(const char *filename) ENTER("add_port"); - port = calloc(1,sizeof(struct termios_list)); + port = calloc(1, sizeof(struct termios_list)); if (!port) { @@ -1217,7 +1217,7 @@ static struct termios_list *add_port(const char *filename) memset(port, 0, sizeof(struct termios_list)); - port->ttyset = calloc(1,sizeof(struct termios)); + port->ttyset = calloc(1, sizeof(struct termios)); if (! port->ttyset) { @@ -1226,7 +1226,7 @@ static struct termios_list *add_port(const char *filename) memset(port->ttyset, 0, sizeof(struct termios)); - port->sstruct = calloc(1,sizeof(struct serial_struct)); + port->sstruct = calloc(1, sizeof(struct serial_struct)); if (! port->sstruct) { @@ -1234,7 +1234,7 @@ static struct termios_list *add_port(const char *filename) } memset(port->sstruct, 0, sizeof(struct serial_struct)); - port->sis = calloc(1,sizeof(struct serial_icounter_struct)); + port->sis = calloc(1, sizeof(struct serial_icounter_struct)); if (! port->sis) { @@ -3407,7 +3407,7 @@ int win32_serial_ioctl(int fd, int request, ...) case TIOCGSERIAL: report("TIOCGSERIAL\n"); - dcb = calloc(1,sizeof(DCB)); + dcb = calloc(1, sizeof(DCB)); if (!dcb) { @@ -3438,7 +3438,7 @@ int win32_serial_ioctl(int fd, int request, ...) case TIOCSSERIAL: report("TIOCSSERIAL\n"); - dcb = calloc(1,sizeof(DCB)); + dcb = calloc(1, sizeof(DCB)); if (!dcb) { diff --git a/rigs/aor/ar3030.c b/rigs/aor/ar3030.c index d5ed256c5..7d34e6464 100644 --- a/rigs/aor/ar3030.c +++ b/rigs/aor/ar3030.c @@ -282,7 +282,7 @@ int ar3030_init(RIG *rig) { struct ar3030_priv_data *priv; - rig->state.priv = calloc(1,sizeof(struct ar3030_priv_data)); + rig->state.priv = calloc(1, sizeof(struct ar3030_priv_data)); if (!rig->state.priv) { diff --git a/rigs/aor/ar7030p.c b/rigs/aor/ar7030p.c index 6bc8669e9..aececedd9 100644 --- a/rigs/aor/ar7030p.c +++ b/rigs/aor/ar7030p.c @@ -257,7 +257,7 @@ static int ar7030p_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); priv = (struct ar7030p_priv_data *) - calloc(1,sizeof(struct ar7030p_priv_data)); + calloc(1, sizeof(struct ar7030p_priv_data)); if (!priv) { diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index f2f93ce6c..e1f10203d 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -102,7 +102,7 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int drake_init(RIG *rig) { struct drake_priv_data *priv; - rig->state.priv = calloc(1,sizeof(struct drake_priv_data)); + rig->state.priv = calloc(1, sizeof(struct drake_priv_data)); if (!rig->state.priv) { diff --git a/rigs/dummy/amp_dummy.c b/rigs/dummy/amp_dummy.c index ba5a138ab..a12b9649e 100644 --- a/rigs/dummy/amp_dummy.c +++ b/rigs/dummy/amp_dummy.c @@ -56,7 +56,7 @@ static int dummy_amp_init(AMP *amp) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); amp->state.priv = (struct dummy_amp_priv_data *) - calloc(1,sizeof(struct dummy_amp_priv_data)); + calloc(1, sizeof(struct dummy_amp_priv_data)); if (!amp->state.priv) { diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index 446818112..1f6fca1b8 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -222,7 +222,7 @@ static int dummy_init(RIG *rig) int i; ENTERFUNC; - priv = (struct dummy_priv_data *)calloc(1,sizeof(struct dummy_priv_data)); + priv = (struct dummy_priv_data *)calloc(1, sizeof(struct dummy_priv_data)); if (!priv) { diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index c26ba539c..c7515a8bd 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -613,7 +613,7 @@ static int flrig_init(RIG *rig) ENTERFUNC; rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, rig->caps->version); - rig->state.priv = (struct flrig_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct flrig_priv_data *)calloc(1, sizeof( struct flrig_priv_data)); if (!rig->state.priv) diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index 0baa4d5cb..c259b401a 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -168,7 +168,7 @@ static int netrigctl_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct netrigctl_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct netrigctl_priv_data *)calloc(1, sizeof( struct netrigctl_priv_data)); if (!rig->state.priv) @@ -296,7 +296,7 @@ static int netrigctl_open(RIG *rig) if (ret <= 0) { - RETURNFUNC( (ret < 0) ? ret : -RIG_EPROTO); + RETURNFUNC((ret < 0) ? ret : -RIG_EPROTO); } prot_ver = atoi(buf); @@ -304,7 +304,7 @@ static int netrigctl_open(RIG *rig) if (prot_ver < RIGCTLD_PROT_VER) { - RETURNFUNC( -RIG_EPROTO); + RETURNFUNC(-RIG_EPROTO); } ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1, @@ -2387,7 +2387,7 @@ static int netrigctl_send_dtmf(RIG *rig, vfo_t vfo, const char *digits) // allocate memory for size of (cmd + digits + \n + \0) len = strlen(cmd) + strlen(digits) + 2; - cmdp = calloc(1,len); + cmdp = calloc(1, len); if (cmdp == NULL) { @@ -2470,7 +2470,7 @@ static int netrigctl_send_morse(RIG *rig, vfo_t vfo, const char *msg) // allocate memory for size of (cmd + msg + \n + \0) len = strlen(cmd) + strlen(msg) + 2; - cmdp = calloc(1,len); + cmdp = calloc(1, len); if (cmdp == NULL) { @@ -2656,6 +2656,7 @@ int netrigctl_set_lock_mode(RIG *rig, int lock) { return -RIG_EPROTO; } + return (RIG_OK); } @@ -2666,11 +2667,13 @@ int netrigctl_get_lock_mode(RIG *rig, int *lock) int ret; SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\get_lock_mode\n"); ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf); + if (ret == 0) { return -RIG_EPROTO; } - sscanf(buf,"%d", lock); + + sscanf(buf, "%d", lock); return (RIG_OK); } diff --git a/rigs/dummy/rot_dummy.c b/rigs/dummy/rot_dummy.c index 56a156997..514d7c19f 100644 --- a/rigs/dummy/rot_dummy.c +++ b/rigs/dummy/rot_dummy.c @@ -121,7 +121,7 @@ static int dummy_rot_init(ROT *rot) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rot->state.priv = (struct dummy_rot_priv_data *) - calloc(1,sizeof(struct dummy_rot_priv_data)); + calloc(1, sizeof(struct dummy_rot_priv_data)); if (!rot->state.priv) { diff --git a/rigs/dummy/tci1x.c b/rigs/dummy/tci1x.c index 0d39d636e..68b11d53d 100644 --- a/rigs/dummy/tci1x.c +++ b/rigs/dummy/tci1x.c @@ -424,7 +424,7 @@ static int tci1x_init(RIG *rig) ENTERFUNC; rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, rig->caps->version); - rig->state.priv = (struct tci1x_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct tci1x_priv_data *)calloc(1, sizeof( struct tci1x_priv_data)); if (!rig->state.priv) diff --git a/rigs/dummy/trxmanager.c b/rigs/dummy/trxmanager.c index 70558051f..72a7ded17 100644 --- a/rigs/dummy/trxmanager.c +++ b/rigs/dummy/trxmanager.c @@ -263,7 +263,7 @@ static int trxmanager_init(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER); rig->state.priv = (struct trxmanager_priv_data *)calloc(1, - sizeof(struct trxmanager_priv_data)); + sizeof(struct trxmanager_priv_data)); if (!rig->state.priv) { diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c index fb33e7253..5c6fa5158 100644 --- a/rigs/elad/elad.c +++ b/rigs/elad/elad.c @@ -203,7 +203,7 @@ transaction_write: len = strlen(cmdstr); - cmd = calloc(1,len + 2); + cmd = calloc(1, len + 2); if (cmd == NULL) { @@ -515,7 +515,7 @@ int elad_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = calloc(1,sizeof(struct elad_priv_data)); + rig->state.priv = calloc(1, sizeof(struct elad_priv_data)); if (rig->state.priv == NULL) { @@ -917,9 +917,12 @@ int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) if (split == tsplit) { - rig_debug(RIG_DEBUG_TRACE, "%s: No change detected...ignoring request\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: No change detected...ignoring request\n", + __func__); } - rig_debug(RIG_DEBUG_TRACE, "%s: Change detected requested split %d!=%d\n", __func__, split, tsplit); + + rig_debug(RIG_DEBUG_TRACE, "%s: Change detected requested split %d!=%d\n", + __func__, split, tsplit); if (split) { diff --git a/rigs/flexradio/sdr1k.c b/rigs/flexradio/sdr1k.c index 5e5da5341..3c3022739 100644 --- a/rigs/flexradio/sdr1k.c +++ b/rigs/flexradio/sdr1k.c @@ -195,7 +195,7 @@ int sdr1k_init(RIG *rig) { struct sdr1k_priv_data *priv; - rig->state.priv = (struct sdr1k_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct sdr1k_priv_data *)calloc(1, sizeof( struct sdr1k_priv_data)); if (!rig->state.priv) diff --git a/rigs/gomspace/gs100.c b/rigs/gomspace/gs100.c index 191bfd9c9..9e8ed8882 100644 --- a/rigs/gomspace/gs100.c +++ b/rigs/gomspace/gs100.c @@ -114,7 +114,7 @@ static int gs100_init(RIG *rig) RETURNFUNC(-RIG_EINVAL); } - priv = (struct gs100_priv_data *)calloc(1,sizeof(struct gs100_priv_data)); + priv = (struct gs100_priv_data *)calloc(1, sizeof(struct gs100_priv_data)); if (!priv) { diff --git a/rigs/icmarine/icmarine.c b/rigs/icmarine/icmarine.c index 59dada123..bc2748087 100644 --- a/rigs/icmarine/icmarine.c +++ b/rigs/icmarine/icmarine.c @@ -132,7 +132,7 @@ int icmarine_init(RIG *rig) priv_caps = (const struct icmarine_priv_caps *) caps->priv; - rig->state.priv = (struct icmarine_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct icmarine_priv_data *)calloc(1, sizeof( struct icmarine_priv_data)); if (!rig->state.priv) diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index 485797b22..e871f6ff2 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -588,22 +588,26 @@ int rig2icom_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width, case RIG_MODE_USB: icmode = S_USB; break; - case RIG_MODE_PKTUSB: - icmode = S_USB; + case RIG_MODE_PKTUSB: + icmode = S_USB; + if (rig->caps->rig_model == RIG_MODEL_IC7800) { icmode = S_PSK; } + break; case RIG_MODE_LSB: icmode = S_LSB; break; - case RIG_MODE_PKTLSB: + case RIG_MODE_PKTLSB: icmode = S_LSB; + if (rig->caps->rig_model == RIG_MODEL_IC7800) { icmode = S_PSKR; } + break; case RIG_MODE_RTTY: icmode = S_RTTY; break; @@ -746,20 +750,24 @@ void icom2rig_mode(RIG *rig, unsigned char md, int pd, rmode_t *mode, case S_RTTYR: *mode = RIG_MODE_RTTYR; break; case S_PSK: - *mode = RIG_MODE_PSK; - if (rig->caps->rig_model == RIG_MODEL_IC7800) - { - *mode = RIG_MODE_PKTUSB; - } - break; + *mode = RIG_MODE_PSK; + + if (rig->caps->rig_model == RIG_MODEL_IC7800) + { + *mode = RIG_MODE_PKTUSB; + } + + break; case S_PSKR: - *mode = RIG_MODE_PSKR; - if (rig->caps->rig_model == RIG_MODEL_IC7800) - { - *mode = RIG_MODE_PKTLSB; - } - break; + *mode = RIG_MODE_PSKR; + + if (rig->caps->rig_model == RIG_MODEL_IC7800) + { + *mode = RIG_MODE_PKTLSB; + } + + break; case S_DSTAR: *mode = RIG_MODE_DSTAR; break; diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 28b2c4ad2..fdb1c6572 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -932,9 +932,11 @@ static void icom_satmode_fix(RIG *rig, int satmode) { if (rig->caps->rig_model == RIG_MODEL_IC9700) { - rig_debug(RIG_DEBUG_VERBOSE, "%s: toggling IC9700 targetable for satmode=%d\n", __func__, satmode); - if (satmode) rig->caps->targetable_vfo = 0; - else rig->caps->targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE; + rig_debug(RIG_DEBUG_VERBOSE, "%s: toggling IC9700 targetable for satmode=%d\n", + __func__, satmode); + + if (satmode) { rig->caps->targetable_vfo = 0; } + else { rig->caps->targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE; } } } @@ -2675,7 +2677,7 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } } - if (*mode == RIG_MODE_FM) *width = 12000; + if (*mode == RIG_MODE_FM) { *width = 12000; } RETURNFUNC2(RIG_OK); } @@ -5270,7 +5272,7 @@ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) { // satmode defaults to 0 -- only call if we need to rig_get_func((RIG *)rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); - icom_satmode_fix(rig,satmode); + icom_satmode_fix(rig, satmode); } rig->state.cache.satmode = satmode; @@ -5376,7 +5378,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) if (rig->caps->has_get_func & RIG_FUNC_SATMODE) { rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); - icom_satmode_fix(rig,satmode); + icom_satmode_fix(rig, satmode); } rig->state.cache.satmode = satmode; @@ -5606,7 +5608,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) if (rig->caps->has_get_func & RIG_FUNC_SATMODE) { rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); - icom_satmode_fix(rig,satmode); + icom_satmode_fix(rig, satmode); } rig->state.cache.satmode = satmode; @@ -5619,8 +5621,9 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) int retry_save = rs->rigport.retry; rs->rigport.retry = 0; cmd = C_SEND_SEL_FREQ; - // when transmitting in split mode the split VFO is active - subcmd = (rig->state.cache.split && rig->state.cache.ptt)? 0x00 : 0x01; // get the unselected vfo + // when transmitting in split mode the split VFO is active + subcmd = (rig->state.cache.split + && rig->state.cache.ptt) ? 0x00 : 0x01; // get the unselected vfo retval = icom_transaction(rig, cmd, subcmd, NULL, 0, ackbuf, &ack_len); @@ -6320,7 +6323,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) "%s: VFO_SUB and satmode is off so turning satmode on\n", __func__); rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, 1); - icom_satmode_fix(rig,1); + icom_satmode_fix(rig, 1); rig->state.cache.satmode = 1; priv->tx_vfo = RIG_VFO_SUB; } @@ -6331,7 +6334,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) "%s: VFO_B and satmode is on so turning satmode off\n", __func__); rig_set_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, 0); - icom_satmode_fix(rig,0); + icom_satmode_fix(rig, 0); rig->state.cache.satmode = 0; priv->tx_vfo = RIG_VFO_B; } @@ -6597,7 +6600,7 @@ int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) if (rig->caps->has_get_func & RIG_FUNC_SATMODE) { rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); - icom_satmode_fix(rig,satmode); + icom_satmode_fix(rig, satmode); if (satmode != rig->state.cache.satmode) { @@ -7008,7 +7011,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) status; // we reset this to current status -- fails in SATMODE priv->x1cx03cmdfails = 0; // we reset this to try it again rig->state.cache.satmode = status; - icom_satmode_fix(rig,status); + icom_satmode_fix(rig, status); break; diff --git a/rigs/icom/optoscan.c b/rigs/icom/optoscan.c index d49ad0178..b2f94a556 100644 --- a/rigs/icom/optoscan.c +++ b/rigs/icom/optoscan.c @@ -70,7 +70,7 @@ int optoscan_open(RIG *rig) rs = &rig->state; priv = (struct icom_priv_data *)rs->priv; - pltstate = calloc(1,sizeof(pltstate_t)); + pltstate = calloc(1, sizeof(pltstate_t)); if (!pltstate) { diff --git a/rigs/jrc/jst145.c b/rigs/jrc/jst145.c index c0c801efb..92d24a808 100644 --- a/rigs/jrc/jst145.c +++ b/rigs/jrc/jst145.c @@ -281,7 +281,7 @@ const struct rig_caps jst245_caps = static int jst145_init(RIG *rig) { struct jst145_priv_data *priv; - priv = (struct jst145_priv_data *)calloc(1,sizeof(struct jst145_priv_data)); + priv = (struct jst145_priv_data *)calloc(1, sizeof(struct jst145_priv_data)); if (!priv) { diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 65709a1fc..12116f9e8 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -298,7 +298,7 @@ transaction_write: len = strlen(cmdstr); - cmd = calloc(1,len + 2); + cmd = calloc(1, len + 2); if (cmd == NULL) { @@ -489,7 +489,8 @@ transaction_read: if (retry_read++ < rs->rigport.retry) { - rig_debug(RIG_DEBUG_ERR, "%s: Retrying shortly %d of %d\n", __func__, retry_read, rs->rigport.retry); + rig_debug(RIG_DEBUG_ERR, "%s: Retrying shortly %d of %d\n", __func__, + retry_read, rs->rigport.retry); hl_usleep(rig->caps->timeout * 1000); goto transaction_write; } @@ -724,7 +725,7 @@ int kenwood_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called, version %s/%s\n", __func__, BACKEND_VER, rig->caps->version); - rig->state.priv = calloc(1,sizeof(struct kenwood_priv_data)); + rig->state.priv = calloc(1, sizeof(struct kenwood_priv_data)); if (rig->state.priv == NULL) { @@ -1101,7 +1102,9 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) struct kenwood_priv_data *priv = rig->state.priv; ENTERFUNC; - rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, is_emulation=%d, curr_mode=%s\n", __func__, rig_strvfo(vfo), priv->is_emulation, rig_strrmode(priv->curr_mode)); + rig_debug(RIG_DEBUG_VERBOSE, + "%s called vfo=%s, is_emulation=%d, curr_mode=%s\n", __func__, rig_strvfo(vfo), + priv->is_emulation, rig_strrmode(priv->curr_mode)); /* Emulations do not need to set VFO since VFOB is a copy of VFOA @@ -1116,12 +1119,14 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) } #if 0 + if (rig->state.current_vfo == vfo) { rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo already is %s...skipping\n", __func__, rig_strvfo(vfo)); RETURNFUNC2(RIG_OK); } + #endif switch (vfo) @@ -1631,12 +1636,14 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, if (rig->state.rx_vfo == RIG_VFO_A) { HAMLIB_TRACE; - *txvfo = rig->state.tx_vfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + *txvfo = rig->state.tx_vfo = priv->tx_vfo = (*split + && !transmitting) ? RIG_VFO_B : RIG_VFO_A; } else if (rig->state.rx_vfo == RIG_VFO_B) { HAMLIB_TRACE; - *txvfo = rig->state.tx_vfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + *txvfo = rig->state.tx_vfo = priv->tx_vfo = (*split + && !transmitting) ? RIG_VFO_B : RIG_VFO_A; } else { @@ -1958,6 +1965,7 @@ int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo)); RETURNFUNC(-RIG_EINVAL); } + if (rig->caps->rig_model == RIG_MODEL_MALACHITE && vfo == RIG_VFO_B) { // Malachite does not have VFOB so we'll just return VFOA @@ -2875,14 +2883,16 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min, expected_length = 18; } - retval = read_string(&rs->rigport, (unsigned char *) levelbuf, expected_length + 1, - NULL, 0, 0, 1); + retval = read_string(&rs->rigport, (unsigned char *) levelbuf, + expected_length + 1, + NULL, 0, 0, 1); rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval); if (retval != expected_length) { - rig_debug(RIG_DEBUG_ERR, "%s: expected %d, got %d in '%s'\n", __func__, expected_length, + rig_debug(RIG_DEBUG_ERR, "%s: expected %d, got %d in '%s'\n", __func__, + expected_length, retval, levelbuf); RETURNFUNC(-RIG_EPROTO); diff --git a/rigs/kenwood/tmd710.c b/rigs/kenwood/tmd710.c index 35f5dae34..e2bca1f0c 100644 --- a/rigs/kenwood/tmd710.c +++ b/rigs/kenwood/tmd710.c @@ -56,10 +56,12 @@ static int tmd710_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int tmd710_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int tmd710_get_split_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int tmd710_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq); -static int tmd710_set_vfo (RIG *rig, vfo_t vfo); +static int tmd710_set_vfo(RIG *rig, vfo_t vfo); static int tmd710_get_vfo(RIG *rig, vfo_t *vfo); -static int tmd710_set_split_vfo (RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo); -static int tmd710_get_split_vfo (RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo); +static int tmd710_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t txvfo); +static int tmd710_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *txvfo); static int tmd710_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts); static int tmd710_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts); static int tmd710_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); @@ -67,17 +69,19 @@ static int tmd710_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone); static int tmd710_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone); static int tmd710_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone); static int tmd710_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int tmd710_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int tmd710_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); static int tmd710_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift); -static int tmd710_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t* shift); +static int tmd710_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift); static int tmd710_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offset); -static int tmd710_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t* offset); +static int tmd710_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *offset); static int tmd710_get_mem(RIG *rig, vfo_t vfo, int *ch); static int tmd710_set_mem(RIG *rig, vfo_t vfo, int ch); -static int tmd710_set_dcs_sql(RIG * rig, vfo_t vfo, tone_t code); -static int tmd710_get_dcs_sql(RIG * rig, vfo_t vfo, tone_t *code); +static int tmd710_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code); +static int tmd710_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code); static int tmd710_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan); -static int tmd710_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only); +static int tmd710_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, + int read_only); static int tmd710_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int tmd710_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); static int tmd710_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); @@ -87,8 +91,10 @@ static int tmd710_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); static int tmd710_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); static int tmd710_get_parm(RIG *rig, setting_t parm, value_t *val); static int tmd710_set_parm(RIG *rig, setting_t parm, value_t val); -static int tmd710_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val); -static int tmd710_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val); +static int tmd710_get_ext_level(RIG *rig, vfo_t vfo, token_t token, + value_t *val); +static int tmd710_set_ext_level(RIG *rig, vfo_t vfo, token_t token, + value_t val); #define TMD710_MODES (RIG_MODE_FM|RIG_MODE_FMN|RIG_MODE_AM) #define TMD710_MODES_FM (RIG_MODE_FM|RIG_MODE_FMN) @@ -221,13 +227,15 @@ static int tmd710_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) #define TMD710_SQC_SOURCE_BUSY_OR_TX 4 #define TMD710_SQC_SOURCE_SQL_OR_TX 5 -static rmode_t tmd710_mode_table[KENWOOD_MODE_TABLE_MAX] = { +static rmode_t tmd710_mode_table[KENWOOD_MODE_TABLE_MAX] = +{ [0] = RIG_MODE_FM, [1] = RIG_MODE_FMN, [2] = RIG_MODE_AM, }; -static struct kenwood_priv_caps tmd710_priv_caps = { +static struct kenwood_priv_caps tmd710_priv_caps = +{ .cmdtrm = EOM_TH, /* Command termination character */ .mode_table = tmd710_mode_table, }; @@ -237,14 +245,17 @@ static struct kenwood_priv_caps tmd710_priv_caps = { * Token definitions for .cfgparams in rig_caps * See enum rig_conf_e and struct confparams in rig.h */ -const struct confparams tmd710_ext_levels[] = { - { TOK_LEVEL_EXT_DATA_BAND, "EXTDATABAND", "External data band", "External data band", +const struct confparams tmd710_ext_levels[] = +{ + { + TOK_LEVEL_EXT_DATA_BAND, "EXTDATABAND", "External data band", "External data band", NULL, RIG_CONF_COMBO, { .c = { .combostr = { "A", "B", "TXA-RXB", "TXB-RXA", NULL } } } }, { RIG_CONF_END, NULL, } }; -const struct rig_caps tmd710_caps = { +const struct rig_caps tmd710_caps = +{ .rig_model = RIG_MODEL_TMD710, .model_name = "TM-D710(G)", .mfg_name = "Kenwood", @@ -344,11 +355,11 @@ const struct rig_caps tmd710_caps = { {RIG_MODE_AM, kHz(4)}, RIG_FLT_END, }, - .priv = (void *) &tmd710_priv_caps, + .priv = (void *)& tmd710_priv_caps, .rig_init = kenwood_init, .rig_open = tmd710_open, - .rig_cleanup = kenwood_cleanup, + .rig_cleanup = kenwood_cleanup, .set_freq = tmd710_set_freq, .get_freq = tmd710_get_freq, .set_split_freq = tmd710_set_split_freq, @@ -554,222 +565,263 @@ const struct rig_caps tmv71_caps = }; /* structure for handling FO radio command */ -typedef struct { - int vfo; // P1 - freq_t freq; // P2 - int step; // P3 - int shift; // P4 - int reverse; // P5 - int tone; // P6 - int ct; // P7 - int dcs; // P8 - int tone_freq; // P9 - int ct_freq; // P10 - int dcs_val; // P11 - int offset; // P12 - int mode; // P13 +typedef struct +{ + int vfo; // P1 + freq_t freq; // P2 + int step; // P3 + int shift; // P4 + int reverse; // P5 + int tone; // P6 + int ct; // P7 + int dcs; // P8 + int tone_freq; // P9 + int ct_freq; // P10 + int dcs_val; // P11 + int offset; // P12 + int mode; // P13 } tmd710_fo; /* structure for handling ME radio command */ -typedef struct { - int channel; // P1 - freq_t freq; // P2 - int step; // P3 - int shift; // P4 - int reverse; // P5 - int tone; // P6 - int ct; // P7 - int dcs; // P8 - int tone_freq; // P9 - int ct_freq; // P10 - int dcs_val; // P11 - int offset; // P12 - int mode; // P13 - freq_t tx_freq; // P14 - int p15_unknown; // P15 - int lockout; // P16 +typedef struct +{ + int channel; // P1 + freq_t freq; // P2 + int step; // P3 + int shift; // P4 + int reverse; // P5 + int tone; // P6 + int ct; // P7 + int dcs; // P8 + int tone_freq; // P9 + int ct_freq; // P10 + int dcs_val; // P11 + int offset; // P12 + int mode; // P13 + freq_t tx_freq; // P14 + int p15_unknown; // P15 + int lockout; // P16 } tmd710_me; /* structure for handling MU (menu) radio command */ -typedef struct { - int beep; // P1 0/1 - int beep_volume; // P2 (1-7) - int ext_speaker_mode; // P3 - int announce; // P4 - int language; // P5 - int voice_volume; // P6 (0-7) - int voice_speed; // P7 (0-4) - int playback_repeat; // P8 0/1 - int playback_repeat_interval; // P9 (00-60) - int continuous_recording; // P10 0/1 - int vhf_aip; // P11 0/1 - int uhf_aip; // P12 0/1 - int smeter_sql_hang_up_time; // P13 - int mute_hang_up_time; // P14 - int beat_shift; // P15 0/1 - int timeout_timer; // P16 - int recall_method; // P17 - int echolink_speed; // P18 - int dtmf_hold; // P19 0/1 - int dtmf_speed; // P20 - int dtmf_pause; // P21 - int dtmf_key_lock; // P22 0/1 - int auto_repeater_offset; // P23 0/1 - int tone_1750_tx_hold; // P24 0/1 - int p25_unknown; // TODO - int brightness_level; // P26 (0-8) - int auto_brightness; // P27 0/1 - int backlight_color; // P28 - int pf1_key; // P29 - int pf2_key; // P30 - int mic_pf1_key; // P31 - int mic_pf2_key; // P32 - int mic_pf3_key; // P33 - int mic_pf4_key; // P34 - int mic_key_lock; // P35 0/1 - int scan_resume; // P36 - int auto_power_off; // P37 - int ext_data_band; // P38 - int ext_data_speed; // P39 - int sqc_source; // P40 - int auto_pm_store; // P41 0/1 - int display_partition_bar; // P42 0/1 +typedef struct +{ + int beep; // P1 0/1 + int beep_volume; // P2 (1-7) + int ext_speaker_mode; // P3 + int announce; // P4 + int language; // P5 + int voice_volume; // P6 (0-7) + int voice_speed; // P7 (0-4) + int playback_repeat; // P8 0/1 + int playback_repeat_interval; // P9 (00-60) + int continuous_recording; // P10 0/1 + int vhf_aip; // P11 0/1 + int uhf_aip; // P12 0/1 + int smeter_sql_hang_up_time; // P13 + int mute_hang_up_time; // P14 + int beat_shift; // P15 0/1 + int timeout_timer; // P16 + int recall_method; // P17 + int echolink_speed; // P18 + int dtmf_hold; // P19 0/1 + int dtmf_speed; // P20 + int dtmf_pause; // P21 + int dtmf_key_lock; // P22 0/1 + int auto_repeater_offset; // P23 0/1 + int tone_1750_tx_hold; // P24 0/1 + int p25_unknown; // TODO + int brightness_level; // P26 (0-8) + int auto_brightness; // P27 0/1 + int backlight_color; // P28 + int pf1_key; // P29 + int pf2_key; // P30 + int mic_pf1_key; // P31 + int mic_pf2_key; // P32 + int mic_pf3_key; // P33 + int mic_pf4_key; // P34 + int mic_key_lock; // P35 0/1 + int scan_resume; // P36 + int auto_power_off; // P37 + int ext_data_band; // P38 + int ext_data_speed; // P39 + int sqc_source; // P40 + int auto_pm_store; // P41 0/1 + int display_partition_bar; // P42 0/1 } tmd710_mu; -static int tmd710_open(RIG *rig) { - - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); +static int tmd710_open(RIG *rig) +{ - rig->state.tx_vfo = RIG_VFO_A; - rig_debug(RIG_DEBUG_TRACE, "RIG_VFO_A: %d\trig->state.tx_vfo: %d\n", RIG_VFO_A, rig->state.tx_vfo); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + + rig->state.tx_vfo = RIG_VFO_A; + rig_debug(RIG_DEBUG_TRACE, "RIG_VFO_A: %d\trig->state.tx_vfo: %d\n", RIG_VFO_A, + rig->state.tx_vfo); - return 0; + return 0; } -static int tmd710_get_vfo_num(RIG *rig, int *vfonum, vfo_t *vfo) { - char buf[10]; - int retval, ctrlnum, pttnum; +static int tmd710_get_vfo_num(RIG *rig, int *vfonum, vfo_t *vfo) +{ + char buf[10]; + int retval, ctrlnum, pttnum; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = kenwood_transaction(rig, "BC", buf, sizeof(buf)); - if (retval != RIG_OK) { - return retval; - } + retval = kenwood_transaction(rig, "BC", buf, sizeof(buf)); - retval = sscanf(buf, "BC %d,%d", &ctrlnum, &pttnum); - if (retval != 2) { - rig_debug(RIG_DEBUG_ERR, "Unable to parse '%s', expected 'BC c,p'\n", buf); - return -RIG_EPROTO; - } + if (retval != RIG_OK) + { + return retval; + } - switch (ctrlnum) { + retval = sscanf(buf, "BC %d,%d", &ctrlnum, &pttnum); + + if (retval != 2) + { + rig_debug(RIG_DEBUG_ERR, "Unable to parse '%s', expected 'BC c,p'\n", buf); + return -RIG_EPROTO; + } + + switch (ctrlnum) + { case TMD710_BAND_A: - if (vfo != NULL) { - *vfo = RIG_VFO_A; - } - break; + if (vfo != NULL) + { + *vfo = RIG_VFO_A; + } + + break; + case TMD710_BAND_B: - if (vfo != NULL) { - *vfo = RIG_VFO_B; - } - break; + if (vfo != NULL) + { + *vfo = RIG_VFO_B; + } + + break; + default: - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected VFO value '%c'\n", __func__, buf[3]); - return -RIG_EVFO; - } + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected VFO value '%c'\n", __func__, buf[3]); + return -RIG_EVFO; + } - if (vfonum != NULL) { - *vfonum = ctrlnum; - } + if (vfonum != NULL) + { + *vfonum = ctrlnum; + } - return RIG_OK; + return RIG_OK; } static int tmd710_get_vfo_and_mode(RIG *rig, vfo_t *vfo, int *vfomode) { - char cmdbuf[10], buf[10]; - int retval, vfonum, vfomodenum; + char cmdbuf[10], buf[10]; + int retval, vfonum, vfomodenum; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - /* Get VFO band */ + /* Get VFO band */ - retval = tmd710_get_vfo_num(rig, &vfonum, vfo); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_get_vfo_num(rig, &vfonum, vfo); - /* Get mode of the VFO band */ + if (retval != RIG_OK) + { + return retval; + } - snprintf(cmdbuf, sizeof(cmdbuf), "VM %d", vfonum); + /* Get mode of the VFO band */ - retval = kenwood_safe_transaction(rig, cmdbuf, buf, 10, 6); - if (retval != RIG_OK) { - return retval; - } + snprintf(cmdbuf, sizeof(cmdbuf), "VM %d", vfonum); - retval = sscanf(buf, "VM %d,%d", &vfonum, &vfomodenum); - if (retval != 2) { - rig_debug(RIG_DEBUG_ERR, "Unable to parse '%s', expected 'VM c,m'\n", buf); - return -RIG_EPROTO; - } + retval = kenwood_safe_transaction(rig, cmdbuf, buf, 10, 6); - if (vfomode != NULL) { - *vfomode = vfomodenum; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = sscanf(buf, "VM %d,%d", &vfonum, &vfomodenum); + + if (retval != 2) + { + rig_debug(RIG_DEBUG_ERR, "Unable to parse '%s', expected 'VM c,m'\n", buf); + return -RIG_EPROTO; + } + + if (vfomode != NULL) + { + *vfomode = vfomodenum; + } + + return RIG_OK; } -static int tmd710_resolve_vfo(RIG *rig, vfo_t vfo, vfo_t *resolved_vfo, int *resolved_vfonum) +static int tmd710_resolve_vfo(RIG *rig, vfo_t vfo, vfo_t *resolved_vfo, + int *resolved_vfonum) { - switch (vfo) { + switch (vfo) + { case RIG_VFO_CURR: - return tmd710_get_vfo_num(rig, resolved_vfonum, resolved_vfo); - case RIG_VFO_A: - if (resolved_vfo != NULL) { - *resolved_vfo = RIG_VFO_A; - } - if (resolved_vfonum != NULL) { - *resolved_vfonum = TMD710_BAND_A; - } - break; - case RIG_VFO_B: - if (resolved_vfo != NULL) { - *resolved_vfo = RIG_VFO_B; - } - if (resolved_vfonum != NULL) { - *resolved_vfonum = TMD710_BAND_B; - } - break; - default: - return -RIG_ENTARGET; - } + return tmd710_get_vfo_num(rig, resolved_vfonum, resolved_vfo); - return RIG_OK; + case RIG_VFO_A: + if (resolved_vfo != NULL) + { + *resolved_vfo = RIG_VFO_A; + } + + if (resolved_vfonum != NULL) + { + *resolved_vfonum = TMD710_BAND_A; + } + + break; + + case RIG_VFO_B: + if (resolved_vfo != NULL) + { + *resolved_vfo = RIG_VFO_B; + } + + if (resolved_vfonum != NULL) + { + *resolved_vfonum = TMD710_BAND_B; + } + + break; + + default: + return -RIG_ENTARGET; + } + + return RIG_OK; } -static int tmd710_scan_me(char *buf, tmd710_me *me_struct) { - int retval; +static int tmd710_scan_me(char *buf, tmd710_me *me_struct) +{ + int retval; - retval = num_sscanf(buf, "ME %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d,%"SCNfreq",%d,%d", - &me_struct->channel, &me_struct->freq, - &me_struct->step, &me_struct->shift, - &me_struct->reverse, &me_struct->tone, - &me_struct->ct, &me_struct->dcs, - &me_struct->tone_freq, &me_struct->ct_freq, - &me_struct->dcs_val, &me_struct->offset, - &me_struct->mode, &me_struct->tx_freq, - &me_struct->p15_unknown, &me_struct->lockout); + retval = num_sscanf(buf, + "ME %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d,%"SCNfreq",%d,%d", + &me_struct->channel, &me_struct->freq, + &me_struct->step, &me_struct->shift, + &me_struct->reverse, &me_struct->tone, + &me_struct->ct, &me_struct->dcs, + &me_struct->tone_freq, &me_struct->ct_freq, + &me_struct->dcs_val, &me_struct->offset, + &me_struct->mode, &me_struct->tx_freq, + &me_struct->p15_unknown, &me_struct->lockout); - if (retval != 16) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); - return -RIG_ERJCTED; - } + if (retval != 16) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); + return -RIG_ERJCTED; + } - return RIG_OK; + return RIG_OK; } /* @@ -780,84 +832,96 @@ static int tmd710_scan_me(char *buf, tmd710_me *me_struct) { */ int tmd710_pull_me(RIG *rig, int ch, tmd710_me *me_struct) { - char cmdbuf[8]; - char buf[80]; - int retval; + char cmdbuf[8]; + char buf[80]; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - snprintf(cmdbuf, sizeof(cmdbuf), "ME %03d", ch); - retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - if (retval != RIG_OK) { - return retval; - } + snprintf(cmdbuf, sizeof(cmdbuf), "ME %03d", ch); + retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - retval = tmd710_scan_me(buf, me_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = tmd710_scan_me(buf, me_struct); + + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } int tmd710_push_me(RIG *rig, tmd710_me *me_struct) { - char cmdbuf[80]; - char buf[80]; + char cmdbuf[80]; + char buf[80]; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - snprintf(cmdbuf, sizeof(cmdbuf), "ME %03d,%010.0f,%1d,%1d,%1d,%1d,%1d,%1d,%02d,%02d,%03d,%08d,%1d,%010.0f,%1d,%1d", - me_struct->channel, me_struct->freq, - me_struct->step, me_struct->shift, - me_struct->reverse, me_struct->tone, - me_struct->ct, me_struct->dcs, - me_struct->tone_freq, me_struct->ct_freq, - me_struct->dcs_val, me_struct->offset, - me_struct->mode, me_struct->tx_freq, - me_struct->p15_unknown, me_struct->lockout); + snprintf(cmdbuf, sizeof(cmdbuf), + "ME %03d,%010.0f,%1d,%1d,%1d,%1d,%1d,%1d,%02d,%02d,%03d,%08d,%1d,%010.0f,%1d,%1d", + me_struct->channel, me_struct->freq, + me_struct->step, me_struct->shift, + me_struct->reverse, me_struct->tone, + me_struct->ct, me_struct->dcs, + me_struct->tone_freq, me_struct->ct_freq, + me_struct->dcs_val, me_struct->offset, + me_struct->mode, me_struct->tx_freq, + me_struct->p15_unknown, me_struct->lockout); - return kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); + return kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); } int tmd710_get_memory_name(RIG *rig, int ch, char *name) { - char cmdbuf[8]; - char buf[80]; - int retval; + char cmdbuf[8]; + char buf[80]; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called on channel %d\n", __func__, ch); + rig_debug(RIG_DEBUG_TRACE, "%s: called on channel %d\n", __func__, ch); - snprintf(cmdbuf, sizeof(cmdbuf), "MN %03d", ch); - retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - if (retval != RIG_OK) { - return retval; - } + snprintf(cmdbuf, sizeof(cmdbuf), "MN %03d", ch); + retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - retval = num_sscanf(buf, "MN %d,%s", &ch, name); - if (retval != 2) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); - return -RIG_ERJCTED; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = num_sscanf(buf, "MN %d,%s", &ch, name); + + if (retval != 2) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); + return -RIG_ERJCTED; + } + + return RIG_OK; } int tmd710_set_memory_name(RIG *rig, int ch, char *name) { - char cmdbuf[32]; - char buf[80]; - int retval; + char cmdbuf[32]; + char buf[80]; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called on channel %d with name %s\n", __func__, ch, name); + rig_debug(RIG_DEBUG_TRACE, "%s: called on channel %d with name %s\n", __func__, + ch, name); - snprintf(cmdbuf, sizeof(cmdbuf), "MN %03d,%s", ch, name); - retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - if (retval != RIG_OK) { - return retval; - } + snprintf(cmdbuf, sizeof(cmdbuf), "MN %03d,%s", ch, name); + retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - return RIG_OK; + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } /* @@ -867,229 +931,250 @@ int tmd710_set_memory_name(RIG *rig, int ch, char *name) */ int tmd710_pull_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) { - char cmdbuf[8]; - char buf[80]; - int vfonum; - int retval; + char cmdbuf[8]; + char buf[80]; + int vfonum; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called with VFO %08X\n", __func__, vfo); + rig_debug(RIG_DEBUG_TRACE, "%s: called with VFO %08X\n", __func__, vfo); - retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - snprintf(cmdbuf, sizeof(cmdbuf), "FO %1d", vfonum); - retval = kenwood_safe_transaction(rig, cmdbuf, buf, sizeof(buf), 48); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - retval = num_sscanf(buf, "FO %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d", - &fo_struct->vfo, &fo_struct->freq, - &fo_struct->step, &fo_struct->shift, - &fo_struct->reverse, &fo_struct->tone, - &fo_struct->ct, &fo_struct->dcs, - &fo_struct->tone_freq, &fo_struct->ct_freq, - &fo_struct->dcs_val, &fo_struct->offset, - &fo_struct->mode); - if (retval != 13) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); - return -RIG_ERJCTED; - } + snprintf(cmdbuf, sizeof(cmdbuf), "FO %1d", vfonum); + retval = kenwood_safe_transaction(rig, cmdbuf, buf, sizeof(buf), 48); - return RIG_OK; + if (retval != RIG_OK) + { + return retval; + } + + retval = num_sscanf(buf, "FO %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d", + &fo_struct->vfo, &fo_struct->freq, + &fo_struct->step, &fo_struct->shift, + &fo_struct->reverse, &fo_struct->tone, + &fo_struct->ct, &fo_struct->dcs, + &fo_struct->tone_freq, &fo_struct->ct_freq, + &fo_struct->dcs_val, &fo_struct->offset, + &fo_struct->mode); + + if (retval != 13) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); + return -RIG_ERJCTED; + } + + return RIG_OK; } int tmd710_push_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) { - char cmdbuf[80]; - char buf[80]; - int retval; + char cmdbuf[80]; + char buf[80]; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - snprintf(cmdbuf, sizeof(cmdbuf), "FO %1d,%010.0f,%1d,%1d,%1d,%1d,%1d,%1d,%02d,%02d,%03d,%08d,%1d", - fo_struct->vfo, fo_struct->freq, - fo_struct->step, fo_struct->shift, - fo_struct->reverse, fo_struct->tone, - fo_struct->ct, fo_struct->dcs, - fo_struct->tone_freq, fo_struct->ct_freq, - fo_struct->dcs_val, fo_struct->offset, - fo_struct->mode); + snprintf(cmdbuf, sizeof(cmdbuf), + "FO %1d,%010.0f,%1d,%1d,%1d,%1d,%1d,%1d,%02d,%02d,%03d,%08d,%1d", + fo_struct->vfo, fo_struct->freq, + fo_struct->step, fo_struct->shift, + fo_struct->reverse, fo_struct->tone, + fo_struct->ct, fo_struct->dcs, + fo_struct->tone_freq, fo_struct->ct_freq, + fo_struct->dcs_val, fo_struct->offset, + fo_struct->mode); - retval = kenwood_safe_transaction(rig, cmdbuf, buf, sizeof(buf), 48); - if (retval != RIG_OK) { - return retval; - } + retval = kenwood_safe_transaction(rig, cmdbuf, buf, sizeof(buf), 48); - retval = num_sscanf(buf, "FO %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d", - &fo_struct->vfo, &fo_struct->freq, - &fo_struct->step, &fo_struct->shift, - &fo_struct->reverse, &fo_struct->tone, - &fo_struct->ct, &fo_struct->dcs, - &fo_struct->tone_freq, &fo_struct->ct_freq, - &fo_struct->dcs_val, &fo_struct->offset, - &fo_struct->mode); - if (retval != 13) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); - return -RIG_ERJCTED; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = num_sscanf(buf, "FO %x,%"SCNfreq",%x,%x,%x,%x,%x,%x,%d,%d,%d,%d,%d", + &fo_struct->vfo, &fo_struct->freq, + &fo_struct->step, &fo_struct->shift, + &fo_struct->reverse, &fo_struct->tone, + &fo_struct->ct, &fo_struct->dcs, + &fo_struct->tone_freq, &fo_struct->ct_freq, + &fo_struct->dcs_val, &fo_struct->offset, + &fo_struct->mode); + + if (retval != 13) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); + return -RIG_ERJCTED; + } + + return RIG_OK; } -int tmd710_scan_mu(char *buf, tmd710_mu *mu_struct) { - int retval; +int tmd710_scan_mu(char *buf, tmd710_mu *mu_struct) +{ + int retval; - retval = num_sscanf(buf, - "MU %d,%d,%d,%d,%d,%d,%d,%d,%d,%d," - "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d," - "%d,%d,%d,%d,%d,%d,%d,%d,%X,%X," - "%X,%X,%X,%X,%d,%d,%d,%d,%d,%d," - "%d,%d", - &mu_struct->beep, - &mu_struct->beep_volume, - &mu_struct->ext_speaker_mode, - &mu_struct->announce, - &mu_struct->language, - &mu_struct->voice_volume, - &mu_struct->voice_speed, - &mu_struct->playback_repeat, - &mu_struct->playback_repeat_interval, - &mu_struct->continuous_recording, - &mu_struct->vhf_aip, - &mu_struct->uhf_aip, - &mu_struct->smeter_sql_hang_up_time, - &mu_struct->mute_hang_up_time, - &mu_struct->beat_shift, - &mu_struct->timeout_timer, - &mu_struct->recall_method, - &mu_struct->echolink_speed, - &mu_struct->dtmf_hold, - &mu_struct->dtmf_speed, - &mu_struct->dtmf_pause, - &mu_struct->dtmf_key_lock, - &mu_struct->auto_repeater_offset, - &mu_struct->tone_1750_tx_hold, - &mu_struct->p25_unknown, - &mu_struct->brightness_level, - &mu_struct->auto_brightness, - &mu_struct->backlight_color, - &mu_struct->pf1_key, - &mu_struct->pf2_key, - &mu_struct->mic_pf1_key, - &mu_struct->mic_pf2_key, - &mu_struct->mic_pf3_key, - &mu_struct->mic_pf4_key, - &mu_struct->mic_key_lock, - &mu_struct->scan_resume, - &mu_struct->auto_power_off, - &mu_struct->ext_data_band, - &mu_struct->ext_data_speed, - &mu_struct->sqc_source, - &mu_struct->auto_pm_store, - &mu_struct->display_partition_bar - ); + retval = num_sscanf(buf, + "MU %d,%d,%d,%d,%d,%d,%d,%d,%d,%d," + "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d," + "%d,%d,%d,%d,%d,%d,%d,%d,%X,%X," + "%X,%X,%X,%X,%d,%d,%d,%d,%d,%d," + "%d,%d", + &mu_struct->beep, + &mu_struct->beep_volume, + &mu_struct->ext_speaker_mode, + &mu_struct->announce, + &mu_struct->language, + &mu_struct->voice_volume, + &mu_struct->voice_speed, + &mu_struct->playback_repeat, + &mu_struct->playback_repeat_interval, + &mu_struct->continuous_recording, + &mu_struct->vhf_aip, + &mu_struct->uhf_aip, + &mu_struct->smeter_sql_hang_up_time, + &mu_struct->mute_hang_up_time, + &mu_struct->beat_shift, + &mu_struct->timeout_timer, + &mu_struct->recall_method, + &mu_struct->echolink_speed, + &mu_struct->dtmf_hold, + &mu_struct->dtmf_speed, + &mu_struct->dtmf_pause, + &mu_struct->dtmf_key_lock, + &mu_struct->auto_repeater_offset, + &mu_struct->tone_1750_tx_hold, + &mu_struct->p25_unknown, + &mu_struct->brightness_level, + &mu_struct->auto_brightness, + &mu_struct->backlight_color, + &mu_struct->pf1_key, + &mu_struct->pf2_key, + &mu_struct->mic_pf1_key, + &mu_struct->mic_pf2_key, + &mu_struct->mic_pf3_key, + &mu_struct->mic_pf4_key, + &mu_struct->mic_key_lock, + &mu_struct->scan_resume, + &mu_struct->auto_power_off, + &mu_struct->ext_data_band, + &mu_struct->ext_data_speed, + &mu_struct->sqc_source, + &mu_struct->auto_pm_store, + &mu_struct->display_partition_bar + ); - if (retval != 42) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); - return -RIG_ERJCTED; - } + if (retval != 42) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, buf); + return -RIG_ERJCTED; + } - return RIG_OK; + return RIG_OK; } int tmd710_pull_mu(RIG *rig, tmd710_mu *mu_struct) { - char buf[128]; - int retval; + char buf[128]; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = kenwood_transaction(rig, "MU", buf, sizeof(buf)); - if (retval != RIG_OK) { - return retval; - } + retval = kenwood_transaction(rig, "MU", buf, sizeof(buf)); - retval = tmd710_scan_mu(buf, mu_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = tmd710_scan_mu(buf, mu_struct); + + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } int tmd710_push_mu(RIG *rig, tmd710_mu *mu_struct) { - char cmdbuf[128]; - char buf[128]; - int retval; + char cmdbuf[128]; + char buf[128]; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - // we re-use fo_struct->vfo for the channel# - snprintf(cmdbuf, sizeof(cmdbuf), - "MU %1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%02d,%1d," - "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d," - "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%02X,%02X," - "%02X,%02X,%02X,%02X,%1d,%1d,%1d,%1d,%1d,%1d," - "%1d,%1d", - mu_struct->beep, - mu_struct->beep_volume, - mu_struct->ext_speaker_mode, - mu_struct->announce, - mu_struct->language, - mu_struct->voice_volume, - mu_struct->voice_speed, - mu_struct->playback_repeat, - mu_struct->playback_repeat_interval, - mu_struct->continuous_recording, - mu_struct->vhf_aip, - mu_struct->uhf_aip, - mu_struct->smeter_sql_hang_up_time, - mu_struct->mute_hang_up_time, - mu_struct->beat_shift, - mu_struct->timeout_timer, - mu_struct->recall_method, - mu_struct->echolink_speed, - mu_struct->dtmf_hold, - mu_struct->dtmf_speed, - mu_struct->dtmf_pause, - mu_struct->dtmf_key_lock, - mu_struct->auto_repeater_offset, - mu_struct->tone_1750_tx_hold, - mu_struct->p25_unknown, - mu_struct->brightness_level, - mu_struct->auto_brightness, - mu_struct->backlight_color, - mu_struct->pf1_key, - mu_struct->pf2_key, - mu_struct->mic_pf1_key, - mu_struct->mic_pf2_key, - mu_struct->mic_pf3_key, - mu_struct->mic_pf4_key, - mu_struct->mic_key_lock, - mu_struct->scan_resume, - mu_struct->auto_power_off, - mu_struct->ext_data_band, - mu_struct->ext_data_speed, - mu_struct->sqc_source, - mu_struct->auto_pm_store, - mu_struct->display_partition_bar - ); + // we re-use fo_struct->vfo for the channel# + snprintf(cmdbuf, sizeof(cmdbuf), + "MU %1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%02d,%1d," + "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d," + "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%02X,%02X," + "%02X,%02X,%02X,%02X,%1d,%1d,%1d,%1d,%1d,%1d," + "%1d,%1d", + mu_struct->beep, + mu_struct->beep_volume, + mu_struct->ext_speaker_mode, + mu_struct->announce, + mu_struct->language, + mu_struct->voice_volume, + mu_struct->voice_speed, + mu_struct->playback_repeat, + mu_struct->playback_repeat_interval, + mu_struct->continuous_recording, + mu_struct->vhf_aip, + mu_struct->uhf_aip, + mu_struct->smeter_sql_hang_up_time, + mu_struct->mute_hang_up_time, + mu_struct->beat_shift, + mu_struct->timeout_timer, + mu_struct->recall_method, + mu_struct->echolink_speed, + mu_struct->dtmf_hold, + mu_struct->dtmf_speed, + mu_struct->dtmf_pause, + mu_struct->dtmf_key_lock, + mu_struct->auto_repeater_offset, + mu_struct->tone_1750_tx_hold, + mu_struct->p25_unknown, + mu_struct->brightness_level, + mu_struct->auto_brightness, + mu_struct->backlight_color, + mu_struct->pf1_key, + mu_struct->pf2_key, + mu_struct->mic_pf1_key, + mu_struct->mic_pf2_key, + mu_struct->mic_pf3_key, + mu_struct->mic_pf4_key, + mu_struct->mic_key_lock, + mu_struct->scan_resume, + mu_struct->auto_power_off, + mu_struct->ext_data_band, + mu_struct->ext_data_speed, + mu_struct->sqc_source, + mu_struct->auto_pm_store, + mu_struct->display_partition_bar + ); - retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - if (retval != RIG_OK) { - return retval; - } + retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); - retval = tmd710_scan_mu(buf, mu_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = tmd710_scan_mu(buf, mu_struct); + + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } /* @@ -1099,34 +1184,41 @@ int tmd710_push_mu(RIG *rig, tmd710_mu *mu_struct) */ int tmd710_do_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - int retval; - tmd710_fo fo_struct; - long freq5, freq625, freq_sent; - int step; + int retval; + tmd710_fo fo_struct; + long freq5, freq625, freq_sent; + int step; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - freq5 = round(freq / 5000) * 5000; - freq625 = round(freq / 6250) * 6250; - if (fabs(freq5 - freq) < fabs(freq625 - freq)) { - step = 0; - freq_sent = freq5; - } else { - step = 1; - freq_sent = freq625; - } + if (retval != RIG_OK) + { + return retval; + } - /* Step needs to be at least 10kHz on higher band, otherwise 5 kHz */ - fo_struct.step = freq_sent >= MHz(470) ? 4 : step; - fo_struct.freq = freq_sent >= MHz(470) ? (round(freq_sent / 10000) * 10000) : freq_sent; + freq5 = round(freq / 5000) * 5000; + freq625 = round(freq / 6250) * 6250; - //return tmd710_push_fo(rig, vfo, &fo_struct); - return tmd710_push_fo(rig, vfo, &fo_struct); + if (fabs(freq5 - freq) < fabs(freq625 - freq)) + { + step = 0; + freq_sent = freq5; + } + else + { + step = 1; + freq_sent = freq625; + } + + /* Step needs to be at least 10kHz on higher band, otherwise 5 kHz */ + fo_struct.step = freq_sent >= MHz(470) ? 4 : step; + fo_struct.freq = freq_sent >= MHz(470) ? (round(freq_sent / 10000) * 10000) : + freq_sent; + + //return tmd710_push_fo(rig, vfo, &fo_struct); + return tmd710_push_fo(rig, vfo, &fo_struct); } /* @@ -1136,88 +1228,101 @@ int tmd710_do_set_freq(RIG *rig, vfo_t vfo, freq_t freq) */ int tmd710_do_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - tmd710_fo fo_struct; - int retval; + tmd710_fo fo_struct; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%d)\n", __func__, rig_strvfo(vfo), vfo); + rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%d)\n", __func__, + rig_strvfo(vfo), vfo); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval == RIG_OK) { - *freq = fo_struct.freq; - } + if (retval == RIG_OK) + { + *freq = fo_struct.freq; + } - return retval; + return retval; } /* * tmd710_set_freq * Assumes rig!=NULL, freq!=NULL */ -int tmd710_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { +int tmd710_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ - rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%d)\n", __func__, rig_strvfo(vfo), vfo); + rig_debug(RIG_DEBUG_TRACE, "%s: called for vfo: %s(%d)\n", __func__, + rig_strvfo(vfo), vfo); - vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A; + vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A; - return tmd710_do_set_freq(rig, vfo, freq); + return tmd710_do_set_freq(rig, vfo, freq); } /* * tmd710_get_freq * Assumes rig!=NULL, freq!=NULL */ -int tmd710_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); +int tmd710_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ - vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A; + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - return tmd710_do_get_freq(rig, vfo, freq); + vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_B : RIG_VFO_A; + + return tmd710_do_get_freq(rig, vfo, freq); } /* * tmd710_set_split_freq * Assumes rig!=NULL, freq!=NULL */ -int tmd710_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq) { +int tmd710_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - - vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_A : RIG_VFO_B; + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - return tmd710_do_set_freq(rig, vfo, freq); + vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_A : RIG_VFO_B; + + return tmd710_do_set_freq(rig, vfo, freq); } /* * tmd710_get_split_freq * Assumes rig!=NULL, freq!=NULL */ -int tmd710_get_split_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); +int tmd710_get_split_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ - vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_A : RIG_VFO_B; - - return tmd710_do_get_freq(rig, vfo, freq); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + + vfo = rig->state.tx_vfo == RIG_VFO_A ? RIG_VFO_A : RIG_VFO_B; + + return tmd710_do_get_freq(rig, vfo, freq); } -static int tmd710_find_ctcss_index(RIG *rig, tone_t tone, int *ctcss_index) { - int k, stepind = -1; - for (k = 0; k < 42; k++) { - if (rig->caps->ctcss_list[k] == tone) { - stepind = k; - break; +static int tmd710_find_ctcss_index(RIG *rig, tone_t tone, int *ctcss_index) +{ + int k, stepind = -1; + + for (k = 0; k < 42; k++) + { + if (rig->caps->ctcss_list[k] == tone) + { + stepind = k; + break; + } } - } - if (stepind == -1) { - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported tone value '%d'\n", __func__, tone); - return -RIG_EINVAL; - } - *ctcss_index = stepind; + if (stepind == -1) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported tone value '%d'\n", __func__, tone); + return -RIG_EINVAL; + } - return RIG_OK; + *ctcss_index = stepind; + + return RIG_OK; } /* @@ -1226,24 +1331,28 @@ static int tmd710_find_ctcss_index(RIG *rig, tone_t tone, int *ctcss_index) { */ static int tmd710_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) { - int retval, stepind; - tmd710_fo fo_struct; + int retval, stepind; + tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_find_ctcss_index(rig, tone, &stepind); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_find_ctcss_index(rig, tone, &stepind); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - fo_struct.tone_freq = stepind; + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - return tmd710_push_fo(rig, vfo, &fo_struct); + if (retval != RIG_OK) + { + return retval; + } + + fo_struct.tone_freq = stepind; + + return tmd710_push_fo(rig, vfo, &fo_struct); } /* @@ -1252,21 +1361,22 @@ static int tmd710_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) */ int tmd710_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) { - tmd710_fo fo_struct; - int retval; + tmd710_fo fo_struct; + int retval; - const struct rig_caps *caps; - caps = rig->caps; + const struct rig_caps *caps; + caps = rig->caps; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval == RIG_OK) { - *tone = caps->ctcss_list[fo_struct.tone_freq]; - } + if (retval == RIG_OK) + { + *tone = caps->ctcss_list[fo_struct.tone_freq]; + } - return retval; + return retval; } /* @@ -1275,24 +1385,28 @@ int tmd710_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) */ static int tmd710_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) { - int retval, stepind; - tmd710_fo fo_struct; + int retval, stepind; + tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_find_ctcss_index(rig, tone, &stepind); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_find_ctcss_index(rig, tone, &stepind); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - fo_struct.ct_freq = stepind; + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - return tmd710_push_fo(rig, vfo, &fo_struct); + if (retval != RIG_OK) + { + return retval; + } + + fo_struct.ct_freq = stepind; + + return tmd710_push_fo(rig, vfo, &fo_struct); } /* @@ -1301,21 +1415,22 @@ static int tmd710_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) */ int tmd710_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) { - tmd710_fo fo_struct; - int retval; + tmd710_fo fo_struct; + int retval; - const struct rig_caps *caps; - caps = rig->caps; + const struct rig_caps *caps; + caps = rig->caps; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval == RIG_OK) { - *tone = caps->ctcss_list[fo_struct.ct_freq]; - } + if (retval == RIG_OK) + { + *tone = caps->ctcss_list[fo_struct.ct_freq]; + } - return retval; + return retval; } /* @@ -1323,43 +1438,54 @@ int tmd710_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) */ int tmd710_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code) { - int retval; - tmd710_fo fo_struct; + int retval; + tmd710_fo fo_struct; - if (!rig || !code) { - return -RIG_EINVAL; - } + if (!rig || !code) + { + return -RIG_EINVAL; + } - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (fo_struct.dcs) { - tone_t *dcs_list = common_dcs_list; - *code = dcs_list[fo_struct.dcs_val]; - } else { - *code = 0; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + if (fo_struct.dcs) + { + tone_t *dcs_list = common_dcs_list; + *code = dcs_list[fo_struct.dcs_val]; + } + else + { + *code = 0; + } + + return RIG_OK; } -static int tmd710_find_dcs_index(tone_t code, int *dcs_index) { - int i = 0; +static int tmd710_find_dcs_index(tone_t code, int *dcs_index) +{ + int i = 0; - // we only allow exact matches here - tone_t *dcs_list = common_dcs_list; - while (code != dcs_list[i]) { - if (dcs_list[i] == 0) { - return -RIG_EINVAL; + // we only allow exact matches here + tone_t *dcs_list = common_dcs_list; + + while (code != dcs_list[i]) + { + if (dcs_list[i] == 0) + { + return -RIG_EINVAL; + } + + i++; } - i++; - } - *dcs_index = i; + *dcs_index = i; - return RIG_OK; + return RIG_OK; } /* @@ -1367,51 +1493,66 @@ static int tmd710_find_dcs_index(tone_t code, int *dcs_index) { */ int tmd710_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code) { - int retval, dcs_index, dcs_enable; - tmd710_fo fo_struct; + int retval, dcs_index, dcs_enable; + tmd710_fo fo_struct; - if (code == 0) { - dcs_index = 0; - dcs_enable = 0; - } else { - retval = tmd710_find_dcs_index(code, &dcs_index); - if (retval != RIG_OK) { - return retval; + if (code == 0) + { + dcs_index = 0; + dcs_enable = 0; } - dcs_enable = 1; - } + else + { + retval = tmd710_find_dcs_index(code, &dcs_index); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - fo_struct.dcs = dcs_enable; - fo_struct.dcs_val = dcs_index; + dcs_enable = 1; + } - return tmd710_push_fo(rig, vfo, &fo_struct); + retval = tmd710_pull_fo(rig, vfo, &fo_struct); + + if (retval != RIG_OK) + { + return retval; + } + + fo_struct.dcs = dcs_enable; + fo_struct.dcs_val = dcs_index; + + return tmd710_push_fo(rig, vfo, &fo_struct); } -static int tmd710_get_mode_hamlib_values(int tmd710_mode, rmode_t *mode, pbwidth_t *width) { - switch (tmd710_mode) { +static int tmd710_get_mode_hamlib_values(int tmd710_mode, rmode_t *mode, + pbwidth_t *width) +{ + switch (tmd710_mode) + { case 0: - *mode = RIG_MODE_FM; - *width = 15000; - break; - case 1: - *mode = RIG_MODE_FMN; - *width = 5000; - break; - case 2: - *mode = RIG_MODE_AM; - *width = 4000; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Illegal value from radio '%ld'\n", __func__, (long)tmd710_mode); - return -RIG_EINVAL; - } + *mode = RIG_MODE_FM; + *width = 15000; + break; - return RIG_OK; + case 1: + *mode = RIG_MODE_FMN; + *width = 5000; + break; + + case 2: + *mode = RIG_MODE_AM; + *width = 4000; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Illegal value from radio '%ld'\n", __func__, + (long)tmd710_mode); + return -RIG_EINVAL; + } + + return RIG_OK; } /* @@ -1420,37 +1561,50 @@ static int tmd710_get_mode_hamlib_values(int tmd710_mode, rmode_t *mode, pbwidth */ int tmd710_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - tmd710_fo fo_struct; - int retval; + tmd710_fo fo_struct; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - retval = tmd710_get_mode_hamlib_values(fo_struct.mode, mode, width); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = tmd710_get_mode_hamlib_values(fo_struct.mode, mode, width); + + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } -static int tmd710_get_mode_tmd710_value(rmode_t mode, int *tmd710_mode) { - if (mode == RIG_MODE_FM) { - *tmd710_mode = 0; - } else if (mode == RIG_MODE_FMN) { - *tmd710_mode = 1; - } else if (mode == RIG_MODE_AM) { - *tmd710_mode = 2; - } else { - rig_debug(RIG_DEBUG_ERR, "%s: Illegal value from radio '%ld'\n", __func__, (long)mode); - return -RIG_EINVAL; - } +static int tmd710_get_mode_tmd710_value(rmode_t mode, int *tmd710_mode) +{ + if (mode == RIG_MODE_FM) + { + *tmd710_mode = 0; + } + else if (mode == RIG_MODE_FMN) + { + *tmd710_mode = 1; + } + else if (mode == RIG_MODE_AM) + { + *tmd710_mode = 2; + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: Illegal value from radio '%ld'\n", __func__, + (long)mode); + return -RIG_EINVAL; + } - return RIG_OK; + return RIG_OK; } /* @@ -1459,47 +1613,60 @@ static int tmd710_get_mode_tmd710_value(rmode_t mode, int *tmd710_mode) { */ static int tmd710_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - int retval, tmd710_mode = RIG_MODE_NONE; - tmd710_fo fo_struct; + int retval, tmd710_mode = RIG_MODE_NONE; + tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_get_mode_tmd710_value(mode, &tmd710_mode); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_get_mode_tmd710_value(mode, &tmd710_mode); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - fo_struct.mode = tmd710_mode; + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - return tmd710_push_fo(rig, vfo, &fo_struct); + if (retval != RIG_OK) + { + return retval; + } + + fo_struct.mode = tmd710_mode; + + return tmd710_push_fo(rig, vfo, &fo_struct); } -static int tmd710_find_tuning_step_index(RIG *rig, shortfreq_t ts, int *step_index) { - int k, stepind = -1; +static int tmd710_find_tuning_step_index(RIG *rig, shortfreq_t ts, + int *step_index) +{ + int k, stepind = -1; - for (k = 0; rig->state.tuning_steps[k].ts != 0; ++k) { + for (k = 0; rig->state.tuning_steps[k].ts != 0; ++k) + { - if ((rig->caps->tuning_steps[k].modes == RIG_MODE_NONE) - && (rig->caps->tuning_steps[k].ts == 0)) - break; - else if (rig->caps->tuning_steps[k].ts == ts) { - stepind = k; - break; + if ((rig->caps->tuning_steps[k].modes == RIG_MODE_NONE) + && (rig->caps->tuning_steps[k].ts == 0)) + { + break; + } + else if (rig->caps->tuning_steps[k].ts == ts) + { + stepind = k; + break; + } } - } - if (stepind == -1) { - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported tuning step value '%ld'\n", __func__, ts); - return -RIG_EINVAL; - } - *step_index = stepind; + if (stepind == -1) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported tuning step value '%ld'\n", __func__, + ts); + return -RIG_EINVAL; + } - return RIG_OK; + *step_index = stepind; + + return RIG_OK; } /* @@ -1508,62 +1675,72 @@ static int tmd710_find_tuning_step_index(RIG *rig, shortfreq_t ts, int *step_ind */ static int tmd710_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts) { - int retval, stepind; - tmd710_fo fo_struct; + int retval, stepind; + tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_find_tuning_step_index(rig, ts, &stepind); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_find_tuning_step_index(rig, ts, &stepind); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - fo_struct.step = stepind; + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - return tmd710_push_fo(rig, vfo, &fo_struct); + if (retval != RIG_OK) + { + return retval; + } + + fo_struct.step = stepind; + + return tmd710_push_fo(rig, vfo, &fo_struct); } /* * tmd710_get_ts * Assumes rig!=NULL, freq!=NULL */ -static int tmd710_get_ts(RIG *rig, vfo_t vfo, shortfreq_t* ts) +static int tmd710_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts) { - int retval; - tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + int retval; + tmd710_fo fo_struct; + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval == RIG_OK) { - *ts = rig->caps->tuning_steps[fo_struct.step].ts; - } + if (retval == RIG_OK) + { + *ts = rig->caps->tuning_steps[fo_struct.step].ts; + } - return retval; + return retval; } -int tmd710_get_rptr_shift_tmd710_value(rptr_shift_t shift, int *tmd710_shift) { - switch (shift) { +int tmd710_get_rptr_shift_tmd710_value(rptr_shift_t shift, int *tmd710_shift) +{ + switch (shift) + { case RIG_RPT_SHIFT_NONE: - *tmd710_shift = 0; - break; - case RIG_RPT_SHIFT_PLUS: - *tmd710_shift = 1; - break; - case RIG_RPT_SHIFT_MINUS: - *tmd710_shift = 2; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected shift value '%d'\n", __func__, shift); - return -RIG_EPROTO; - } + *tmd710_shift = 0; + break; - return RIG_OK; + case RIG_RPT_SHIFT_PLUS: + *tmd710_shift = 1; + break; + + case RIG_RPT_SHIFT_MINUS: + *tmd710_shift = 2; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected shift value '%d'\n", __func__, shift); + return -RIG_EPROTO; + } + + return RIG_OK; } /* @@ -1572,41 +1749,51 @@ int tmd710_get_rptr_shift_tmd710_value(rptr_shift_t shift, int *tmd710_shift) { */ int tmd710_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift) { - int retval; - tmd710_fo fo_struct; + int retval; + tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - retval = tmd710_get_rptr_shift_tmd710_value(shift, &fo_struct.shift); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - return tmd710_push_fo(rig, vfo, &fo_struct); + retval = tmd710_get_rptr_shift_tmd710_value(shift, &fo_struct.shift); + + if (retval != RIG_OK) + { + return retval; + } + + return tmd710_push_fo(rig, vfo, &fo_struct); } -int tmd710_get_rptr_shift_hamlib_value(int tmd710_shift, rptr_shift_t *shift) { - switch (tmd710_shift) { +int tmd710_get_rptr_shift_hamlib_value(int tmd710_shift, rptr_shift_t *shift) +{ + switch (tmd710_shift) + { case 0: - *shift = RIG_RPT_SHIFT_NONE; - break; - case 1: - *shift = RIG_RPT_SHIFT_PLUS; - break; - case 2: - *shift = RIG_RPT_SHIFT_MINUS; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected shift value '%d'\n", __func__, tmd710_shift); - return -RIG_EPROTO; - } + *shift = RIG_RPT_SHIFT_NONE; + break; - return RIG_OK; + case 1: + *shift = RIG_RPT_SHIFT_PLUS; + break; + + case 2: + *shift = RIG_RPT_SHIFT_MINUS; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected shift value '%d'\n", __func__, + tmd710_shift); + return -RIG_EPROTO; + } + + return RIG_OK; } /* @@ -1615,22 +1802,26 @@ int tmd710_get_rptr_shift_hamlib_value(int tmd710_shift, rptr_shift_t *shift) { */ int tmd710_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift) { - int retval; - tmd710_fo fo_struct; + int retval; + tmd710_fo fo_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - retval = tmd710_get_rptr_shift_hamlib_value(fo_struct.shift, shift); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + retval = tmd710_get_rptr_shift_hamlib_value(fo_struct.shift, shift); + + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } /* @@ -1639,28 +1830,36 @@ int tmd710_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift) */ int tmd710_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t freq) { - int retval; - tmd710_fo fo_struct; - long freq5, freq625, freq_sent; + int retval; + tmd710_fo fo_struct; + long freq5, freq625, freq_sent; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - freq5 = round(freq / 5000) * 5000; - freq625 = round(freq / 6250) * 6250; - if (abs((int) (freq5 - freq)) < abs((int) (freq625 - freq))) { - freq_sent = freq5; - } else { - freq_sent = freq625; - } - /* Step needs to be at least 10kHz on higher band, otherwise 5 kHz */ - fo_struct.offset = freq_sent >= MHz(470) ? (round(freq_sent / 10000) * 10000) : freq_sent; + if (retval != RIG_OK) + { + return retval; + } - return tmd710_push_fo(rig, vfo, &fo_struct); + freq5 = round(freq / 5000) * 5000; + freq625 = round(freq / 6250) * 6250; + + if (abs((int)(freq5 - freq)) < abs((int)(freq625 - freq))) + { + freq_sent = freq5; + } + else + { + freq_sent = freq625; + } + + /* Step needs to be at least 10kHz on higher band, otherwise 5 kHz */ + fo_struct.offset = freq_sent >= MHz(470) ? (round(freq_sent / 10000) * 10000) : + freq_sent; + + return tmd710_push_fo(rig, vfo, &fo_struct); } @@ -1671,18 +1870,20 @@ int tmd710_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t freq) */ int tmd710_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs) { - tmd710_fo fo_struct; - int retval; + tmd710_fo fo_struct; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_fo(rig, vfo, &fo_struct); + retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval == RIG_OK) - *rptr_offs = fo_struct.offset; + if (retval == RIG_OK) + { + *rptr_offs = fo_struct.offset; + } - return retval; + return retval; } /* @@ -1691,29 +1892,35 @@ int tmd710_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs) */ int tmd710_get_vfo(RIG *rig, vfo_t *vfo) { - int vfomode; - int retval; + int vfomode; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_get_vfo_and_mode(rig, vfo, &vfomode); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_get_vfo_and_mode(rig, vfo, &vfomode); - switch (vfomode) { + if (retval != RIG_OK) + { + return retval; + } + + switch (vfomode) + { case TMD710_BAND_MODE_VFO: - break; + break; + case TMD710_BAND_MODE_MEMORY: case TMD710_BAND_MODE_CALL: - *vfo = RIG_VFO_MEM; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected VFO mode value '%c'\n", __func__, vfomode); - return -RIG_EVFO; - } + *vfo = RIG_VFO_MEM; + break; - return RIG_OK; + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected VFO mode value '%c'\n", __func__, + vfomode); + return -RIG_EVFO; + } + + return RIG_OK; } /* @@ -1723,399 +1930,494 @@ int tmd710_get_vfo(RIG *rig, vfo_t *vfo) */ int tmd710_set_vfo(RIG *rig, vfo_t vfo) { - char vfobuf[16], ackbuf[16]; - int vfonum, vfomode; - int retval; + char vfobuf[16], ackbuf[16]; + int vfonum, vfomode; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called %s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: called %s\n", __func__, rig_strvfo(vfo)); - switch (vfo) { + switch (vfo) + { case RIG_VFO_A: case RIG_VFO_VFO: - vfonum = TMD710_BAND_A; - vfomode = TMD710_BAND_MODE_VFO; - break; + vfonum = TMD710_BAND_A; + vfomode = TMD710_BAND_MODE_VFO; + break; + case RIG_VFO_B: - vfonum = TMD710_BAND_B; - vfomode = TMD710_BAND_MODE_VFO; - break; + vfonum = TMD710_BAND_B; + vfomode = TMD710_BAND_MODE_VFO; + break; + case RIG_VFO_MEM: - /* get current band */ - retval = tmd710_get_vfo_num(rig, &vfonum, NULL); - if (retval != RIG_OK) { - return retval; - } - vfomode = TMD710_BAND_MODE_MEMORY; - break; + /* get current band */ + retval = tmd710_get_vfo_num(rig, &vfonum, NULL); + + if (retval != RIG_OK) + { + return retval; + } + + vfomode = TMD710_BAND_MODE_MEMORY; + break; + default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __func__, vfo); - return -RIG_EVFO; - } + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __func__, vfo); + return -RIG_EVFO; + } - snprintf(vfobuf, sizeof(vfobuf), "VM %1d,%1d", vfonum, vfomode); - retval = kenwood_transaction(rig, vfobuf, ackbuf, sizeof(ackbuf)); - if (retval != RIG_OK) { - return retval; - } + snprintf(vfobuf, sizeof(vfobuf), "VM %1d,%1d", vfonum, vfomode); + retval = kenwood_transaction(rig, vfobuf, ackbuf, sizeof(ackbuf)); + + if (retval != RIG_OK) + { + return retval; + } + + if (vfo == RIG_VFO_MEM) + { + return RIG_OK; + } + + snprintf(vfobuf, sizeof(vfobuf), "BC %1d,%1d", vfonum, vfonum); + retval = kenwood_transaction(rig, vfobuf, ackbuf, sizeof(ackbuf)); + + if (retval != RIG_OK) + { + return retval; + } - if (vfo == RIG_VFO_MEM) { return RIG_OK; - } - - snprintf(vfobuf, sizeof(vfobuf), "BC %1d,%1d", vfonum, vfonum); - retval = kenwood_transaction(rig, vfobuf, ackbuf, sizeof(ackbuf)); - if (retval != RIG_OK) { - return retval; - } - - return RIG_OK; } /* -* tmd710_set_split_vfo +* tmd710_set_split_vfo * -* This radio has two VFOs, and either one can be the TX/RX. As such, this function does two things: -* - Sets PTT control on the specified VFO. -* - Sets the TX_VFO and RX_VFO for use in Set_Freq and Set_Split_Freq -* - The value of split is ignored, as the radio is always in "split" mode. +* This radio has two VFOs, and either one can be the TX/RX. As such, this function does two things: +* - Sets PTT control on the specified VFO. +* - Sets the TX_VFO and RX_VFO for use in Set_Freq and Set_Split_Freq +* - The value of split is ignored, as the radio is always in "split" mode. * */ -int tmd710_set_split_vfo (RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) +int tmd710_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) { char vfobuf[16], ackbuf[16]; int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called vfo: %s\ttxvfo: %s\n", __func__, rig_strvfo(vfo), rig_strvfo(txvfo)); - - rig->state.tx_vfo = txvfo; + rig_debug(RIG_DEBUG_TRACE, "%s: called vfo: %s\ttxvfo: %s\n", __func__, + rig_strvfo(vfo), rig_strvfo(txvfo)); - int txVfoIndex = txvfo == RIG_VFO_A ? 0 : 1; + rig->state.tx_vfo = txvfo; - sprintf(vfobuf, "BC %d,%d", txVfoIndex, txVfoIndex ); + int txVfoIndex = txvfo == RIG_VFO_A ? 0 : 1; + + sprintf(vfobuf, "BC %d,%d", txVfoIndex, txVfoIndex); retval = kenwood_transaction(rig, vfobuf, ackbuf, sizeof(ackbuf)); - if (retval != RIG_OK) - return retval; - + if (retval != RIG_OK) + { + return retval; + } + + return RIG_OK; } -int tmd710_get_split_vfo (RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo) +int tmd710_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo) { char buf[10]; int retval; rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - /* Get VFO band */ + /* Get VFO band */ - retval = kenwood_safe_transaction(rig, "BC", buf, 10, 6); - if (retval != RIG_OK) - return retval; + retval = kenwood_safe_transaction(rig, "BC", buf, 10, 6); - switch (buf[5]) { - case '0': *txvfo = RIG_VFO_A; break; - case '1': *txvfo = RIG_VFO_B; break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected txVFO value '%c'\n", __func__, buf[5]); - return -RIG_EPROTO; - } + if (retval != RIG_OK) + { + return retval; + } + + switch (buf[5]) + { + case '0': *txvfo = RIG_VFO_A; break; + + case '1': *txvfo = RIG_VFO_B; break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected txVFO value '%c'\n", __func__, buf[5]); + return -RIG_EPROTO; + } rig->state.tx_vfo = *txvfo; - return RIG_OK; + return RIG_OK; } int tmd710_get_mem(RIG *rig, vfo_t vfo, int *ch) { - char cmd[16]; - char membuf[16]; - int retval; - int vfonum; - int n; + char cmd[16]; + char membuf[16]; + int retval; + int vfonum; + int n; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (!rig || !ch) { - return -RIG_EINVAL; - } - - if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) { - retval = tmd710_get_vfo_num(rig, &vfonum, NULL); - if (retval != RIG_OK) { - return retval; + if (!rig || !ch) + { + return -RIG_EINVAL; } - } - else - { - vfonum = rig->state.current_vfo == RIG_VFO_A ? 0: 1; - } - snprintf(cmd, sizeof(cmd), "MR %d", vfonum); - retval = kenwood_safe_transaction(rig, cmd, membuf, sizeof(membuf), 8); - if (retval != RIG_OK) { - return retval; - } + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + retval = tmd710_get_vfo_num(rig, &vfonum, NULL); - n = sscanf(membuf, "MR %*d,%d", ch); - if (n != 1) { - rig_debug(RIG_DEBUG_ERR, "Unable to parse '%s', expected 'MR v,ccc'\n", membuf); - return -RIG_EPROTO; - } + if (retval != RIG_OK) + { + return retval; + } + } + else + { + vfonum = rig->state.current_vfo == RIG_VFO_A ? 0 : 1; + } - return RIG_OK; + snprintf(cmd, sizeof(cmd), "MR %d", vfonum); + retval = kenwood_safe_transaction(rig, cmd, membuf, sizeof(membuf), 8); + + if (retval != RIG_OK) + { + return retval; + } + + n = sscanf(membuf, "MR %*d,%d", ch); + + if (n != 1) + { + rig_debug(RIG_DEBUG_ERR, "Unable to parse '%s', expected 'MR v,ccc'\n", membuf); + return -RIG_EPROTO; + } + + return RIG_OK; } int tmd710_set_mem(RIG *rig, vfo_t vfo, int ch) { - int retval, vfonum; - char cmd[16]; - char membuf[16]; + int retval, vfonum; + char cmd[16]; + char membuf[16]; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (!rig) { - return -RIG_EINVAL; - } - - if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) { - retval = tmd710_get_vfo_num(rig, &vfonum, NULL); - if (retval != RIG_OK) { - return retval; + if (!rig) + { + return -RIG_EINVAL; } - } - else - { - vfonum = rig->state.current_vfo == RIG_VFO_A ? 0: 1; - } - snprintf(cmd, sizeof(cmd), "MR %d,%03d", vfonum, ch); + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + retval = tmd710_get_vfo_num(rig, &vfonum, NULL); - return kenwood_safe_transaction(rig, cmd, membuf, sizeof(membuf), 8); + if (retval != RIG_OK) + { + return retval; + } + } + else + { + vfonum = rig->state.current_vfo == RIG_VFO_A ? 0 : 1; + } + + snprintf(cmd, sizeof(cmd), "MR %d,%03d", vfonum, ch); + + return kenwood_safe_transaction(rig, cmd, membuf, sizeof(membuf), 8); } int tmd710_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) { - int retval; - tmd710_me me_struct; + int retval; + tmd710_me me_struct; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (!rig || !chan) { - return -RIG_EINVAL; - } + if (!rig || !chan) + { + return -RIG_EINVAL; + } - retval = tmd710_pull_me(rig, chan->channel_num, &me_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_me(rig, chan->channel_num, &me_struct); - chan->freq = me_struct.freq; - chan->vfo = RIG_VFO_CURR; + if (retval != RIG_OK) + { + return retval; + } - retval = tmd710_get_mode_hamlib_values(me_struct.mode, &chan->mode, &chan->width); - if (retval != RIG_OK) { - return retval; - } + chan->freq = me_struct.freq; + chan->vfo = RIG_VFO_CURR; - chan->tuning_step = rig->caps->tuning_steps[me_struct.step].ts; + retval = tmd710_get_mode_hamlib_values(me_struct.mode, &chan->mode, + &chan->width); - chan->funcs = 0; + if (retval != RIG_OK) + { + return retval; + } - if (me_struct.tone != 0) { - chan->funcs |= RIG_FUNC_TONE; - } - if (me_struct.ct != 0) { - chan->funcs |= RIG_FUNC_TSQL; - } - if (me_struct.reverse != 0) { - chan->funcs |= RIG_FUNC_REV; - } + chan->tuning_step = rig->caps->tuning_steps[me_struct.step].ts; - chan->ctcss_tone = rig->caps->ctcss_list[me_struct.tone_freq]; - chan->ctcss_sql = rig->caps->ctcss_list[me_struct.ct_freq]; - chan->dcs_code = 0; - if (me_struct.dcs) { - tone_t *dcs_list = common_dcs_list; - chan->dcs_sql = dcs_list[me_struct.dcs_val]; - } else { - chan->dcs_sql = 0; - } + chan->funcs = 0; - retval = tmd710_get_rptr_shift_hamlib_value(me_struct.shift, &chan->rptr_shift); - if (retval != RIG_OK) { - return retval; - } + if (me_struct.tone != 0) + { + chan->funcs |= RIG_FUNC_TONE; + } - chan->rptr_offs = me_struct.offset; + if (me_struct.ct != 0) + { + chan->funcs |= RIG_FUNC_TSQL; + } - retval = tmd710_get_memory_name(rig, chan->channel_num, chan->channel_desc); - if (retval != RIG_OK) { - return retval; - } + if (me_struct.reverse != 0) + { + chan->funcs |= RIG_FUNC_REV; + } - chan->flags = RIG_CHFLAG_NONE; + chan->ctcss_tone = rig->caps->ctcss_list[me_struct.tone_freq]; + chan->ctcss_sql = rig->caps->ctcss_list[me_struct.ct_freq]; + chan->dcs_code = 0; - if (me_struct.lockout) { - chan->flags |= RIG_CHFLAG_SKIP; - } + if (me_struct.dcs) + { + tone_t *dcs_list = common_dcs_list; + chan->dcs_sql = dcs_list[me_struct.dcs_val]; + } + else + { + chan->dcs_sql = 0; + } - chan->tx_freq = me_struct.tx_freq; + retval = tmd710_get_rptr_shift_hamlib_value(me_struct.shift, &chan->rptr_shift); - // Unsupported features - chan->bank_num = 0; - chan->ant = 0; - chan->split = RIG_SPLIT_OFF; - chan->tx_vfo = RIG_VFO_NONE; - chan->tx_mode = RIG_MODE_NONE; - chan->tx_width = 0; - chan->rit = 0; - chan->xit = 0; - chan->scan_group = 0; - // TODO: chan->levels - chan->ext_levels = NULL; + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + chan->rptr_offs = me_struct.offset; + + retval = tmd710_get_memory_name(rig, chan->channel_num, chan->channel_desc); + + if (retval != RIG_OK) + { + return retval; + } + + chan->flags = RIG_CHFLAG_NONE; + + if (me_struct.lockout) + { + chan->flags |= RIG_CHFLAG_SKIP; + } + + chan->tx_freq = me_struct.tx_freq; + + // Unsupported features + chan->bank_num = 0; + chan->ant = 0; + chan->split = RIG_SPLIT_OFF; + chan->tx_vfo = RIG_VFO_NONE; + chan->tx_mode = RIG_MODE_NONE; + chan->tx_width = 0; + chan->rit = 0; + chan->xit = 0; + chan->scan_group = 0; + // TODO: chan->levels + chan->ext_levels = NULL; + + return RIG_OK; } int tmd710_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan) { - int retval; - tmd710_me me_struct; + int retval; + tmd710_me me_struct; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (!rig || !chan) { - return -RIG_EINVAL; - } - - me_struct.channel = chan->channel_num; - me_struct.freq = chan->freq; - me_struct.tx_freq = chan->tx_freq; - - retval = tmd710_find_tuning_step_index(rig, chan->tuning_step, &me_struct.step); - if (retval != RIG_OK) { - return retval; - } - - retval = tmd710_get_rptr_shift_tmd710_value(chan->rptr_shift, &me_struct.shift); - if (retval != RIG_OK) { - return retval; - } - - me_struct.offset = chan->rptr_offs; - - me_struct.reverse = (chan->funcs & RIG_FUNC_REV) ? 1 : 0; - me_struct.tone = (chan->funcs & RIG_FUNC_TONE) ? 1 : 0; - me_struct.ct = (chan->funcs & RIG_FUNC_TSQL) ? 1 : 0; - - if (!me_struct.tone && chan->ctcss_tone == 0) { - me_struct.tone_freq = 0; - } else { - retval = tmd710_find_ctcss_index(rig, chan->ctcss_tone, &me_struct.tone_freq); - if (retval != RIG_OK) { - return retval; + if (!rig || !chan) + { + return -RIG_EINVAL; } - } - if (!me_struct.ct && chan->ctcss_sql == 0) { - me_struct.ct_freq = 0; - } else { - retval = tmd710_find_ctcss_index(rig, chan->ctcss_sql, &me_struct.ct_freq); - if (retval != RIG_OK) { - return retval; + me_struct.channel = chan->channel_num; + me_struct.freq = chan->freq; + me_struct.tx_freq = chan->tx_freq; + + retval = tmd710_find_tuning_step_index(rig, chan->tuning_step, &me_struct.step); + + if (retval != RIG_OK) + { + return retval; } - } - if (chan->dcs_sql == 0) { - me_struct.dcs = 0; - me_struct.dcs_val = 0; - } else { - retval = tmd710_find_dcs_index(chan->dcs_sql, &me_struct.dcs_val); - if (retval != RIG_OK) { - return retval; + retval = tmd710_get_rptr_shift_tmd710_value(chan->rptr_shift, &me_struct.shift); + + if (retval != RIG_OK) + { + return retval; } - me_struct.dcs = 1; - } - me_struct.lockout = (chan->flags & RIG_CHFLAG_SKIP) ? 1 : 0; + me_struct.offset = chan->rptr_offs; - retval = tmd710_get_mode_tmd710_value(chan->mode, &me_struct.mode); - if (retval != RIG_OK) { - return retval; - } + me_struct.reverse = (chan->funcs & RIG_FUNC_REV) ? 1 : 0; + me_struct.tone = (chan->funcs & RIG_FUNC_TONE) ? 1 : 0; + me_struct.ct = (chan->funcs & RIG_FUNC_TSQL) ? 1 : 0; - me_struct.p15_unknown = 0; + if (!me_struct.tone && chan->ctcss_tone == 0) + { + me_struct.tone_freq = 0; + } + else + { + retval = tmd710_find_ctcss_index(rig, chan->ctcss_tone, &me_struct.tone_freq); - retval = tmd710_push_me(rig, &me_struct); - if (retval != RIG_OK) { - return retval; - } + if (retval != RIG_OK) + { + return retval; + } + } - return tmd710_set_memory_name(rig, me_struct.channel, (char *) chan->channel_desc); + if (!me_struct.ct && chan->ctcss_sql == 0) + { + me_struct.ct_freq = 0; + } + else + { + retval = tmd710_find_ctcss_index(rig, chan->ctcss_sql, &me_struct.ct_freq); + + if (retval != RIG_OK) + { + return retval; + } + } + + if (chan->dcs_sql == 0) + { + me_struct.dcs = 0; + me_struct.dcs_val = 0; + } + else + { + retval = tmd710_find_dcs_index(chan->dcs_sql, &me_struct.dcs_val); + + if (retval != RIG_OK) + { + return retval; + } + + me_struct.dcs = 1; + } + + me_struct.lockout = (chan->flags & RIG_CHFLAG_SKIP) ? 1 : 0; + + retval = tmd710_get_mode_tmd710_value(chan->mode, &me_struct.mode); + + if (retval != RIG_OK) + { + return retval; + } + + me_struct.p15_unknown = 0; + + retval = tmd710_push_me(rig, &me_struct); + + if (retval != RIG_OK) + { + return retval; + } + + return tmd710_set_memory_name(rig, me_struct.channel, + (char *) chan->channel_desc); } int tmd710_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { - char ackbuf[32]; + char ackbuf[32]; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - return kenwood_transaction(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX", ackbuf, sizeof(ackbuf)); + return kenwood_transaction(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX", ackbuf, + sizeof(ackbuf)); } int tmd710_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) { - char cmd[8], buf[8]; - int retval; - int vfonum, dcd_val; + char cmd[8], buf[8]; + int retval; + int vfonum, dcd_val; - retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - snprintf(cmd, sizeof(cmd), "BY %d", vfonum); + if (retval != RIG_OK) + { + return retval; + } - retval = kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), 6); - if (retval != RIG_OK) { - return retval; - } + snprintf(cmd, sizeof(cmd), "BY %d", vfonum); - retval = sscanf(buf, "BY %d,%d", &vfonum, &dcd_val); - if (retval != 2) { - rig_debug(RIG_DEBUG_ERR, "%s: unexpected reply '%s', len=%ld\n", __func__, buf, (long)strlen(buf)); - return -RIG_EPROTO; - } + retval = kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), 6); - switch (dcd_val) { + if (retval != RIG_OK) + { + return retval; + } + + retval = sscanf(buf, "BY %d,%d", &vfonum, &dcd_val); + + if (retval != 2) + { + rig_debug(RIG_DEBUG_ERR, "%s: unexpected reply '%s', len=%ld\n", __func__, buf, + (long)strlen(buf)); + return -RIG_EPROTO; + } + + switch (dcd_val) + { case 0: - *dcd = RIG_DCD_OFF; - break; - case 1: - *dcd = RIG_DCD_ON; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: unexpected reply '%s', len=%ld\n", __func__, buf, (long)strlen(buf)); - return -RIG_ERJCTED; - } + *dcd = RIG_DCD_OFF; + break; - return RIG_OK; + case 1: + *dcd = RIG_DCD_ON; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unexpected reply '%s', len=%ld\n", __func__, buf, + (long)strlen(buf)); + return -RIG_ERJCTED; + } + + return RIG_OK; } int tmd710_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { - char ackbuf[8]; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + char ackbuf[8]; + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - switch (op) { + switch (op) + { case RIG_OP_UP: - return kenwood_transaction(rig, "UP", ackbuf, sizeof(ackbuf)); + return kenwood_transaction(rig, "UP", ackbuf, sizeof(ackbuf)); + case RIG_OP_DOWN: - return kenwood_transaction(rig, "DW", ackbuf, sizeof(ackbuf)); + return kenwood_transaction(rig, "DW", ackbuf, sizeof(ackbuf)); + default: - return -RIG_EINVAL; - } + return -RIG_EINVAL; + } } /* @@ -2124,97 +2426,116 @@ int tmd710_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) */ int tmd710_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - char buf[10], ackbuf[20]; - int retval, v, l; - int vfonum; + char buf[10], ackbuf[20]; + int retval, v, l; + int vfonum; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - switch (level) { - case RIG_LEVEL_RFPOWER: - snprintf(buf, sizeof(buf), "PC %d", vfonum); - retval = kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); - if (retval != RIG_OK) + if (retval != RIG_OK) + { return retval; + } - retval = sscanf(ackbuf, "PC %d,%d", &v, &l); - if (retval != 2 || l < 0 || l > 2) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf); - return -RIG_ERJCTED; - } + switch (level) + { + case RIG_LEVEL_RFPOWER: + snprintf(buf, sizeof(buf), "PC %d", vfonum); + retval = kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); - /* range [0.0 ... 1.0] */ - val->f = (float) (l - TMD710_RF_POWER_MIN) / (float) (TMD710_RF_POWER_MAX - TMD710_RF_POWER_MIN); + if (retval != RIG_OK) + { + return retval; + } - // RF power needs to be inverted - val->f = 1.0f - val->f; - break; + retval = sscanf(ackbuf, "PC %d,%d", &v, &l); + + if (retval != 2 || l < 0 || l > 2) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf); + return -RIG_ERJCTED; + } + + /* range [0.0 ... 1.0] */ + val->f = (float)(l - TMD710_RF_POWER_MIN) / (float)(TMD710_RF_POWER_MAX - + TMD710_RF_POWER_MIN); + + // RF power needs to be inverted + val->f = 1.0f - val->f; + break; case RIG_LEVEL_SQL: - snprintf(buf, sizeof(buf), "SQ %d", vfonum); - retval = kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); - if (retval != RIG_OK) - return retval; + snprintf(buf, sizeof(buf), "SQ %d", vfonum); + retval = kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); - retval = sscanf(ackbuf, "SQ %X", &l); - if (retval != 1 || l < TMD710_SQL_MIN || l > TMD710_SQL_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf); - return -RIG_ERJCTED; - } + if (retval != RIG_OK) + { + return retval; + } - /* range [0.0 ... 1.0] */ - val->f = (float) (l - TMD710_SQL_MIN) / (float) (TMD710_SQL_MAX - TMD710_SQL_MIN); - break; + retval = sscanf(ackbuf, "SQ %X", &l); + + if (retval != 1 || l < TMD710_SQL_MIN || l > TMD710_SQL_MAX) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __func__, ackbuf); + return -RIG_ERJCTED; + } + + /* range [0.0 ... 1.0] */ + val->f = (float)(l - TMD710_SQL_MIN) / (float)(TMD710_SQL_MAX - TMD710_SQL_MIN); + break; default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported Level %ld\n", __func__, (long)level); - return -RIG_EINVAL; - } + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported Level %ld\n", __func__, (long)level); + return -RIG_EINVAL; + } - return RIG_OK; + return RIG_OK; } int tmd710_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - char buf[12], ackbuf[12]; - int vfonum; - int retval; + char buf[12], ackbuf[12]; + int vfonum; + int retval; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_resolve_vfo(rig, vfo, NULL, &vfonum); - switch (level) { + if (retval != RIG_OK) + { + return retval; + } + + switch (level) + { case RIG_LEVEL_RFPOWER: - // RF power needs to be inverted - snprintf(buf, sizeof(buf), "PC %d,%d", vfonum, - (int) ((1.0f - val.f) * (TMD710_RF_POWER_MAX - TMD710_RF_POWER_MIN) + TMD710_RF_POWER_MIN)); + // RF power needs to be inverted + snprintf(buf, sizeof(buf), "PC %d,%d", vfonum, + (int)((1.0f - val.f) * (TMD710_RF_POWER_MAX - TMD710_RF_POWER_MIN) + + TMD710_RF_POWER_MIN)); - return kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); + return kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); case RIG_LEVEL_SQL: - snprintf(buf, sizeof(buf), "SQ %d,%02X", vfonum, - (int) (val.f * (TMD710_SQL_MAX - TMD710_SQL_MIN) + TMD710_SQL_MIN)); - return kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); + snprintf(buf, sizeof(buf), "SQ %d,%02X", vfonum, + (int)(val.f * (TMD710_SQL_MAX - TMD710_SQL_MIN) + TMD710_SQL_MIN)); + return kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported Level %ld\n", __func__, (long)level); - return -RIG_EINVAL; - } + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported Level %ld\n", __func__, (long)level); + return -RIG_EINVAL; + } } static int tmd710_tburst(RIG *rig, int status) { - char ackbuf[8]; - return kenwood_transaction(rig, (status == 1) ? "TT" : "RX", ackbuf, sizeof(ackbuf)); + char ackbuf[8]; + return kenwood_transaction(rig, (status == 1) ? "TT" : "RX", ackbuf, + sizeof(ackbuf)); } /* @@ -2223,24 +2544,27 @@ static int tmd710_tburst(RIG *rig, int status) */ static int tmd710_get_kenwood_func(RIG *rig, const char *cmd, int *status) { - char buf[8]; - int retval, len, expected; + char buf[8]; + int retval, len, expected; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - len = strlen(cmd); - expected = len + 2; + len = strlen(cmd); + expected = len + 2; - retval = kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), expected); - if (retval != RIG_OK) { - return retval; - } + retval = kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), expected); - if (status) { - *status = (buf[len + 1] == '0') ? 0 : 1; - } + if (retval != RIG_OK) + { + return retval; + } - return RIG_OK; + if (status) + { + *status = (buf[len + 1] == '0') ? 0 : 1; + } + + return RIG_OK; }; /* @@ -2249,15 +2573,16 @@ static int tmd710_get_kenwood_func(RIG *rig, const char *cmd, int *status) */ static int tmd710_set_kenwood_func(RIG *rig, const char *cmd, int status) { - char buf[16], ackbuf[16]; + char buf[16], ackbuf[16]; - rig_debug(RIG_DEBUG_TRACE, "%s: cmd = %s, status = %d\n", __func__, cmd, status); + rig_debug(RIG_DEBUG_TRACE, "%s: cmd = %s, status = %d\n", __func__, cmd, + status); - strncpy(buf, cmd, sizeof(buf) - 2); - buf[sizeof(buf) - 1] = '\0'; - strncat(buf, status ? " 1" : " 0", sizeof(buf) - 1); + strncpy(buf, cmd, sizeof(buf) - 2); + buf[sizeof(buf) - 1] = '\0'; + strncat(buf, status ? " 1" : " 0", sizeof(buf) - 1); - return kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); + return kenwood_transaction(rig, buf, ackbuf, sizeof(ackbuf)); } /* @@ -2266,67 +2591,84 @@ static int tmd710_set_kenwood_func(RIG *rig, const char *cmd, int status) */ int tmd710_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) { - int retval; - int use_fo = 0, use_mu = 0; - tmd710_fo fo_struct; - tmd710_mu mu_struct; + int retval; + int use_fo = 0, use_mu = 0; + tmd710_fo fo_struct; + tmd710_mu mu_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called (0x%04lx)\n", __func__, (long)func); + rig_debug(RIG_DEBUG_TRACE, "%s: called (0x%04lx)\n", __func__, (long)func); - switch (func) { + switch (func) + { case RIG_FUNC_TONE: case RIG_FUNC_TSQL: case RIG_FUNC_REV: - use_fo = 1; - break; + use_fo = 1; + break; + case RIG_FUNC_ARO: case RIG_FUNC_AIP: case RIG_FUNC_RESUME: - use_mu = 1; - break; - } - - if (use_fo) { - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; + use_mu = 1; + break; } - } - if (use_mu) { - retval = tmd710_pull_mu(rig, &mu_struct); - if (retval != RIG_OK) { - return retval; + if (use_fo) + { + retval = tmd710_pull_fo(rig, vfo, &fo_struct); + + if (retval != RIG_OK) + { + return retval; + } } - } - switch (func) { + if (use_mu) + { + retval = tmd710_pull_mu(rig, &mu_struct); + + if (retval != RIG_OK) + { + return retval; + } + } + + switch (func) + { case RIG_FUNC_TONE: - *status = (fo_struct.tone != 0) ? 1 : 0; - break; + *status = (fo_struct.tone != 0) ? 1 : 0; + break; + case RIG_FUNC_TSQL: - *status = (fo_struct.ct != 0) ? 1 : 0; - break; + *status = (fo_struct.ct != 0) ? 1 : 0; + break; + case RIG_FUNC_REV: - *status = (fo_struct.reverse != 0) ? 1 : 0; - break; + *status = (fo_struct.reverse != 0) ? 1 : 0; + break; + case RIG_FUNC_LOCK: - return tmd710_get_kenwood_func(rig, "LK", status); - case RIG_FUNC_ARO: - *status = (mu_struct.auto_repeater_offset != 0) ? 1 : 0; - break; - case RIG_FUNC_AIP: - *status = ((mu_struct.vhf_aip != 0) || (mu_struct.uhf_aip != 0)) ? 1 : 0; - break; - case RIG_FUNC_RESUME: - *status = (mu_struct.scan_resume == TMD710_SCAN_RESUME_TIME) ? 1 : 0; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported function %#lx\n", __func__, (long)func); - return -RIG_EINVAL; - } + return tmd710_get_kenwood_func(rig, "LK", status); - return RIG_OK; + case RIG_FUNC_ARO: + *status = (mu_struct.auto_repeater_offset != 0) ? 1 : 0; + break; + + case RIG_FUNC_AIP: + *status = ((mu_struct.vhf_aip != 0) || (mu_struct.uhf_aip != 0)) ? 1 : 0; + break; + + case RIG_FUNC_RESUME: + *status = (mu_struct.scan_resume == TMD710_SCAN_RESUME_TIME) ? 1 : 0; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported function %#lx\n", __func__, + (long)func); + return -RIG_EINVAL; + } + + return RIG_OK; } /* @@ -2335,78 +2677,99 @@ int tmd710_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) */ int tmd710_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) { - int retval; - int use_fo = 0, use_mu = 0; - tmd710_fo fo_struct; - tmd710_mu mu_struct; + int retval; + int use_fo = 0, use_mu = 0; + tmd710_fo fo_struct; + tmd710_mu mu_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called (0x%04lx)\n", __func__, (long)func); + rig_debug(RIG_DEBUG_TRACE, "%s: called (0x%04lx)\n", __func__, (long)func); - switch (func) { + switch (func) + { case RIG_FUNC_TONE: case RIG_FUNC_TSQL: case RIG_FUNC_REV: - use_fo = 1; - break; + use_fo = 1; + break; + case RIG_FUNC_ARO: case RIG_FUNC_AIP: case RIG_FUNC_RESUME: - use_mu = 1; - break; - } - - if (use_fo) { - retval = tmd710_pull_fo(rig, vfo, &fo_struct); - if (retval != RIG_OK) { - return retval; + use_mu = 1; + break; } - } - if (use_mu) { - retval = tmd710_pull_mu(rig, &mu_struct); - if (retval != RIG_OK) { - return retval; + if (use_fo) + { + retval = tmd710_pull_fo(rig, vfo, &fo_struct); + + if (retval != RIG_OK) + { + return retval; + } } - } - switch (func) { + if (use_mu) + { + retval = tmd710_pull_mu(rig, &mu_struct); + + if (retval != RIG_OK) + { + return retval; + } + } + + switch (func) + { case RIG_FUNC_TONE: - fo_struct.tone = status ? 1 : 0; - break; + fo_struct.tone = status ? 1 : 0; + break; + case RIG_FUNC_TSQL: - fo_struct.ct = status ? 1 : 0; - break; + fo_struct.ct = status ? 1 : 0; + break; + case RIG_FUNC_REV: - fo_struct.reverse = status ? 1 : 0; - break; + fo_struct.reverse = status ? 1 : 0; + break; + case RIG_FUNC_ARO: - mu_struct.auto_repeater_offset = status ? 1 : 0; - break; + mu_struct.auto_repeater_offset = status ? 1 : 0; + break; + case RIG_FUNC_AIP: - mu_struct.vhf_aip = status ? 1 : 0; - mu_struct.uhf_aip = status ? 1 : 0; - break; + mu_struct.vhf_aip = status ? 1 : 0; + mu_struct.uhf_aip = status ? 1 : 0; + break; + case RIG_FUNC_RESUME: - mu_struct.scan_resume = status ? TMD710_SCAN_RESUME_TIME : TMD710_SCAN_RESUME_CARRIER; - break; + mu_struct.scan_resume = status ? TMD710_SCAN_RESUME_TIME : + TMD710_SCAN_RESUME_CARRIER; + break; + case RIG_FUNC_LOCK: - return tmd710_set_kenwood_func(rig, "LK", status); + return tmd710_set_kenwood_func(rig, "LK", status); + case RIG_FUNC_TBURST: - return tmd710_tburst(rig, status); + return tmd710_tburst(rig, status); + default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported function %#lx\n", __func__, (long)func); - return -RIG_EINVAL; - } + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported function %#lx\n", __func__, + (long)func); + return -RIG_EINVAL; + } - if (use_fo) { - return tmd710_push_fo(rig, vfo, &fo_struct); - } + if (use_fo) + { + return tmd710_push_fo(rig, vfo, &fo_struct); + } - if (use_mu) { - return tmd710_push_mu(rig, &mu_struct); - } + if (use_mu) + { + return tmd710_push_mu(rig, &mu_struct); + } - return -RIG_EINVAL; + return -RIG_EINVAL; } /* @@ -2415,85 +2778,112 @@ int tmd710_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) */ int tmd710_get_parm(RIG *rig, setting_t parm, value_t *val) { - int retval; - tmd710_mu mu_struct; + int retval; + tmd710_mu mu_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called (0x%04lx)\n", __func__, (long)parm); + rig_debug(RIG_DEBUG_TRACE, "%s: called (0x%04lx)\n", __func__, (long)parm); - retval = tmd710_pull_mu(rig, &mu_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_mu(rig, &mu_struct); - switch (parm) { + if (retval != RIG_OK) + { + return retval; + } + + switch (parm) + { case RIG_PARM_BEEP: - val->i = mu_struct.beep ? 1 : 0; - break; - case RIG_PARM_APO: - if (mu_struct.auto_power_off == TMD710_AUTO_POWER_OFF_180MIN) { - val->i = 180; - } else { - val->i = mu_struct.auto_power_off * 30; - } - break; - case RIG_PARM_BACKLIGHT: - val->f = ((float) mu_struct.brightness_level) / 8.0f; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported parm %#lx\n", __func__, (long)parm); - return -RIG_EINVAL; - } + val->i = mu_struct.beep ? 1 : 0; + break; - return RIG_OK; + case RIG_PARM_APO: + if (mu_struct.auto_power_off == TMD710_AUTO_POWER_OFF_180MIN) + { + val->i = 180; + } + else + { + val->i = mu_struct.auto_power_off * 30; + } + + break; + + case RIG_PARM_BACKLIGHT: + val->f = ((float) mu_struct.brightness_level) / 8.0f; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported parm %#lx\n", __func__, (long)parm); + return -RIG_EINVAL; + } + + return RIG_OK; } int tmd710_set_parm(RIG *rig, setting_t parm, value_t val) { - int retval; - tmd710_mu mu_struct; + int retval; + tmd710_mu mu_struct; - rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); - retval = tmd710_pull_mu(rig, &mu_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_mu(rig, &mu_struct); - switch (parm) { - case RIG_PARM_BEEP: - mu_struct.beep = val.i ? 1 : 0; - break; - case RIG_PARM_BACKLIGHT: - if (val.f < 0 || val.f > 1) { - return -RIG_EINVAL; - } - - mu_struct.brightness_level = (int) (val.f * 8); - break; - case RIG_PARM_APO: { - int value = 0; - - if (val.i > 120) { - value = TMD710_AUTO_POWER_OFF_180MIN; - } else if (val.i > 90) { - value = TMD710_AUTO_POWER_OFF_120MIN; - } else if (val.i > 60) { - value = TMD710_AUTO_POWER_OFF_90MIN; - } else if (val.i > 30) { - value = TMD710_AUTO_POWER_OFF_60MIN; - } else if (val.i > 0) { - value = TMD710_AUTO_POWER_OFF_30MIN; - } - - mu_struct.auto_power_off = value; - break; + if (retval != RIG_OK) + { + return retval; } - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported parm %#lx\n", __func__, (long)parm); - return -RIG_EINVAL; - } - return tmd710_push_mu(rig, &mu_struct); + switch (parm) + { + case RIG_PARM_BEEP: + mu_struct.beep = val.i ? 1 : 0; + break; + + case RIG_PARM_BACKLIGHT: + if (val.f < 0 || val.f > 1) + { + return -RIG_EINVAL; + } + + mu_struct.brightness_level = (int)(val.f * 8); + break; + + case RIG_PARM_APO: + { + int value = 0; + + if (val.i > 120) + { + value = TMD710_AUTO_POWER_OFF_180MIN; + } + else if (val.i > 90) + { + value = TMD710_AUTO_POWER_OFF_120MIN; + } + else if (val.i > 60) + { + value = TMD710_AUTO_POWER_OFF_90MIN; + } + else if (val.i > 30) + { + value = TMD710_AUTO_POWER_OFF_60MIN; + } + else if (val.i > 0) + { + value = TMD710_AUTO_POWER_OFF_30MIN; + } + + mu_struct.auto_power_off = value; + break; + } + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported parm %#lx\n", __func__, (long)parm); + return -RIG_EINVAL; + } + + return tmd710_push_mu(rig, &mu_struct); } /* @@ -2501,27 +2891,33 @@ int tmd710_set_parm(RIG *rig, setting_t parm, value_t val) * Assumes rig!=NULL, rig->state.priv!=NULL, val!=NULL * */ -int tmd710_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) { - int retval; - tmd710_mu mu_struct; +int tmd710_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) +{ + int retval; + tmd710_mu mu_struct; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - retval = tmd710_pull_mu(rig, &mu_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_mu(rig, &mu_struct); - switch (token) { + if (retval != RIG_OK) + { + return retval; + } + + switch (token) + { case TOK_LEVEL_EXT_DATA_BAND: - val->i = mu_struct.ext_data_band; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported ext level %ld\n", __func__, (long)token); - return -RIG_EINVAL; - } + val->i = mu_struct.ext_data_band; + break; - return RIG_OK; + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported ext level %ld\n", __func__, + (long)token); + return -RIG_EINVAL; + } + + return RIG_OK; } /* @@ -2529,32 +2925,41 @@ int tmd710_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) { * Assumes rig!=NULL, rig->state.priv!=NULL * */ -int tmd710_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) { - int retval; - tmd710_mu mu_struct; +int tmd710_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) +{ + int retval; + tmd710_mu mu_struct; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - retval = tmd710_pull_mu(rig, &mu_struct); - if (retval != RIG_OK) { - return retval; - } + retval = tmd710_pull_mu(rig, &mu_struct); - switch (token) { - case TOK_LEVEL_EXT_DATA_BAND: { - int v = val.i; - if (v != TMD710_EXT_DATA_BAND_A && v != TMD710_EXT_DATA_BAND_B - && v != TMD710_EXT_DATA_BAND_TXA_RXB && v != TMD710_EXT_DATA_BAND_TXB_RXA) { - return -RIG_EINVAL; - } - - mu_struct.ext_data_band = v; - break; + if (retval != RIG_OK) + { + return retval; } - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported ext level %ld\n", __func__, (long)token); - return -RIG_EINVAL; - } - return tmd710_push_mu(rig, &mu_struct); + switch (token) + { + case TOK_LEVEL_EXT_DATA_BAND: + { + int v = val.i; + + if (v != TMD710_EXT_DATA_BAND_A && v != TMD710_EXT_DATA_BAND_B + && v != TMD710_EXT_DATA_BAND_TXA_RXB && v != TMD710_EXT_DATA_BAND_TXB_RXA) + { + return -RIG_EINVAL; + } + + mu_struct.ext_data_band = v; + break; + } + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported ext level %ld\n", __func__, + (long)token); + return -RIG_EINVAL; + } + + return tmd710_push_mu(rig, &mu_struct); } diff --git a/rigs/kenwood/xg3.c b/rigs/kenwood/xg3.c index 8102dd210..15fc9d8d1 100644 --- a/rigs/kenwood/xg3.c +++ b/rigs/kenwood/xg3.c @@ -178,7 +178,7 @@ int xg3_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - priv = (struct xg3_priv_data *)calloc(1,sizeof(struct xg3_priv_data)); + priv = (struct xg3_priv_data *)calloc(1, sizeof(struct xg3_priv_data)); if (!priv) { diff --git a/rigs/kit/dds60.c b/rigs/kit/dds60.c index 0c0951559..8746f527f 100644 --- a/rigs/kit/dds60.c +++ b/rigs/kit/dds60.c @@ -171,7 +171,7 @@ int dds60_init(RIG *rig) { struct dds60_priv_data *priv; - rig->state.priv = (struct dds60_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct dds60_priv_data *)calloc(1, sizeof( struct dds60_priv_data)); if (!rig->state.priv) diff --git a/rigs/kit/drt1.c b/rigs/kit/drt1.c index fc1e119ae..c114f7452 100644 --- a/rigs/kit/drt1.c +++ b/rigs/kit/drt1.c @@ -171,7 +171,7 @@ int drt1_init(RIG *rig) { struct drt1_priv_data *priv; - rig->state.priv = (struct drt1_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct drt1_priv_data *)calloc(1, sizeof( struct drt1_priv_data)); if (!rig->state.priv) diff --git a/rigs/kit/dwt.c b/rigs/kit/dwt.c index 53174f461..f0ccfd51f 100644 --- a/rigs/kit/dwt.c +++ b/rigs/kit/dwt.c @@ -228,7 +228,7 @@ int dwtdll_init(RIG *rig) { struct dwtdll_priv_data *priv; - rig->state.priv = (struct dwtdll_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct dwtdll_priv_data *)calloc(1, sizeof( struct dwtdll_priv_data)); if (!rig->state.priv) diff --git a/rigs/kit/elektor304.c b/rigs/kit/elektor304.c index a862ff8ae..746efc18d 100644 --- a/rigs/kit/elektor304.c +++ b/rigs/kit/elektor304.c @@ -163,7 +163,7 @@ int elektor304_init(RIG *rig) { struct elektor304_priv_data *priv; - rig->state.priv = (struct elektor304_priv_data *)calloc(1,sizeof(struct + rig->state.priv = (struct elektor304_priv_data *)calloc(1, sizeof(struct elektor304_priv_data)); if (!rig->state.priv) diff --git a/rigs/kit/hiqsdr.c b/rigs/kit/hiqsdr.c index 039d15720..ecb3ab3ec 100644 --- a/rigs/kit/hiqsdr.c +++ b/rigs/kit/hiqsdr.c @@ -296,7 +296,7 @@ int hiqsdr_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct hiqsdr_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct hiqsdr_priv_data *)calloc(1, sizeof( struct hiqsdr_priv_data)); if (!rig->state.priv) diff --git a/rigs/pcr/pcr.c b/rigs/pcr/pcr.c index f6728e8b0..d09a36fb7 100644 --- a/rigs/pcr/pcr.c +++ b/rigs/pcr/pcr.c @@ -481,7 +481,8 @@ pcr_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct pcr_priv_data *) calloc(1,sizeof(struct pcr_priv_data)); + rig->state.priv = (struct pcr_priv_data *) calloc(1, + sizeof(struct pcr_priv_data)); if (!rig->state.priv) { diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c index c8959e482..f1f78dc85 100644 --- a/rigs/racal/ra37xx.c +++ b/rigs/racal/ra37xx.c @@ -219,7 +219,7 @@ int ra37xx_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ra37xx_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct ra37xx_priv_data *)calloc(1, sizeof( struct ra37xx_priv_data)); if (!rig->state.priv) diff --git a/rigs/racal/racal.c b/rigs/racal/racal.c index 7acaf009a..4a482cabf 100644 --- a/rigs/racal/racal.c +++ b/rigs/racal/racal.c @@ -124,7 +124,7 @@ int racal_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct racal_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct racal_priv_data *)calloc(1, sizeof( struct racal_priv_data)); if (!rig->state.priv) diff --git a/rigs/skanti/trp8255.c b/rigs/skanti/trp8255.c index 489fce292..a9aa21462 100644 --- a/rigs/skanti/trp8255.c +++ b/rigs/skanti/trp8255.c @@ -217,7 +217,7 @@ static int cu_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); - rig->state.priv = calloc(1,sizeof(struct cu_priv_data)); + rig->state.priv = calloc(1, sizeof(struct cu_priv_data)); if (!rig->state.priv) { diff --git a/rigs/tentec/jupiter.c b/rigs/tentec/jupiter.c index a305db7e0..bb54dec55 100644 --- a/rigs/tentec/jupiter.c +++ b/rigs/tentec/jupiter.c @@ -293,7 +293,7 @@ int tt538_init(RIG *rig) { struct tt538_priv_data *priv; - rig->state.priv = (struct tt538_priv_data *) calloc(1,sizeof( + rig->state.priv = (struct tt538_priv_data *) calloc(1, sizeof( struct tt538_priv_data)); if (!rig->state.priv) diff --git a/rigs/tentec/omnivii.c b/rigs/tentec/omnivii.c index ef52c2321..7e5cfa79b 100644 --- a/rigs/tentec/omnivii.c +++ b/rigs/tentec/omnivii.c @@ -295,7 +295,8 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, { return RIG_OK; } - if (retval == -RIG_ETIMEOUT) return retval; + + if (retval == -RIG_ETIMEOUT) { return retval; } rig_debug(RIG_DEBUG_ERR, "%s: read_string failed, try#%d\n", __func__, i + 1); } @@ -332,7 +333,7 @@ int tt588_init(RIG *rig) struct tt588_priv_data *priv; rig_debug(RIG_DEBUG_VERBOSE, "%s:\n", __func__); - rig->state.priv = (struct tt588_priv_data *) calloc(1,sizeof( + rig->state.priv = (struct tt588_priv_data *) calloc(1, sizeof( struct tt588_priv_data)); if (!rig->state.priv) diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index e01e6033c..b31c4edd1 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -225,7 +225,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int tt565_init(RIG *rig) { struct tt565_priv_data *priv; - rig->state.priv = (struct tt565_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct tt565_priv_data *)calloc(1, sizeof( struct tt565_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; } /* no memory available */ @@ -1210,20 +1210,23 @@ int tt565_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) if (rig->caps->rig_model == RIG_MODEL_TT599) { ii = (int)(val.f * 10); - if (ii > 9) ii=9; // cannot set NR level 10 apparently + + if (ii > 9) { ii = 9; } // cannot set NR level 10 apparently + SNPRINTF(cmdbuf, sizeof(cmdbuf), "*RMNN%c" EOM, ii); } else { - /* Noise Reduction (blanking) Float 0.0 - 1.0 - For some reason NB setting is supported in 1.372, but - NR, NOTCH, and AN are not. - FOR NOW -- RIG_LEVEL_NR controls the Orion NB setting - */ - SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cNB%d" EOM, - which_receiver(rig, vfo), - (int)(val.f * 9)); + /* Noise Reduction (blanking) Float 0.0 - 1.0 + For some reason NB setting is supported in 1.372, but + NR, NOTCH, and AN are not. + FOR NOW -- RIG_LEVEL_NR controls the Orion NB setting + */ + SNPRINTF(cmdbuf, sizeof(cmdbuf), "*R%cNB%d" EOM, + which_receiver(rig, vfo), + (int)(val.f * 9)); } + break; case RIG_LEVEL_VOXDELAY: @@ -1692,15 +1695,16 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; case RIG_LEVEL_NR: + /* RIG_LEVEL_NR controls Orion NB setting - TEMP */ if (rig->caps->rig_model == RIG_MODEL_TT599) { - SNPRINTF(cmdbuf, sizeof(cmdbuf), "?RMNN" EOM) + SNPRINTF(cmdbuf, sizeof(cmdbuf), "?RMNN" EOM) } else { - SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cNB" EOM, - which_receiver(rig, vfo)); + SNPRINTF(cmdbuf, sizeof(cmdbuf), "?R%cNB" EOM, + which_receiver(rig, vfo)); } lvl_len = sizeof(lvlbuf); @@ -1717,6 +1721,7 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) __func__, lvlbuf); return -RIG_EPROTO; } + sscanf(lvlbuf + 5, "%f", &val->f); val->f /= 10.0; break; diff --git a/rigs/tentec/paragon.c b/rigs/tentec/paragon.c index 9fd1e4a49..74085f49a 100644 --- a/rigs/tentec/paragon.c +++ b/rigs/tentec/paragon.c @@ -212,7 +212,7 @@ int tt585_init(RIG *rig) { struct tt585_priv_data *priv; - rig->state.priv = (struct tt585_priv_data *) calloc(1,sizeof( + rig->state.priv = (struct tt585_priv_data *) calloc(1, sizeof( struct tt585_priv_data)); if (!rig->state.priv) diff --git a/rigs/tentec/rx331.c b/rigs/tentec/rx331.c index 8403ee359..685394d79 100644 --- a/rigs/tentec/rx331.c +++ b/rigs/tentec/rx331.c @@ -295,7 +295,7 @@ int rx331_init(RIG *rig) { struct rx331_priv_data *priv; - rig->state.priv = (struct rx331_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct rx331_priv_data *)calloc(1, sizeof( struct rx331_priv_data)); if (!rig->state.priv) diff --git a/rigs/tentec/rx340.c b/rigs/tentec/rx340.c index a73108558..72bfbd6a2 100644 --- a/rigs/tentec/rx340.c +++ b/rigs/tentec/rx340.c @@ -239,7 +239,7 @@ int rx340_init(RIG *rig) { struct rx340_priv_data *priv; - priv = (struct rx340_priv_data *)calloc(1,sizeof(struct rx340_priv_data)); + priv = (struct rx340_priv_data *)calloc(1, sizeof(struct rx340_priv_data)); if (!priv) { diff --git a/rigs/tentec/tentec.c b/rigs/tentec/tentec.c index 3f53cb43a..0f03b7c90 100644 --- a/rigs/tentec/tentec.c +++ b/rigs/tentec/tentec.c @@ -109,7 +109,7 @@ int tentec_init(RIG *rig) { struct tentec_priv_data *priv; - rig->state.priv = (struct tentec_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct tentec_priv_data *)calloc(1, sizeof( struct tentec_priv_data)); if (!rig->state.priv) diff --git a/rigs/tentec/tt550.c b/rigs/tentec/tt550.c index a0ec77269..6c1cc4c75 100644 --- a/rigs/tentec/tt550.c +++ b/rigs/tentec/tt550.c @@ -360,7 +360,7 @@ tt550_init(RIG *rig) { struct tt550_priv_data *priv; - rig->state.priv = (struct tt550_priv_data *) calloc(1,sizeof( + rig->state.priv = (struct tt550_priv_data *) calloc(1, sizeof( struct tt550_priv_data)); if (!rig->state.priv) diff --git a/rigs/winradio/g303.c b/rigs/winradio/g303.c index 82c1ef548..f21c967ed 100644 --- a/rigs/winradio/g303.c +++ b/rigs/winradio/g303.c @@ -190,7 +190,7 @@ int g3_init(RIG *rig) { struct g3_priv_data *priv; - rig->state.priv = (struct g3_priv_data *)calloc(1,sizeof(struct g3_priv_data)); + rig->state.priv = (struct g3_priv_data *)calloc(1, sizeof(struct g3_priv_data)); if (!rig->state.priv) { diff --git a/rigs/winradio/g305.c b/rigs/winradio/g305.c index e90e9836c..138e99d21 100644 --- a/rigs/winradio/g305.c +++ b/rigs/winradio/g305.c @@ -191,7 +191,7 @@ int g3_init(RIG *rig) { struct g3_priv_data *priv; - rig->state.priv = (struct g3_priv_data *)calloc(1,sizeof(struct g3_priv_data)); + rig->state.priv = (struct g3_priv_data *)calloc(1, sizeof(struct g3_priv_data)); if (!rig->state.priv) { diff --git a/rigs/winradio/g313-posix.c b/rigs/winradio/g313-posix.c index 34d802547..5abf4ebff 100644 --- a/rigs/winradio/g313-posix.c +++ b/rigs/winradio/g313-posix.c @@ -112,7 +112,7 @@ int g313_init(RIG *rig) { struct g313_priv_data *priv; - priv = (struct g313_priv_data *)calloc(1,sizeof(struct g313_priv_data)); + priv = (struct g313_priv_data *)calloc(1, sizeof(struct g313_priv_data)); if (!priv) { diff --git a/rigs/winradio/g313-win.c b/rigs/winradio/g313-win.c index b7bc90b5b..2c22bb057 100644 --- a/rigs/winradio/g313-win.c +++ b/rigs/winradio/g313-win.c @@ -234,7 +234,7 @@ int g313_init(RIG *rig) { struct g313_priv_data *priv; - rig->state.priv = (struct g313_priv_data *)calloc(1,sizeof( + rig->state.priv = (struct g313_priv_data *)calloc(1, sizeof( struct g313_priv_data)); if (!rig->state.priv) diff --git a/rigs/wj/wj.c b/rigs/wj/wj.c index e4cb89ae1..5d585008c 100644 --- a/rigs/wj/wj.c +++ b/rigs/wj/wj.c @@ -211,7 +211,7 @@ int wj_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct wj_priv_data *)calloc(1,sizeof(struct wj_priv_data)); + rig->state.priv = (struct wj_priv_data *)calloc(1, sizeof(struct wj_priv_data)); if (!rig->state.priv) { diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index ed4c53d48..a366ffbfe 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -730,7 +730,9 @@ int ft897_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } int factor = 10; - if (p->fm_status[3]==1) factor = 100; + + if (p->fm_status[3] == 1) { factor = 100; } + *freq = from_bcd_be(p->fm_status, 8) * factor; return RIG_OK; diff --git a/rigs/yaesu/ft990v12.c b/rigs/yaesu/ft990v12.c old mode 100755 new mode 100644 index 59bcc6ce6..c9fdf4687 --- a/rigs/yaesu/ft990v12.c +++ b/rigs/yaesu/ft990v12.c @@ -30,11 +30,11 @@ * G0OAN */ /* MODIFIED VERSION for FT-990 with ROM v1.2 : June 2022 - * The standard version was written for FT-990 with ROM v1.3 and as the CAT spec was different to ROM v1.2 CAT + * The standard version was written for FT-990 with ROM v1.3 and as the CAT spec was different to ROM v1.2 CAT * would not work with the older ROM. This version enables ROM v1.2 to work although it is necessary to accept * that frequent polling functionality is not feasible with this older ROM. With ROM v1.2 polling fetches 1492 * bytes which at 4800 Baud takes about 3.8 seconds during which the FT-990 has a CAT blackout. The longest poll - * interval available in WSJT-X is 99 seconds. + * interval available in WSJT-X is 99 seconds. * Collaboration between M0EZP David Brewerton and K1MMI Edmund Hajjar */ @@ -117,19 +117,23 @@ static int ft990v12_open(RIG *rig); static int ft990v12_close(RIG *rig); static int ft990v12_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft990v12_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int ft990v12_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int ft990v12_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int ft990v12_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width); +static int ft990v12_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); static int ft990v12_set_vfo(RIG *rig, vfo_t vfo); static int ft990v12_get_vfo(RIG *rig, vfo_t *vfo); static int ft990v12_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int ft990v12_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); -static int ft990v12_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); -static int ft990v12_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift); +static int ft990v12_set_rptr_shift(RIG *rig, vfo_t vfo, + rptr_shift_t rptr_shift); +static int ft990v12_get_rptr_shift(RIG *rig, vfo_t vfo, + rptr_shift_t *rptr_shift); static int ft990v12_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs); static int ft990v12_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, - vfo_t tx_vfo); + vfo_t tx_vfo); static int ft990v12_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, - vfo_t *tx_vfo); + vfo_t *tx_vfo); static int ft990v12_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft990v12_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); static int ft990v12_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); @@ -137,29 +141,32 @@ static int ft990v12_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); static int ft990v12_set_parm(RIG *rig, setting_t parm, value_t val); static int ft990v12_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit); static int ft990v12_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit); -static int ft990v12_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +static int ft990v12_get_level(RIG *rig, vfo_t vfo, setting_t level, + value_t *val); static int ft990v12_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); static int ft990v12_set_mem(RIG *rig, vfo_t vfo, int ch); static int ft990v12_get_mem(RIG *rig, vfo_t vfo, int *ch); static int ft990v12_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan); static int ft990v12_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, - int read_only); + int read_only); /* Private helper function prototypes */ -static int ft990v12_get_update_data(RIG *rig, unsigned char ci, unsigned short ch); +static int ft990v12_get_update_data(RIG *rig, unsigned char ci, + unsigned short ch); static int ft990v12_send_static_cmd(RIG *rig, unsigned char ci); static int ft990v12_send_dynamic_cmd(RIG *rig, unsigned char ci, - unsigned char p1, unsigned char p2, - unsigned char p3, unsigned char p4); + unsigned char p1, unsigned char p2, + unsigned char p3, unsigned char p4); static int ft990v12_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq); static int ft990v12_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit); static const yaesu_cmd_set_t ncmd[] = -{ /* ci */ +{ + /* ci */ { 1, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* 00 00 Split (OFF) */ { 1, { 0x00, 0x00, 0x00, 0x01, 0x01 } }, /* 01 01 Split (On) */ { 0, { 0x00, 0x00, 0x00, 0x00, 0x02 } }, /* 02 02 Recall Memory */ @@ -218,7 +225,7 @@ static const yaesu_cmd_set_t ncmd[] = /* * Private data */ - // M0EZP: status 0=uni first call, 1=uni after first call +// M0EZP: status 0=uni first call, 1=uni after first call int ft990uni_get_freq_state = 0; struct ft990v12_priv_data @@ -242,7 +249,7 @@ struct ft990v12_priv_data .flags = 1, \ } -// Old FT990 ROM has to read all 1492 to get frequency +// Old FT990 ROM has to read all 1492 to get frequency // So for this model we just use the cache to read freq const struct rig_caps ft990uni_caps = { @@ -473,7 +480,8 @@ int ft990v12_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s: read pacing = %i\n", __func__, priv->pacing); - err = ft990v12_send_dynamic_cmd(rig, FT990_NATIVE_PACING, priv->pacing, 0, 0, 0); + err = ft990v12_send_dynamic_cmd(rig, FT990_NATIVE_PACING, priv->pacing, 0, 0, + 0); if (err != RIG_OK) { @@ -482,7 +490,7 @@ int ft990v12_open(RIG *rig) // Get current rig settings and status // err = ft990v12_get_update_data(rig, FT990_NATIVE_UPDATE_OP_DATA, 0); -// M0EZP read flags instead of update +// M0EZP read flags instead of update err = ft990v12_get_update_data(rig, FT990_NATIVE_READ_FLAGS, 0); if (err != RIG_OK) @@ -619,23 +627,26 @@ int ft990v12_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo = 0x%02x\n", __func__, vfo); - rig_debug(RIG_DEBUG_TRACE, "%s: ft990uni_get_freq_state = 0x%02x\n", __func__, ft990uni_get_freq_state); + rig_debug(RIG_DEBUG_TRACE, "%s: ft990uni_get_freq_state = 0x%02x\n", __func__, + ft990uni_get_freq_state); - if (ft990uni_get_freq_state < 2) { - // M0EZP: UNI first call needs UPDATE_ALL + if (ft990uni_get_freq_state < 2) + { + // M0EZP: UNI first call needs UPDATE_ALL ft990uni_get_freq_state = ft990uni_get_freq_state + 1; - + if (!rig) { return -RIG_EINVAL; } priv = (struct ft990v12_priv_data *)rig->state.priv; + if (vfo == RIG_VFO_CURR) { vfo = priv->current_vfo; rig_debug(RIG_DEBUG_TRACE, "%s: priv->current.vfo = 0x%02x\n", - __func__, vfo); + __func__, vfo); } switch (vfo) @@ -660,7 +671,7 @@ int ft990v12_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) default: return -RIG_EINVAL; } - + ci = FT990_NATIVE_UPDATE_ALL_DATA; /* M0EZP: inserted to override CI */ err = ft990v12_get_update_data(rig, ci, 0); @@ -673,9 +684,9 @@ int ft990v12_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) f = ((((p[0] << 8) + p[1]) << 8) + p[2]) * 10; rig_debug(RIG_DEBUG_TRACE, "%s: p0=0x%02x p1=0x%02x p2=0x%02x\n", - __func__, p[0], p[1], p[2]); + __func__, p[0], p[1], p[2]); rig_debug(RIG_DEBUG_TRACE, - "%s: freq = %"PRIfreq" Hz for vfo 0x%02x\n", __func__, f, vfo); + "%s: freq = %"PRIfreq" Hz for vfo 0x%02x\n", __func__, f, vfo); // Frequency sanity check if (f < 100000 || f > 30000000) @@ -686,11 +697,13 @@ int ft990v12_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) *freq = f; return RIG_OK; - } else { - // M0EZP: Uni use cache + } + else + { + // M0EZP: Uni use cache // *freq = vfo == RIG_VFO_A ? rig->state.cache.freqMainA : rig->state.cache.freqMainB; - return (RIG_OK); - } + return (RIG_OK); + } } /* @@ -1088,7 +1101,7 @@ int ft990v12_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs) __func__, bcd[0], bcd[1], bcd[2]); err = ft990v12_send_dynamic_cmd(rig, FT990_NATIVE_RPTR_OFFSET, 0, - bcd[2], bcd[1], bcd[0]); + bcd[2], bcd[1], bcd[0]); if (err != RIG_OK) { @@ -1861,7 +1874,7 @@ int ft990v12_set_parm(RIG *rig, setting_t parm, value_t val) { case RIG_PARM_BACKLIGHT: err = ft990v12_send_dynamic_cmd(rig, FT990_NATIVE_DIM_LEVEL, - (unsigned char)(0x0d * val.f), 0, 0, 0); + (unsigned char)(0x0d * val.f), 0, 0, 0); break; default: @@ -2282,7 +2295,7 @@ int ft990v12_set_vfo(RIG *rig, vfo_t vfo) if (vfo == RIG_VFO_MEM) { err = ft990v12_send_dynamic_cmd(rig, ci, - priv->update_data.channelnumber + 1, 0, 0, 0); + priv->update_data.channelnumber + 1, 0, 0, 0); rig_debug(RIG_DEBUG_TRACE, "%s: set mem channel = 0x%02x\n", __func__, priv->update_data.channelnumber + 1); @@ -2334,8 +2347,8 @@ int ft990v12_get_vfo(RIG *rig, vfo_t *vfo) priv = (struct ft990v12_priv_data *)rig->state.priv; - /* Get flags for VFO status - err = ft990v12_get_update_data(rig, FT990_NATIVE_READ_FLAGS, 0); + /* Get flags for VFO status + err = ft990v12_get_update_data(rig, FT990_NATIVE_READ_FLAGS, 0); if (err != RIG_OK) { @@ -2590,7 +2603,7 @@ int ft990v12_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) if (op == RIG_OP_TO_VFO || op == RIG_OP_FROM_VFO) err = ft990v12_send_dynamic_cmd(rig, ci, - priv->update_data.channelnumber + 1, 0, 0, 0); + priv->update_data.channelnumber + 1, 0, 0, 0); else { err = ft990v12_send_static_cmd(rig, ci); @@ -3031,7 +3044,8 @@ int ft990v12_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) if (chan->split & RIG_SPLIT_ON) { // Get data for the transmit VFO - p = (ft990v12_op_data_t *) &priv->update_data.current_front; /* M0EZP: was current_rear */ + p = (ft990v12_op_data_t *) + &priv->update_data.current_front; /* M0EZP: was current_rear */ /* FT1000D @@ -3267,95 +3281,77 @@ int ft990v12_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) priv = (struct ft990v12_priv_data *)rig->state.priv; switch (ci) + { + case FT990_NATIVE_UPDATE_ALL_DATA: + case FT990_NATIVE_UPDATE_MEM_CHNL: + case FT990_NATIVE_UPDATE_OP_DATA: + case FT990_NATIVE_UPDATE_VFO_DATA: + case FT990_NATIVE_UPDATE_MEM_CHNL_DATA: + if (ft990uni_get_freq_state < 2) { - case FT990_NATIVE_UPDATE_ALL_DATA: - case FT990_NATIVE_UPDATE_MEM_CHNL: - case FT990_NATIVE_UPDATE_OP_DATA: - case FT990_NATIVE_UPDATE_VFO_DATA: - case FT990_NATIVE_UPDATE_MEM_CHNL_DATA: - if (ft990uni_get_freq_state < 2) { - // - if (ci == FT990_NATIVE_UPDATE_MEM_CHNL_DATA) - // P4 = 0x01 to 0x5a for channel 1 - 90 - { - /* err = ft990v12_send_dynamic_cmd(rig, ci, 4, 0, 0, ch); - M0EZP: dont send command, rely on the assignment from memory below*/ - } else { - // err = RIG_OK; K1MMI - err = ft990v12_send_static_cmd(rig, ci); // K1MMI: only send for ALL DATA 1492 bytes or READ FLAGS 5 bytes - } - - - if (err != RIG_OK) - { - return err; - } - - switch (ci) - { - case FT990_NATIVE_UPDATE_ALL_DATA: - rl = FT990_ALL_DATA_LENGTH; // K1MMI: prepare to receive 1492 bytes back - p = (unsigned char *)&priv->update_data; // K1MMI: This seems like 1492 will be saved here - - n = read_block(&rig->state.rigport, p, rl); /* M0EZP: copied here from below */ - return RIG_OK; - break; - - case FT990_NATIVE_UPDATE_MEM_CHNL: - // we already have the channelnumber in the previously saved 1492 bytes - p = (unsigned char *) &priv->update_data.channelnumber; - rl = FT990_MEM_CHNL_LENGTH; // 1 - break; - - case FT990_NATIVE_UPDATE_OP_DATA: - // we already have the current OP and VFOA in the 1492 bytes - p = (unsigned char *) &priv->update_data.current_front; - rl = FT990_OP_DATA_LENGTH; // 32 - break; - - case FT990_NATIVE_UPDATE_VFO_DATA: - // we already have the VFOA and VFOB in the 1492 bytes - p = (unsigned char *) &priv->update_data.vfoa; - rl = FT990_VFO_DATA_LENGTH; // 32 - break; - - case FT990_NATIVE_UPDATE_MEM_CHNL_DATA: - // we already have the 16 structure for the memory channel number - p = (unsigned char *) &priv->update_data.channel[ch]; - rl = FT990_MEM_CHNL_DATA_LENGTH; // 16 - break; - default: - // M0EZP: shouldn't be here! - rig_debug(RIG_DEBUG_TRACE, "%s: Default clause ci 0x%02x\n", __func__, ci); // M0EZP - return -RIG_EINVAL; - } - - ft990uni_get_freq_state = ft990uni_get_freq_state + 1; - - if (n < 0) - { - return n; /* die returning read_block error */ - } - - rig_debug(RIG_DEBUG_TRACE, "%s: read %i bytes\n", __func__, n); - - memcpy(&priv->update_data, p, FT990_ALL_DATA_LENGTH); - return RIG_OK; - } else { - return RIG_OK; + // + if (ci == FT990_NATIVE_UPDATE_MEM_CHNL_DATA) + // P4 = 0x01 to 0x5a for channel 1 - 90 + { + /* err = ft990v12_send_dynamic_cmd(rig, ci, 4, 0, 0, ch); + M0EZP: dont send command, rely on the assignment from memory below*/ + } + else + { + // err = RIG_OK; K1MMI + err = ft990v12_send_static_cmd(rig, + ci); // K1MMI: only send for ALL DATA 1492 bytes or READ FLAGS 5 bytes } - case FT990_NATIVE_READ_FLAGS: - rig_debug(RIG_DEBUG_TRACE, "%s: passed ci 0x%02x\n", __func__, ci); - err = ft990v12_send_static_cmd(rig, ci); // K1MMI: only send for ALL DATA 1492 bytes + if (err != RIG_OK) { return err; } - p = (unsigned char *)&priv->update_data; - rl = FT990_STATUS_FLAGS_LENGTH; // 5 - n = read_block(&rig->state.rigport, (unsigned char*)&temp, rl); /* M0EZP: copied here from below */ + switch (ci) + { + case FT990_NATIVE_UPDATE_ALL_DATA: + rl = FT990_ALL_DATA_LENGTH; // K1MMI: prepare to receive 1492 bytes back + p = (unsigned char *) + &priv->update_data; // K1MMI: This seems like 1492 will be saved here + + n = read_block(&rig->state.rigport, p, rl); /* M0EZP: copied here from below */ + return RIG_OK; + break; + + case FT990_NATIVE_UPDATE_MEM_CHNL: + // we already have the channelnumber in the previously saved 1492 bytes + p = (unsigned char *) &priv->update_data.channelnumber; + rl = FT990_MEM_CHNL_LENGTH; // 1 + break; + + case FT990_NATIVE_UPDATE_OP_DATA: + // we already have the current OP and VFOA in the 1492 bytes + p = (unsigned char *) &priv->update_data.current_front; + rl = FT990_OP_DATA_LENGTH; // 32 + break; + + case FT990_NATIVE_UPDATE_VFO_DATA: + // we already have the VFOA and VFOB in the 1492 bytes + p = (unsigned char *) &priv->update_data.vfoa; + rl = FT990_VFO_DATA_LENGTH; // 32 + break; + + case FT990_NATIVE_UPDATE_MEM_CHNL_DATA: + // we already have the 16 structure for the memory channel number + p = (unsigned char *) &priv->update_data.channel[ch]; + rl = FT990_MEM_CHNL_DATA_LENGTH; // 16 + break; + + default: + // M0EZP: shouldn't be here! + rig_debug(RIG_DEBUG_TRACE, "%s: Default clause ci 0x%02x\n", __func__, + ci); // M0EZP + return -RIG_EINVAL; + } + + ft990uni_get_freq_state = ft990uni_get_freq_state + 1; if (n < 0) { @@ -3364,17 +3360,50 @@ int ft990v12_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) rig_debug(RIG_DEBUG_TRACE, "%s: read %i bytes\n", __func__, n); - memcpy(&priv->update_data, p, FT990_STATUS_FLAGS_LENGTH - 2); /* just overwrite first 3 bytes */ - + memcpy(&priv->update_data, p, FT990_ALL_DATA_LENGTH); return RIG_OK; - break; - - default: - // M0EZP: shouldn't be here! - rig_debug(RIG_DEBUG_TRACE, "%s: Default clause ci 0x%02x\n", __func__, ci); // M0EZP - return -RIG_EINVAL; } + else + { + return RIG_OK; + } + + case FT990_NATIVE_READ_FLAGS: + rig_debug(RIG_DEBUG_TRACE, "%s: passed ci 0x%02x\n", __func__, ci); + err = ft990v12_send_static_cmd(rig, + ci); // K1MMI: only send for ALL DATA 1492 bytes + + if (err != RIG_OK) + { + return err; + } + + p = (unsigned char *)&priv->update_data; + rl = FT990_STATUS_FLAGS_LENGTH; // 5 + n = read_block(&rig->state.rigport, (unsigned char *)&temp, + rl); /* M0EZP: copied here from below */ + + if (n < 0) + { + return n; /* die returning read_block error */ + } + + rig_debug(RIG_DEBUG_TRACE, "%s: read %i bytes\n", __func__, n); + + memcpy(&priv->update_data, p, + FT990_STATUS_FLAGS_LENGTH - 2); /* just overwrite first 3 bytes */ + return RIG_OK; + break; + + default: + // M0EZP: shouldn't be here! + rig_debug(RIG_DEBUG_TRACE, "%s: Default clause ci 0x%02x\n", __func__, + ci); // M0EZP + return -RIG_EINVAL; + } + + return RIG_OK; } /* @@ -3430,8 +3459,8 @@ int ft990v12_send_static_cmd(RIG *rig, unsigned char ci) * otherwise returns error from called functiion */ int ft990v12_send_dynamic_cmd(RIG *rig, unsigned char ci, - unsigned char p1, unsigned char p2, - unsigned char p3, unsigned char p4) + unsigned char p1, unsigned char p2, + unsigned char p3, unsigned char p4) { struct ft990v12_priv_data *priv; int err; diff --git a/rigs/yaesu/ft991.c b/rigs/yaesu/ft991.c index 9e2ca3165..52765118e 100644 --- a/rigs/yaesu/ft991.c +++ b/rigs/yaesu/ft991.c @@ -414,7 +414,8 @@ ft991_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) if (rig->state.cache.freqMainB == tx_freq) { - rig_debug(RIG_DEBUG_TRACE, "%s: freq %.0f already set on VFOB\n", __func__, tx_freq); + rig_debug(RIG_DEBUG_TRACE, "%s: freq %.0f already set on VFOB\n", __func__, + tx_freq); return RIG_OK; } @@ -590,7 +591,8 @@ static int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, if (rig->state.cache.modeMainB == tx_mode) { - rig_debug(RIG_DEBUG_TRACE, "%s: mode %s already set on VFOB\n", __func__, rig_strrmode(tx_mode)); + rig_debug(RIG_DEBUG_TRACE, "%s: mode %s already set on VFOB\n", __func__, + rig_strrmode(tx_mode)); return RIG_OK; } diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 2ef422eb6..b7fb41ca2 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -601,9 +601,11 @@ int newcat_open(RIG *rig) int err; // set the CAT TIME OUT TIMER to 100ms SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX0331"); + if (RIG_OK != (err = newcat_set_cmd(rig))) { - rig_debug(RIG_DEBUG_ERR, "%s: FTDX5000 CAT RATE error: %s\n", __func__, rigerror(err)); + rig_debug(RIG_DEBUG_ERR, "%s: FTDX5000 CAT RATE error: %s\n", __func__, + rigerror(err)); } } @@ -750,9 +752,11 @@ int newcat_60m_exception(RIG *rig, freq_t freq) // can we improve this to set memory mode and pick the memory slot? if (is_ftdx10 && freq > 5.2 && freq < 5.5) { - rig_debug(RIG_DEBUG_VERBOSE, "%s: 60M exception ignoring freq/mode commands\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s: 60M exception ignoring freq/mode commands\n", + __func__); return 1; } + return 0; } @@ -767,7 +771,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) ENTERFUNC; - if (newcat_60m_exception(rig,freq)) RETURNFUNC(RIG_OK); // we don't set freq in this case + if (newcat_60m_exception(rig, freq)) { RETURNFUNC(RIG_OK); } // we don't set freq in this case if (!newcat_valid_command(rig, "FA")) { @@ -1286,7 +1290,7 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) ENTERFUNC; - if (newcat_60m_exception(rig,rig->state.cache.freqMainA)) RETURNFUNC(RIG_OK); // we don't set mode in this case + if (newcat_60m_exception(rig, rig->state.cache.freqMainA)) { RETURNFUNC(RIG_OK); } // we don't set mode in this case if (!newcat_valid_command(rig, "MD")) { @@ -1340,10 +1344,15 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { RETURNFUNC(err); } + if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) - rig->state.cache.modeMainA = mode; + { + rig->state.cache.modeMainA = mode; + } else - rig->state.cache.modeMainB = mode; + { + rig->state.cache.modeMainB = mode; + } if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(err); } @@ -1701,11 +1710,13 @@ int newcat_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str); err = newcat_set_cmd(rig); break; + case RIG_PTT_ON_DATA: SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX1031;"); rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str); err = newcat_set_cmd(rig); break; + case RIG_PTT_ON: /* Build the command string */ SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s", txon); @@ -2378,7 +2389,8 @@ int newcat_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tmp_width; int err; - rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, tx_mode=%s, tx_width=%d\n", __func__, rig_strvfo(vfo), rig_strrmode(tx_mode), (int)tx_width); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, tx_mode=%s, tx_width=%d\n", __func__, + rig_strvfo(vfo), rig_strrmode(tx_mode), (int)tx_width); err = newcat_get_mode(rig, RIG_VFO_B, &tmp_mode, &tmp_width); if (err < 0) @@ -2398,10 +2410,15 @@ int newcat_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, { RETURNFUNC(err); } + if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) - rig->state.cache.modeMainA = tx_mode; + { + rig->state.cache.modeMainA = tx_mode; + } else - rig->state.cache.modeMainB = tx_mode; + { + rig->state.cache.modeMainB = tx_mode; + } RETURNFUNC(-RIG_ENAVAIL); diff --git a/rotators/ars/ars.c b/rotators/ars/ars.c index 60e4ea7b1..c8909f093 100644 --- a/rotators/ars/ars.c +++ b/rotators/ars/ars.c @@ -147,7 +147,8 @@ ars_init(ROT *rot) return -RIG_EINVAL; } - rot->state.priv = (struct ars_priv_data *)calloc(1,sizeof(struct ars_priv_data)); + rot->state.priv = (struct ars_priv_data *)calloc(1, + sizeof(struct ars_priv_data)); if (!rot->state.priv) { diff --git a/rotators/heathkit/hd1780.c b/rotators/heathkit/hd1780.c index 66175c2d2..6977758aa 100644 --- a/rotators/heathkit/hd1780.c +++ b/rotators/heathkit/hd1780.c @@ -118,7 +118,7 @@ static int hd1780_rot_init(ROT *rot) } rot->state.priv = (struct hd1780_rot_priv_data *) - calloc(1,sizeof(struct hd1780_rot_priv_data)); + calloc(1, sizeof(struct hd1780_rot_priv_data)); if (!rot->state.priv) { diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index ae204f07e..6536d0dea 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -364,7 +364,7 @@ static int rotorez_rot_init(ROT *rot) } rot->state.priv = (struct rotorez_rot_priv_data *) - calloc(1,sizeof(struct rotorez_rot_priv_data)); + calloc(1, sizeof(struct rotorez_rot_priv_data)); if (!rot->state.priv) { diff --git a/rotators/spid/spid.c b/rotators/spid/spid.c index 080114054..1c312200e 100644 --- a/rotators/spid/spid.c +++ b/rotators/spid/spid.c @@ -55,7 +55,7 @@ static int spid_rot_init(ROT *rot) { struct spid_rot2prog_priv_data *priv; - priv = (struct spid_rot2prog_priv_data *)calloc(1,sizeof(struct + priv = (struct spid_rot2prog_priv_data *)calloc(1, sizeof(struct spid_rot2prog_priv_data)); if (!priv) diff --git a/rotators/ts7400/ts7400.c b/rotators/ts7400/ts7400.c index dbcb590c5..f32a8dd4c 100644 --- a/rotators/ts7400/ts7400.c +++ b/rotators/ts7400/ts7400.c @@ -51,7 +51,7 @@ static int ts7400_rot_init(ROT *rot) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rot->state.priv = (struct ts7400_rot_priv_data *) - calloc(1,sizeof(struct ts7400_rot_priv_data)); + calloc(1, sizeof(struct ts7400_rot_priv_data)); if (!rot->state.priv) { diff --git a/security/md5.c b/security/md5.c index f04c0dca6..2af6bfa0b 100644 --- a/security/md5.c +++ b/security/md5.c @@ -2,7 +2,7 @@ char *make_digest(const unsigned char *digest, int len) /* {{{ */ { - char *md5str = (char *) calloc(1,sizeof(char) * (len * 2 + 1)); + char *md5str = (char *) calloc(1, sizeof(char) * (len * 2 + 1)); static const char hexits[17] = "0123456789abcdef"; int i; diff --git a/simulators/simkenwood.c b/simulators/simkenwood.c index 90d0dd310..d30b9a776 100644 --- a/simulators/simkenwood.c +++ b/simulators/simkenwood.c @@ -108,6 +108,7 @@ int main(int argc, char *argv[]) buf[0] = 0; if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); } + // else { return 0; } if (strcmp(buf, "RM5;") == 0) @@ -137,7 +138,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); usleep(50 * 1000); pbuf = "IF000503130001000+0000000000030000000;"; - sprintf(ifbuf,"IF%011d0001000+0000000000030000000;",freqa); + sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa); //pbuf = "IF00010138698 +00000000002000000 ; n = write(fd, ifbuf, strlen(pbuf)); // printf("n=%d\n", n); diff --git a/src/amp_reg.c b/src/amp_reg.c index 6fa9b0e12..998a58ffd 100644 --- a/src/amp_reg.c +++ b/src/amp_reg.c @@ -152,7 +152,7 @@ int HAMLIB_API amp_register(const struct amp_caps *caps) #endif - p = (struct amp_list *)calloc(1,sizeof(struct amp_list)); + p = (struct amp_list *)calloc(1, sizeof(struct amp_list)); if (!p) { diff --git a/src/amplifier.c b/src/amplifier.c index a841657dd..fc06cc02f 100644 --- a/src/amplifier.c +++ b/src/amplifier.c @@ -87,7 +87,7 @@ static struct opened_amp_l *opened_amp_list = { NULL }; static int add_opened_amp(AMP *amp) { struct opened_amp_l *p; - p = (struct opened_amp_l *)calloc(1,sizeof(struct opened_amp_l)); + p = (struct opened_amp_l *)calloc(1, sizeof(struct opened_amp_l)); if (!p) { diff --git a/src/cache.c b/src/cache.c index 00bca1598..b10849e71 100644 --- a/src/cache.c +++ b/src/cache.c @@ -46,7 +46,8 @@ int rig_set_cache_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (vfo == RIG_VFO_NONE || vfo == RIG_VFO_CURR) { vfo = RIG_VFO_A; } if (vfo == RIG_VFO_SUB && rig->state.cache.satmode) { vfo = RIG_VFO_SUB_A; }; - if (vfo == RIG_VFO_OTHER) vfo = vfo_fixup(rig, vfo, rig->state.cache.split); + + if (vfo == RIG_VFO_OTHER) { vfo = vfo_fixup(rig, vfo, rig->state.cache.split); } switch (vfo) { diff --git a/src/mem.c b/src/mem.c index 23c0fdea5..8aa51e574 100644 --- a/src/mem.c +++ b/src/mem.c @@ -253,7 +253,7 @@ static int generic_retr_extl(RIG *rig, if (chan->ext_levels == NULL) { - p = chan->ext_levels = calloc(1,2 * sizeof(struct ext_list)); + p = chan->ext_levels = calloc(1, 2 * sizeof(struct ext_list)); } else { diff --git a/src/misc.c b/src/misc.c index 4a6e3e983..1bb82951d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2094,6 +2094,7 @@ int HAMLIB_API rig_flush(hamlib_port_t *port) { return RIG_OK; } + if (port->type.rig == RIG_PORT_NETWORK || port->type.rig == RIG_PORT_UDP_NETWORK) { diff --git a/src/network.c b/src/network.c index 150c1146f..ecd963bc9 100644 --- a/src/network.c +++ b/src/network.c @@ -976,7 +976,8 @@ int network_multicast_publisher_start(RIG *rig, const char *multicast_addr, ENTERFUNC; - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):multicast address=%s, port=%d\n", __FILE__, __LINE__, + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):multicast address=%s, port=%d\n", __FILE__, + __LINE__, multicast_addr, multicast_port); if (strcmp(multicast_addr, "0.0.0.0") == 0) diff --git a/src/register.c b/src/register.c index a533781c8..c9aa48418 100644 --- a/src/register.c +++ b/src/register.c @@ -205,7 +205,7 @@ int HAMLIB_API rig_register(const struct rig_caps *caps) caps->rig_model); #endif - p = (struct rig_list *)calloc(1,sizeof(struct rig_list)); + p = (struct rig_list *)calloc(1, sizeof(struct rig_list)); if (!p) { @@ -305,12 +305,14 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model) } #if 0 // this stopped a 2nd rig_init call with a valid model to fail -- reversing + if (n > 1) { rig_debug(RIG_DEBUG_ERR, "%s: rig model %u not found and rig count=%d\n", __func__, rig_model, n); return -RIG_ENAVAIL; } + #endif be_idx = rig_lookup_backend(rig_model); diff --git a/src/rig.c b/src/rig.c index 73588ac5c..41530d97a 100644 --- a/src/rig.c +++ b/src/rig.c @@ -240,7 +240,7 @@ static int add_opened_rig(RIG *rig) { struct opened_rig_l *p; - p = (struct opened_rig_l *)calloc(1,sizeof(struct opened_rig_l)); + p = (struct opened_rig_l *)calloc(1, sizeof(struct opened_rig_l)); if (!p) { @@ -850,7 +850,7 @@ int HAMLIB_API rig_open(RIG *rig) rig_settings_load_all(NULL); // load default .hamlib_settings // Read in our settings - char *cwd = calloc(1,4096); + char *cwd = calloc(1, 4096); if (getcwd(cwd, 4096) == NULL) { @@ -859,11 +859,12 @@ int HAMLIB_API rig_open(RIG *rig) else { rig_debug(RIG_DEBUG_VERBOSE, "%s: cwd=%s\n", __func__, cwd); - char *path = calloc(1,4096); + char *path = calloc(1, 4096); extern char *settings_file; char *xdgpath = getenv("XDG_CONFIG_HOME"); settings_file = "hamlib_settings"; + if (xdgpath) { sprintf(path, "%s/%s/%s", xdgpath, cwd, settings_file); @@ -1243,6 +1244,7 @@ int HAMLIB_API rig_open(RIG *rig) */ int retry_save = rs->rigport.retry; rs->rigport.retry = 1; + if (caps->rig_open != NULL) { status = caps->rig_open(rig); @@ -1317,26 +1319,30 @@ int HAMLIB_API rig_open(RIG *rig) // freq_t freq; // if (caps->get_freq) rig_get_freq(rig, RIG_VFO_A, &freq); // if (caps->get_freq) rig_get_freq(rig, RIG_VFO_B, &freq); - + // prime the freq and mode settings // don't care about the return here -- if it doesn't work so be it freq_t freq; + if (rig->caps->get_freq) { int retval = rig_get_freq(rig, RIG_VFO_A, &freq); + if (retval == RIG_OK && rig->caps->rig_model != RIG_MODEL_F6K) { vfo_t tx_vfo; split_t split; rig_get_freq(rig, RIG_VFO_B, &freq); rig_get_split_vfo(rig, RIG_VFO_RX, &tx_vfo, &split); - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Current split=%d, tx_vfo=%s\n", __func__, __LINE__, split, rig_strvfo(tx_vfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Current split=%d, tx_vfo=%s\n", __func__, + __LINE__, split, rig_strvfo(tx_vfo)); rmode_t mode; pbwidth_t width; rig_get_mode(rig, RIG_VFO_A, &mode, &width); rig_get_mode(rig, RIG_VFO_B, &mode, &width); } } + rs->rigport.retry = retry_save; memcpy(&rs->rigport_deprecated, &rs->rigport, sizeof(hamlib_port_t_deprecated)); @@ -2198,7 +2204,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } rig_get_lock_mode(rig, &locked_mode); - if (locked_mode) { return(RIG_OK); } + + if (locked_mode) { return (RIG_OK); } // do not mess with mode while PTT is on if (rig->state.cache.ptt) @@ -2256,7 +2263,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } curr_vfo = rig->state.current_vfo; - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): curr_vfo=%s, vfo=%s\n", __func__, __LINE__, rig_strvfo(curr_vfo), rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): curr_vfo=%s, vfo=%s\n", __func__, + __LINE__, rig_strvfo(curr_vfo), rig_strvfo(vfo)); HAMLIB_TRACE; retcode = caps->set_vfo(rig, vfo); @@ -2656,7 +2664,7 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) if (retcode != RIG_OK) { rig_debug(RIG_DEBUG_WARN, "%s: rig_get_vfo error=%s\n", __func__, - rigerror(retcode)); + rigerror(retcode)); } if (curr_vfo == vfo) { RETURNFUNC(RIG_OK); } @@ -4184,14 +4192,18 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, // we check both VFOs are in the same tx mode -- then we can ignore // this could be make more intelligent but this should cover all cases where we can skip this - if (tx_mode == rig->state.cache.modeMainA && tx_mode == rig->state.cache.modeMainB) + if (tx_mode == rig->state.cache.modeMainA + && tx_mode == rig->state.cache.modeMainB) { - rig_debug(RIG_DEBUG_TRACE, "%s: mode already %s so no change required\n", __func__, rig_strrmode(tx_mode)); + rig_debug(RIG_DEBUG_TRACE, "%s: mode already %s so no change required\n", + __func__, rig_strrmode(tx_mode)); RETURNFUNC(RIG_OK); } else { - rig_debug(RIG_DEBUG_TRACE, "%s: mode %s is different from A=%s and B=%s\n", __func__, rig_strrmode(tx_mode), rig_strrmode(rig->state.cache.modeMainA), rig_strrmode(rig->state.cache.modeMainB)); + rig_debug(RIG_DEBUG_TRACE, "%s: mode %s is different from A=%s and B=%s\n", + __func__, rig_strrmode(tx_mode), rig_strrmode(rig->state.cache.modeMainA), + rig_strrmode(rig->state.cache.modeMainB)); } // do not mess with mode while PTT is on @@ -4347,9 +4359,13 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, rig_set_split_vfo(rig, rx_vfo, RIG_SPLIT_ON, tx_vfo); if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) - rig->state.cache.modeMainA = tx_mode; + { + rig->state.cache.modeMainA = tx_mode; + } else - rig->state.cache.modeMainB = tx_mode; + { + rig->state.cache.modeMainB = tx_mode; + } ELAPSED2; diff --git a/src/rot_reg.c b/src/rot_reg.c index dc016f4f1..13e152c59 100644 --- a/src/rot_reg.c +++ b/src/rot_reg.c @@ -204,7 +204,7 @@ int HAMLIB_API rot_register(const struct rot_caps *caps) #endif - p = (struct rot_list *)calloc(1,sizeof(struct rot_list)); + p = (struct rot_list *)calloc(1, sizeof(struct rot_list)); if (!p) { diff --git a/src/rotator.c b/src/rotator.c index 855e179fc..93abc0fd0 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -108,7 +108,7 @@ static struct opened_rot_l *opened_rot_list = { NULL }; static int add_opened_rot(ROT *rot) { struct opened_rot_l *p; - p = (struct opened_rot_l *)calloc(1,sizeof(struct opened_rot_l)); + p = (struct opened_rot_l *)calloc(1, sizeof(struct opened_rot_l)); if (!p) { diff --git a/src/serial.c b/src/serial.c index 1441e79a6..62446a354 100644 --- a/src/serial.c +++ b/src/serial.c @@ -618,7 +618,7 @@ int HAMLIB_API serial_setup(hamlib_port_t *rp) #endif // Store a copy of the original options for this FD, to be restored on close. - term_backup = calloc(1,sizeof(term_options_backup_t)); + term_backup = calloc(1, sizeof(term_options_backup_t)); term_backup-> fd = fd; #if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H) memcpy(&term_backup->options, &orig_options, sizeof(orig_options)); diff --git a/src/settings.c b/src/settings.c index 8745cd9f1..73d1fc98c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -1002,23 +1002,25 @@ HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen) char *xdgpath = getenv("XDG_CONFIG_HOME"); char *home = getenv("HOME"); snprintf(path, pathlen, "%s/.config", home); + if (xdgpath) { - snprintf(path, pathlen-1, "%s/%s/%s", xdgpath, cwd, HAMLIB_SETTINGS_FILE); + snprintf(path, pathlen - 1, "%s/%s/%s", xdgpath, cwd, HAMLIB_SETTINGS_FILE); } else if (home && access(path, F_OK) != -1) { - snprintf(path, pathlen-1, "%s/.config/%s", home, HAMLIB_SETTINGS_FILE); + snprintf(path, pathlen - 1, "%s/.config/%s", home, HAMLIB_SETTINGS_FILE); } else if (home) { // we add a leading period to hide the file - snprintf(path, pathlen-1, "%s/.%s", home, HAMLIB_SETTINGS_FILE); + snprintf(path, pathlen - 1, "%s/.%s", home, HAMLIB_SETTINGS_FILE); } else { - snprintf(path, pathlen-1, ".%s", HAMLIB_SETTINGS_FILE); + snprintf(path, pathlen - 1, ".%s", HAMLIB_SETTINGS_FILE); } + rig_debug(RIG_DEBUG_TRACE, "%s: path=%s\n", __func__, path); return RIG_OK; } @@ -1040,19 +1042,22 @@ HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value, char buf[4096]; char *cvalue = (char *)value; int *ivalue = (int *)value; - int n=0; + int n = 0; long *lvalue = (long *) value; float *fvalue = (float *) value; double *dvalue = (double *) value; char *vformat = "Unknown format??"; char template[64]; - rig_settings_get_path(path,sizeof(path)); + rig_settings_get_path(path, sizeof(path)); fp = fopen(path, "r"); - if (fp == NULL) { + + if (fp == NULL) + { rig_debug(RIG_DEBUG_WARN, "%s: %s not found\n", __func__, path); return -RIG_EIO; } + strcpy(template, "hamlib_settings_XXXXXX"); switch (valuetype) @@ -1112,7 +1117,9 @@ HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value, { char *tmp = strdup(buf); char *s = strtok(tmp, "="); - if (buf[0] == '#') { + + if (buf[0] == '#') + { fprintf(fptmp, "%s\n", buf); continue; } @@ -1125,6 +1132,7 @@ HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value, fclose(fptmp); return -RIG_EINTERNAL; } + ++n; char *v = strtok(NULL, "\r\n"); @@ -1137,6 +1145,7 @@ HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value, fclose(fptmp); return -RIG_EINTERNAL; } + rig_debug(RIG_DEBUG_TRACE, "%s: parsing setting %s=%s\n", __func__, s, v); fprintf(fptmp, vformat, s, value); } @@ -1161,18 +1170,21 @@ HAMLIB_EXPORT(int) rig_settings_load_all(char *settings_file) char buf[4096]; char settingstmp[4096]; - if (settings_file == NULL) { + if (settings_file == NULL) + { rig_settings_get_path(settingstmp, sizeof(settingstmp)); settings_file = settingstmp; } fp = fopen(settings_file, "r"); + if (fp == NULL) { rig_debug(RIG_DEBUG_VERBOSE, "%s: settings_file (%s): %s\n", __func__, settings_file, strerror(errno)); return -RIG_EINVAL; } + rig_debug(RIG_DEBUG_TRACE, "%s: opened %s\n", __func__, settings_file); while (fgets(buf, sizeof(buf), fp)) diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index d584218c3..2a9e9e7b4 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -232,7 +232,7 @@ void hash_add_model(int id, { struct mod_lst *s; - s = (struct mod_lst *)calloc(1,sizeof(struct mod_lst)); + s = (struct mod_lst *)calloc(1, sizeof(struct mod_lst)); s->id = id; SNPRINTF(s->mfg_name, sizeof(s->mfg_name), "%s", mfg_name); @@ -1692,7 +1692,7 @@ declare_proto_amp(set_level) } fputc('\n', fout); - return(RIG_OK); + return (RIG_OK); } level = rig_parse_level(arg1); @@ -1710,7 +1710,7 @@ declare_proto_amp(set_level) if (!cfp) { - return(-RIG_ENAVAIL); /* no such parameter */ + return (-RIG_ENAVAIL); /* no such parameter */ } switch (cfp->type) @@ -1734,10 +1734,10 @@ declare_proto_amp(set_level) break; default: - return(-RIG_ECONF); + return (-RIG_ECONF); } - return(amp_set_ext_level(amp, cfp->token, val)); + return (amp_set_ext_level(amp, cfp->token, val)); } if (RIG_LEVEL_IS_FLOAT(level)) @@ -1749,7 +1749,7 @@ declare_proto_amp(set_level) CHKSCN1ARG(sscanf(arg2, "%d", &val.i)); } - return(amp_set_level(amp, level, val)); + return (amp_set_level(amp, level, val)); } /* 'l' */ diff --git a/tests/ampctld.c b/tests/ampctld.c index 62e52172f..8718aa688 100644 --- a/tests/ampctld.c +++ b/tests/ampctld.c @@ -540,7 +540,7 @@ int main(int argc, char *argv[]) */ do { - arg = calloc(1,sizeof(struct handle_data)); + arg = calloc(1, sizeof(struct handle_data)); if (!arg) { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index ecf9da007..57cce91b6 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -426,7 +426,7 @@ void hash_add_model(int id, { struct mod_lst *s; - s = (struct mod_lst *)calloc(1,sizeof(struct mod_lst)); + s = (struct mod_lst *)calloc(1, sizeof(struct mod_lst)); s->id = id; SNPRINTF(s->mfg_name, sizeof(s->mfg_name), "%s", mfg_name); @@ -1725,40 +1725,46 @@ readline_repeat: } else - { + { if ((rig_powerstat == RIG_POWER_OFF || rig_powerstat == RIG_POWER_STANDBY)) { - rig_debug(RIG_DEBUG_VERBOSE, "%s: rig_powerstat is not on = %d\n", __func__, rig_powerstat); + rig_debug(RIG_DEBUG_VERBOSE, "%s: rig_powerstat is not on = %d\n", __func__, + rig_powerstat); // Update power status powerstat_t stat = RIG_POWER_ON; retcode = rig_get_powerstat(my_rig, &stat); - if (retcode == RIG_OK) rig_powerstat = stat; + + if (retcode == RIG_OK) { rig_powerstat = stat; } } + // only command allows when powered off is 0x87=set_powerstat - if (retcode == RIG_OK && (rig_powerstat == RIG_POWER_OFF || rig_powerstat == RIG_POWER_STANDBY) - && cmd_entry->cmd != 0x01 // dump_caps - && cmd_entry->cmd != 0xf0 // chk_vfo - && cmd_entry->cmd != 0x87) // set_powerstat + if (retcode == RIG_OK && (rig_powerstat == RIG_POWER_OFF + || rig_powerstat == RIG_POWER_STANDBY) + && cmd_entry->cmd != 0x01 // dump_caps + && cmd_entry->cmd != 0xf0 // chk_vfo + && cmd_entry->cmd != 0x87) // set_powerstat { //rig_debug(RIG_DEBUG_WARN, "%s: %s - only \\set_powerstat can be run \n", __func__, rigerror(-RIG_EPOWER)); - rig_debug(RIG_DEBUG_WARN, "%s: only \\set_powerstat can be run when rig powered off\n", __func__); + rig_debug(RIG_DEBUG_WARN, + "%s: only \\set_powerstat can be run when rig powered off\n", __func__); retcode = -RIG_EPOWER; } - else { - retcode = (*cmd_entry->rig_routine)(my_rig, - fout, - fin, - interactive, - prompt, - vfo_opt, - send_cmd_term, - *ext_resp_ptr, - *resp_sep_ptr, - cmd_entry, - vfo, - p1, - p2 ? p2 : "", - p3 ? p3 : ""); + else + { + retcode = (*cmd_entry->rig_routine)(my_rig, + fout, + fin, + interactive, + prompt, + vfo_opt, + send_cmd_term, + *ext_resp_ptr, + *resp_sep_ptr, + cmd_entry, + vfo, + p1, + p2 ? p2 : "", + p3 ? p3 : ""); } } @@ -2259,12 +2265,16 @@ declare_proto_rig(set_vfo) } vfo = rig_parse_vfo(arg1); - if (vfo == RIG_VFO_NONE) + + if (vfo == RIG_VFO_NONE) { int c; - while((c = fgetc(fin)) != '\n' && c != '\r' && c > 0); + + while ((c = fgetc(fin)) != '\n' && c != '\r' && c > 0); + return -RIG_EINVAL; } + retval = rig_set_vfo(rig, vfo); #if 0 // see if we can make this dynamic @@ -4682,7 +4692,7 @@ declare_proto_rig(set_powerstat) retval = rig_set_powerstat(rig, (powerstat_t) stat); rig->state.powerstat = stat; - rig_powerstat = stat; // update our global so others can see powerstat + rig_powerstat = stat; // update our global so others can see powerstat fflush(fin); RETURNFUNC(retval); } diff --git a/tests/rigctld.c b/tests/rigctld.c index e2d169c01..d1e1991b7 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -974,7 +974,9 @@ int main(int argc, char *argv[]) /* * main loop accepting connections */ - rig_debug(RIG_DEBUG_TRACE, "%s: rigctld listening on port %s\n", __func__, portno); + rig_debug(RIG_DEBUG_TRACE, "%s: rigctld listening on port %s\n", __func__, + portno); + do { fd_set set; @@ -1239,12 +1241,15 @@ void *handle_socket(void *arg) handle_data_arg->use_password); if (retcode != 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctl_parse retcode=%d\n", __func__, retcode); } + // update our power stat in case power gets turned off - if (retcode == -RIG_ETIMEOUT && my_rig->caps->get_powerstat) // if we get a timeout we might be powered off + if (retcode == -RIG_ETIMEOUT + && my_rig->caps->get_powerstat) // if we get a timeout we might be powered off { rig_get_powerstat(my_rig, &powerstat); rig_powerstat = powerstat; - if (powerstat == RIG_POWER_OFF) retcode = -RIG_EPOWER; + + if (powerstat == RIG_POWER_OFF) { retcode = -RIG_EPOWER; } } } else diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index b0419bbfa..1a7c03d60 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -291,7 +291,7 @@ void hash_add_model(int id, { struct mod_lst *s; - s = (struct mod_lst *)calloc(1,sizeof(struct mod_lst)); + s = (struct mod_lst *)calloc(1, sizeof(struct mod_lst)); s->id = id; SNPRINTF(s->mfg_name, sizeof(s->mfg_name), "%s", mfg_name); diff --git a/tests/rotctld.c b/tests/rotctld.c index ba9b36392..915ec7f02 100644 --- a/tests/rotctld.c +++ b/tests/rotctld.c @@ -570,7 +570,7 @@ int main(int argc, char *argv[]) */ do { - arg = calloc(1,sizeof(struct handle_data)); + arg = calloc(1, sizeof(struct handle_data)); if (!arg) {