Skip to content

Commit 43eddfc

Browse files
committed
Fix problems when HAMLIB_KEYER is set, but rig control is disabled
When HAMLIB_KEYER is set, but rig control and keying is disabled via `tlf -r`, hitting ESC will trip the assert(init_called) in rig_has_stop_morse. Protect the hamlib_keyer_* functions against being called in that mode. In passing, decrease the timeout after showing the "keying disabled" message to 1s.
1 parent e3b7cb8 commit 43eddfc

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/hamlib_keyer.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@
2525
#include "hamlib_keyer.h"
2626

2727
int hamlib_keyer_set_speed(int *cwspeed) {
28-
gran_t keyspd_gran = my_rig->caps->level_gran[rig_setting2idx(
29-
RIG_LEVEL_KEYSPD)];
28+
gran_t keyspd_gran;
3029
value_t spd;
3130

31+
if (! trx_control)
32+
return RIG_OK;
33+
34+
keyspd_gran = my_rig->caps->level_gran[rig_setting2idx(RIG_LEVEL_KEYSPD)];
35+
3236
/* if rig declared min/max speed, honor it. */
3337
if (keyspd_gran.min.i > 0 && *cwspeed < keyspd_gran.min.i)
3438
*cwspeed = keyspd_gran.min.i;
@@ -46,6 +50,9 @@ int hamlib_keyer_set_speed(int *cwspeed) {
4650
int hamlib_keyer_get_speed(int *cwspeed) {
4751
value_t value;
4852

53+
if (! trx_control)
54+
return RIG_OK;
55+
4956
assert(cwspeed != NULL);
5057

5158
pthread_mutex_lock(&tlf_rig_mutex);
@@ -58,6 +65,9 @@ int hamlib_keyer_get_speed(int *cwspeed) {
5865
}
5966

6067
int hamlib_keyer_send(char *cwmessage) {
68+
if (! trx_control)
69+
return RIG_OK;
70+
6171
pthread_mutex_lock(&tlf_rig_mutex);
6272
int ret = rig_send_morse(my_rig, RIG_VFO_CURR, cwmessage);
6373
pthread_mutex_unlock(&tlf_rig_mutex);
@@ -66,6 +76,9 @@ int hamlib_keyer_send(char *cwmessage) {
6676
}
6777

6878
int hamlib_keyer_stop() {
79+
if (! trx_control)
80+
return RIG_OK;
81+
6982
#if HAMLIB_VERSION >= 400
7083
if (rig_has_stop_morse()) {
7184
pthread_mutex_lock(&tlf_rig_mutex);

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static void keyer_init() {
951951
showmsg("CW-Keyer is Hamlib");
952952
if (trx_control_disabled) {
953953
showmsg("Radio control disabled - no keying!");
954-
sleep(2);
954+
sleep(1);
955955
return;
956956
}
957957
if (!trx_control) {

0 commit comments

Comments
 (0)