From b455affe7f8332b50680572673c41051bc0d5dc1 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Mon, 12 Mar 2018 17:22:52 -0400 Subject: [PATCH] Fix K3 send_morse and change generic to 0x20 padding per manual. Tested on TS-2000 --- kenwood/kenwood.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index f4c73b116..9b694a82e 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -2786,18 +2786,28 @@ int kenwood_send_morse(RIG *rig, vfo_t vfo, const char *msg) if (!strncmp(m2,"KY0", 3)) break; if (!strncmp(m2,"KY1", 3)) usleep(500000); else return -RIG_EINVAL; } - /* - * Make the total message segments 28 characters - * in length because Kenwood demands it. - * Spaces fill in the message end. - */ buff_len = msg_len > 24 ? 24 : msg_len; strncpy(m2, p, 24); m2[24] = '\0'; - /* the command must consist of 28 bytes */ - snprintf(morsebuf, sizeof (morsebuf), "KY %-24s", m2); + /* + * Make the total message segments 28 characters + * in length because some Kenwoods demand it. + * 0x20 fills in the message end. + * Some rigs don't need the fill + */ + switch(rig->caps->rig_model) { + case RIG_MODEL_K3: // probably a lot more rigs need to go here + snprintf(morsebuf, sizeof (morsebuf), "KY %s", m2); + break; + default: + /* the command must consist of 28 bytes 0x20 padded */ + snprintf(morsebuf, sizeof (morsebuf), "KY %-24s", m2); + for(int i=strlen(morsebuf)-1;i>0 && morsebuf[i]==' ';--i) { + morsebuf[i]=0x20; + } + } retval = kenwood_transaction(rig, morsebuf, NULL, 0); if (retval != RIG_OK) return retval;