kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'master' into rshfiq-aug2021
commit
ae08f81935
|
@ -370,7 +370,7 @@ int verify_kenwood_id(RIG *rig, char *id)
|
||||||
if (strcmp("017", idptr) != 0)
|
if (strcmp("017", idptr) != 0)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Rig (%s) is not a K2 or K3\n", __func__, id);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: Rig (%s) is not a K2 or K3\n", __func__, id);
|
||||||
return -RIG_EPROTO;
|
// return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -183,7 +183,7 @@ const struct rig_caps k3_caps =
|
||||||
RIG_MODEL(RIG_MODEL_K3),
|
RIG_MODEL(RIG_MODEL_K3),
|
||||||
.model_name = "K3",
|
.model_name = "K3",
|
||||||
.mfg_name = "Elecraft",
|
.mfg_name = "Elecraft",
|
||||||
.version = BACKEND_VER ".14",
|
.version = BACKEND_VER ".15",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -334,7 +334,7 @@ const struct rig_caps k3s_caps =
|
||||||
RIG_MODEL(RIG_MODEL_K3S),
|
RIG_MODEL(RIG_MODEL_K3S),
|
||||||
.model_name = "K3S",
|
.model_name = "K3S",
|
||||||
.mfg_name = "Elecraft",
|
.mfg_name = "Elecraft",
|
||||||
.version = BACKEND_VER ".12",
|
.version = BACKEND_VER ".13",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -484,7 +484,7 @@ const struct rig_caps k4_caps =
|
||||||
RIG_MODEL(RIG_MODEL_K4),
|
RIG_MODEL(RIG_MODEL_K4),
|
||||||
.model_name = "K4",
|
.model_name = "K4",
|
||||||
.mfg_name = "Elecraft",
|
.mfg_name = "Elecraft",
|
||||||
.version = BACKEND_VER ".12",
|
.version = BACKEND_VER ".13",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -633,7 +633,7 @@ const struct rig_caps kx3_caps =
|
||||||
RIG_MODEL(RIG_MODEL_KX3),
|
RIG_MODEL(RIG_MODEL_KX3),
|
||||||
.model_name = "KX3",
|
.model_name = "KX3",
|
||||||
.mfg_name = "Elecraft",
|
.mfg_name = "Elecraft",
|
||||||
.version = BACKEND_VER ".12",
|
.version = BACKEND_VER ".13",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -782,7 +782,7 @@ const struct rig_caps kx2_caps =
|
||||||
RIG_MODEL(RIG_MODEL_KX2),
|
RIG_MODEL(RIG_MODEL_KX2),
|
||||||
.model_name = "KX2",
|
.model_name = "KX2",
|
||||||
.mfg_name = "Elecraft",
|
.mfg_name = "Elecraft",
|
||||||
.version = BACKEND_VER ".12",
|
.version = BACKEND_VER ".13",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -1467,59 +1467,78 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||||
char buf[32];
|
char buf[32];
|
||||||
char kmode;
|
char kmode;
|
||||||
int err;
|
int err;
|
||||||
char cmd_m[4];
|
char cmd_m[16];
|
||||||
|
struct kenwood_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
switch (tx_mode)
|
switch (tx_mode)
|
||||||
{
|
{
|
||||||
case RIG_MODE_PKTLSB:
|
case RIG_MODE_PKTLSB:
|
||||||
tx_mode = RIG_MODE_RTTY; // "DT0" RIG_MODE_RTTY = LSB
|
tx_mode = RIG_MODE_RTTYR; // "DT0" RIG_MODE_RTTY = LSB
|
||||||
snprintf(cmd_m, sizeof(cmd_m),
|
snprintf(cmd_m, sizeof(cmd_m),
|
||||||
"DT0"); /* DATA A mode - DATA-R LSB, suppressed carrier */
|
"DT0;"); /* DATA A mode - DATA-R LSB, suppressed carrier */
|
||||||
|
if (priv->is_k4d || priv->is_k4hd) {
|
||||||
|
strcat(cmd_m, "DT$0;");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_MODE_PKTUSB:
|
case RIG_MODE_PKTUSB:
|
||||||
tx_mode = RIG_MODE_RTTYR; // "DT0" RIG_MODE_RTTYR = USB
|
tx_mode = RIG_MODE_RTTY; // "DT0" RIG_MODE_RTTYR = USB
|
||||||
snprintf(cmd_m, sizeof(cmd_m),
|
snprintf(cmd_m, sizeof(cmd_m),
|
||||||
"DT0"); /* DATA A mode - DATA on USB, suppressed carrier */
|
"DT0;"); /* DATA A mode - DATA on USB, suppressed carrier */
|
||||||
|
if (priv->is_k4d || priv->is_k4hd) {
|
||||||
|
strcat(cmd_m, "DT$0;");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_MODE_RTTY:
|
case RIG_MODE_RTTY:
|
||||||
tx_mode = RIG_MODE_RTTY; // DT1" RIG_MODE_RTTY = LSB and RIG_MODE_RTTYR = USB
|
tx_mode = RIG_MODE_RTTY; // DT1" RIG_MODE_RTTY = LSB and RIG_MODE_RTTYR = USB
|
||||||
snprintf(cmd_m, sizeof(cmd_m),
|
snprintf(cmd_m, sizeof(cmd_m),
|
||||||
"DT1"); /* FSK D mode - direct FSK on LSB optimized for RTTY, VFO dial is MARK */
|
"DT2;"); /* FSK D mode - direct FSK on LSB optimized for RTTY, VFO dial is MARK */
|
||||||
|
if (priv->is_k4d || priv->is_k4hd) {
|
||||||
|
strcat(cmd_m, "DT$2;");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_MODE_RTTYR:
|
case RIG_MODE_RTTYR:
|
||||||
tx_mode = RIG_MODE_RTTYR; // "DT2" RIG_MODE_RTTY = USB and RIG_MODE_RTTYR = USB
|
tx_mode = RIG_MODE_RTTYR; // "DT2" RIG_MODE_RTTY = USB and RIG_MODE_RTTYR = USB
|
||||||
snprintf(cmd_m, sizeof(cmd_m),
|
snprintf(cmd_m, sizeof(cmd_m),
|
||||||
"DT2"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */
|
"DT1;"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */
|
||||||
|
if (priv->is_k4d || priv->is_k4hd) {
|
||||||
|
strcat(cmd_m, "DT$1;");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_MODE_PSK:
|
case RIG_MODE_PSK:
|
||||||
tx_mode = RIG_MODE_PSK;
|
tx_mode = RIG_MODE_PSK;
|
||||||
snprintf(cmd_m, sizeof(cmd_m),
|
snprintf(cmd_m, sizeof(cmd_m),
|
||||||
"DT3"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */
|
"DT3;"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */
|
||||||
|
if (priv->is_k4d || priv->is_k4hd) {
|
||||||
|
strcat(cmd_m, "DT$3;");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
// Enabling this clause for just the K4 for now
|
||||||
|
#if 1
|
||||||
|
|
||||||
/* Set data sub-mode. K3 needs to be in a DATA mode before setting
|
if (priv->is_k4d || priv->is_k4hd) {
|
||||||
* the sub-mode or switching to VFOB so we do this before the MD$ command.
|
/* Set data sub-mode. K3 needs to be in a DATA mode before setting
|
||||||
*/
|
* the sub-mode or switching to VFOB so we do this before the MD$ command.
|
||||||
if (tx_mode == RIG_MODE_PKTLSB || tx_mode == RIG_MODE_PKTUSB
|
*/
|
||||||
|
if (tx_mode == RIG_MODE_PKTLSB || tx_mode == RIG_MODE_PKTUSB
|
||||||
|| tx_mode == RIG_MODE_RTTY || tx_mode == RIG_MODE_RTTYR)
|
|| tx_mode == RIG_MODE_RTTY || tx_mode == RIG_MODE_RTTYR)
|
||||||
{
|
|
||||||
err = kenwood_transaction(rig, cmd_m, NULL, 0);
|
|
||||||
|
|
||||||
if (err != RIG_OK)
|
|
||||||
{
|
{
|
||||||
return err;
|
err = kenwood_transaction(rig, cmd_m, NULL, 0);
|
||||||
|
|
||||||
|
if (err != RIG_OK)
|
||||||
|
{
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1556,8 +1575,8 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* passband widths vary by mode so gather lower and upper limits */
|
/* passband widths vary by mode so gather lower and upper limits */
|
||||||
pbwidth_t pb_nar = rig_passband_narrow(rig, tx_mode);
|
//pbwidth_t pb_nar = rig_passband_narrow(rig, tx_mode);
|
||||||
pbwidth_t pb_wid = rig_passband_wide(rig, tx_mode);
|
//pbwidth_t pb_wid = rig_passband_wide(rig, tx_mode);
|
||||||
|
|
||||||
if (tx_width < 0)
|
if (tx_width < 0)
|
||||||
{
|
{
|
||||||
|
@ -1568,6 +1587,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||||
{
|
{
|
||||||
tx_width = rig_passband_normal(rig, tx_mode);
|
tx_width = rig_passband_normal(rig, tx_mode);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
else if (tx_width < pb_nar)
|
else if (tx_width < pb_nar)
|
||||||
{
|
{
|
||||||
tx_width = pb_nar;
|
tx_width = pb_nar;
|
||||||
|
@ -1576,6 +1596,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
||||||
{
|
{
|
||||||
tx_width = pb_wid;
|
tx_width = pb_wid;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
snprintf(cmd_s, sizeof(cmd_s), "BW$%04ld", tx_width / 10);
|
snprintf(cmd_s, sizeof(cmd_s), "BW$%04ld", tx_width / 10);
|
||||||
err = kenwood_transaction(rig, cmd_s, NULL, 0);
|
err = kenwood_transaction(rig, cmd_s, NULL, 0);
|
||||||
|
|
|
@ -954,6 +954,12 @@ int kenwood_open(RIG *rig)
|
||||||
}
|
}
|
||||||
|
|
||||||
rig->state.rigport.retry = retry_save;
|
rig->state.rigport.retry = retry_save;
|
||||||
|
|
||||||
|
// Default to 1st VFO and split off
|
||||||
|
if (rig->caps->set_vfo) {
|
||||||
|
rig_set_vfo(rig, vfo_fixup(rig, RIG_VFO_A, 0));
|
||||||
|
}
|
||||||
|
|
||||||
RETURNFUNC(RIG_OK);
|
RETURNFUNC(RIG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#define BACKEND_VER "20210719"
|
#define BACKEND_VER "20210804"
|
||||||
|
|
||||||
#define EOM_KEN ';'
|
#define EOM_KEN ';'
|
||||||
#define EOM_TH '\r'
|
#define EOM_TH '\r'
|
||||||
|
|
|
@ -0,0 +1,257 @@
|
||||||
|
// can run this using rigctl/rigctld and socat pty devices
|
||||||
|
// gcc -o simyaesu simyaesu.c
|
||||||
|
#define _XOPEN_SOURCE 600
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 256
|
||||||
|
|
||||||
|
float freqA = 14074000;
|
||||||
|
float freqB = 14074500;
|
||||||
|
|
||||||
|
// ID 0310 == 310, Must drop leading zero
|
||||||
|
typedef enum nc_rigid_e
|
||||||
|
{
|
||||||
|
NC_RIGID_NONE = 0,
|
||||||
|
NC_RIGID_FT450 = 241,
|
||||||
|
NC_RIGID_FT450D = 244,
|
||||||
|
NC_RIGID_FT950 = 310,
|
||||||
|
NC_RIGID_FT891 = 135,
|
||||||
|
NC_RIGID_FT991 = 135,
|
||||||
|
NC_RIGID_FT2000 = 251,
|
||||||
|
NC_RIGID_FT2000D = 252,
|
||||||
|
NC_RIGID_FTDX1200 = 583,
|
||||||
|
NC_RIGID_FTDX9000D = 101,
|
||||||
|
NC_RIGID_FTDX9000Contest = 102,
|
||||||
|
NC_RIGID_FTDX9000MP = 103,
|
||||||
|
NC_RIGID_FTDX5000 = 362,
|
||||||
|
NC_RIGID_FTDX3000 = 460,
|
||||||
|
NC_RIGID_FTDX101D = 681,
|
||||||
|
NC_RIGID_FTDX101MP = 682
|
||||||
|
} nc_rigid_t;
|
||||||
|
|
||||||
|
int
|
||||||
|
getmyline(int fd, char *buf)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
int i = 0;
|
||||||
|
memset(buf, 0, BUFSIZE);
|
||||||
|
|
||||||
|
while (read(fd, &c, 1) > 0)
|
||||||
|
{
|
||||||
|
buf[i++] = c;
|
||||||
|
|
||||||
|
if (c == ';') { return strlen(buf); }
|
||||||
|
}
|
||||||
|
|
||||||
|
return strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
|
int openPort(char *comport) // doesn't matter for using pts devices
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
fd = open(comport, O_RDWR);
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
perror(comport);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
int openPort(char *comport) // doesn't matter for using pts devices
|
||||||
|
{
|
||||||
|
int fd = posix_openpt(O_RDWR);
|
||||||
|
char *name = ptsname(fd);
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
perror("pstname");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("name=%s\n", name);
|
||||||
|
|
||||||
|
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
|
||||||
|
{
|
||||||
|
perror("posix_openpt");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
char *pbuf;
|
||||||
|
int n;
|
||||||
|
int fd = openPort(argv[1]);
|
||||||
|
int modea, modeb = 0;
|
||||||
|
int freqa = 14074000, freqb = 14073500;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
buf[0]=0;
|
||||||
|
if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf);
|
||||||
|
else return 0;
|
||||||
|
|
||||||
|
if (strcmp(buf, "RM5;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "RM5100000;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("RM5"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strcmp(buf, "AN0;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "AN030;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("AN"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "IF;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "IF059014200000+000000700000;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("IF"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "ID;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
int id = 24;
|
||||||
|
snprintf(buf,sizeof(buf),"ID%03d;", id);
|
||||||
|
n = snprintf(buf, sizeof(buf), "ID%03d;", id);
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("ID"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
else if (strncmp(buf, "AI", 2) == 0)
|
||||||
|
{
|
||||||
|
if (strcmp(buf, "AI;"))
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
n = fprintf(fp, "%s", "AI0;");
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("AI"); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
else if (strcmp(buf, "VS;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "VS0;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n < 0) { perror("VS"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "EX032;") == 0)
|
||||||
|
{
|
||||||
|
static int ant = 0;
|
||||||
|
ant = (ant + 1) % 3;
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
snprintf(buf, sizeof(buf), "EX032%1d;", ant);
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n < 0) { perror("EX032"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"OM;") == 0)
|
||||||
|
{
|
||||||
|
// KPA3 snprintf(buf, sizeof(buf), "OM AP----L-----;");
|
||||||
|
// K4+KPA3
|
||||||
|
snprintf(buf, sizeof(buf), "OM AP-S----4---;");
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n < 0) { perror("OM"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"K2;") == 0)
|
||||||
|
{
|
||||||
|
write(fd, "K20;", 4);
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"K3;") == 0)
|
||||||
|
{
|
||||||
|
write(fd, "K30;", 4);
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"RVM;") == 0)
|
||||||
|
{
|
||||||
|
write(fd, "RV02.37;", 8);
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"AI;") == 0)
|
||||||
|
{
|
||||||
|
write(fd, "AI0;", 4);
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"MD;") == 0)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "MD%d;", modea);
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"MD$;") == 0)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "MD$%d;", modeb);
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
else if (strncmp(buf,"MD", 2) == 0)
|
||||||
|
{
|
||||||
|
if (buf[2]=='$') sscanf(buf,"MD$%d;",&modeb);
|
||||||
|
else sscanf(buf,"MD%d;", &modea);
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"FA;")==0)
|
||||||
|
{
|
||||||
|
sprintf(buf, "FA%011d;", freqa);
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
else if (strcmp(buf,"FB;")==0)
|
||||||
|
{
|
||||||
|
sprintf(buf, "FB%011d;", freqb);
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strncmp(buf,"FA",2)==0)
|
||||||
|
{
|
||||||
|
sscanf(buf,"FA%d",&freqa);
|
||||||
|
}
|
||||||
|
else if (strncmp(buf,"FB",2)==0)
|
||||||
|
{
|
||||||
|
sscanf(buf,"FB%d",&freqb);
|
||||||
|
}
|
||||||
|
else if (strlen(buf) > 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unknown command: %s\n", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,298 @@
|
||||||
|
// simicom will show the pts port to use for rigctl on Unix
|
||||||
|
// using virtual serial ports on Windows is to be developed yet
|
||||||
|
// Needs a lot of improvement to work on all Icoms
|
||||||
|
// gcc -g -Wall -o simicom simicom.c -lhamlib
|
||||||
|
// On mingw in the hamlib src directory
|
||||||
|
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
|
||||||
|
#define _XOPEN_SOURCE 600
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <hamlib/rig.h>
|
||||||
|
#include "../src/misc.h"
|
||||||
|
|
||||||
|
#define BUFSIZE 256
|
||||||
|
|
||||||
|
int civ_731_mode = 0;
|
||||||
|
vfo_t current_vfo = RIG_VFO_A;
|
||||||
|
int split = 0;
|
||||||
|
|
||||||
|
// we make B different from A to ensure we see a difference at startup
|
||||||
|
float freqA = 14074000;
|
||||||
|
float freqB = 14074500;
|
||||||
|
mode_t modeA = RIG_MODE_CW;
|
||||||
|
mode_t modeB = RIG_MODE_USB;
|
||||||
|
pbwidth_t widthA = 0;
|
||||||
|
pbwidth_t widthB = 1;
|
||||||
|
|
||||||
|
void dumphex(unsigned char *buf, int n)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
frameGet(int fd, unsigned char *buf)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
memset(buf, 0, BUFSIZE);
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
|
while (read(fd, &c, 1) > 0)
|
||||||
|
{
|
||||||
|
buf[i++] = c;
|
||||||
|
//printf("i=%d, c=0x%02x\n",i,c);
|
||||||
|
|
||||||
|
if (c == 0xfd)
|
||||||
|
{
|
||||||
|
dumphex(buf, i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Error???\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void frameParse(int fd, unsigned char *frame, int len)
|
||||||
|
{
|
||||||
|
double freq;
|
||||||
|
|
||||||
|
dumphex(frame, len);
|
||||||
|
|
||||||
|
if (frame[0] != 0xfe && frame[1] != 0xfe)
|
||||||
|
{
|
||||||
|
printf("expected fe fe, got ");
|
||||||
|
dumphex(frame, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (frame[4])
|
||||||
|
{
|
||||||
|
case 0x03:
|
||||||
|
|
||||||
|
//from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||||
|
{
|
||||||
|
printf("get_freqA\n");
|
||||||
|
to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("get_freqB\n");
|
||||||
|
to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame[10] = 0xfd;
|
||||||
|
write(fd, frame, 11);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x04:
|
||||||
|
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
|
||||||
|
{
|
||||||
|
printf("get_modeA\n");
|
||||||
|
frame[5] = modeA;
|
||||||
|
frame[6] = widthA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("get_modeB\n");
|
||||||
|
frame[5] = modeB;
|
||||||
|
frame[6] = widthB;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame[7] = 0xfd;
|
||||||
|
write(fd, frame, 8);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x05:
|
||||||
|
freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
printf("set_freq to %.0f\n", freq);
|
||||||
|
|
||||||
|
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; }
|
||||||
|
else { freqB = freq; }
|
||||||
|
frame[4] = 0xfb;
|
||||||
|
frame[5] = 0xfd;
|
||||||
|
write(fd, frame, 6);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x06:
|
||||||
|
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; }
|
||||||
|
else { modeB = frame[6]; }
|
||||||
|
frame[4] = 0xfb;
|
||||||
|
frame[5] = 0xfd;
|
||||||
|
write(fd, frame, 6);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x07:
|
||||||
|
|
||||||
|
switch (frame[5])
|
||||||
|
{
|
||||||
|
case 0x00: current_vfo = RIG_VFO_A; break;
|
||||||
|
|
||||||
|
case 0x01: current_vfo = RIG_VFO_B; break;
|
||||||
|
|
||||||
|
case 0xd0: current_vfo = RIG_VFO_MAIN; break;
|
||||||
|
|
||||||
|
case 0xd1: current_vfo = RIG_VFO_SUB; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("set_vfo to %s\n", rig_strvfo(current_vfo));
|
||||||
|
|
||||||
|
frame[4] = 0xfb;
|
||||||
|
frame[5] = 0xfd;
|
||||||
|
write(fd, frame, 6);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0f:
|
||||||
|
if (frame[5] == 0) { split = 0; }
|
||||||
|
else { split = 1; }
|
||||||
|
|
||||||
|
printf("set split %d\n", 1);
|
||||||
|
frame[4] = 0xfb;
|
||||||
|
frame[5] = 0xfd;
|
||||||
|
write(fd, frame, 6);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x1a: // miscellaneous things
|
||||||
|
switch (frame[5])
|
||||||
|
{
|
||||||
|
case 0x03: // width
|
||||||
|
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; }
|
||||||
|
else { frame[6] = widthB; }
|
||||||
|
|
||||||
|
frame[7] = 0xfd;
|
||||||
|
write(fd, frame, 8);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
case 0x25:
|
||||||
|
if (frame[6] == 0xfd)
|
||||||
|
{
|
||||||
|
if (frame[5] == 0x00)
|
||||||
|
{
|
||||||
|
to_bcd(&frame[6], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
printf("get_freqA=%.0f\n", freqA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_bcd(&frame[6], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
printf("get_freqB=%.0f\n", freqB);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame[11] = 0xfd;
|
||||||
|
write(fd, frame, 12);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2);
|
||||||
|
printf("set_freq to %.0f\n", freq);
|
||||||
|
|
||||||
|
if (frame[5] == 0x00) { freqA = freq; }
|
||||||
|
else { freqB = freq; }
|
||||||
|
|
||||||
|
frame[4] = 0xfb;
|
||||||
|
frame[5] = 0xfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default: printf("cmd 0x%02x unknown\n", frame[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't care about the rig type yet
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
|
int openPort(char *comport) // doesn't matter for using pts devices
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
fd = open(comport, O_RDWR);
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
perror(comport);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
int openPort(char *comport) // doesn't matter for using pts devices
|
||||||
|
{
|
||||||
|
int fd = posix_openpt(O_RDWR);
|
||||||
|
char *name = ptsname(fd);
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
perror("pstname");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("name=%s\n", name);
|
||||||
|
|
||||||
|
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
|
||||||
|
{
|
||||||
|
perror("posix_openpt");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void rigStatus()
|
||||||
|
{
|
||||||
|
char vfoa = current_vfo == RIG_VFO_A ? '*' : ' ';
|
||||||
|
char vfob = current_vfo == RIG_VFO_B ? '*' : ' ';
|
||||||
|
printf("%cVFOA: mode=%s width=%ld freq=%.0f\n", vfoa, rig_strrmode(modeA),
|
||||||
|
widthA,
|
||||||
|
freqA);
|
||||||
|
printf("%cVFOB: mode=%s width=%ld freq=%.0f\n", vfob, rig_strrmode(modeB),
|
||||||
|
widthB,
|
||||||
|
freqB);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
unsigned char buf[256];
|
||||||
|
int fd = openPort(argv[1]);
|
||||||
|
|
||||||
|
printf("%s: %s\n", argv[0], rig_version());
|
||||||
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
printf("Missing comport argument\n");
|
||||||
|
printf("%s [comport]\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int len = frameGet(fd, buf);
|
||||||
|
|
||||||
|
if (len <= 0)
|
||||||
|
{
|
||||||
|
close(fd);
|
||||||
|
fd = openPort(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
frameParse(fd, buf, len);
|
||||||
|
rigStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,223 @@
|
||||||
|
// can run this using rigctl/rigctld and socat pty devices
|
||||||
|
// gcc -o simyaesu simyaesu.c
|
||||||
|
#define _XOPEN_SOURCE 600
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 256
|
||||||
|
|
||||||
|
float freqA = 14074000;
|
||||||
|
float freqB = 14074500;
|
||||||
|
|
||||||
|
// ID 0310 == 310, Must drop leading zero
|
||||||
|
typedef enum nc_rigid_e
|
||||||
|
{
|
||||||
|
NC_RIGID_NONE = 0,
|
||||||
|
NC_RIGID_FT450 = 241,
|
||||||
|
NC_RIGID_FT450D = 244,
|
||||||
|
NC_RIGID_FT950 = 310,
|
||||||
|
NC_RIGID_FT891 = 135,
|
||||||
|
NC_RIGID_FT991 = 135,
|
||||||
|
NC_RIGID_FT2000 = 251,
|
||||||
|
NC_RIGID_FT2000D = 252,
|
||||||
|
NC_RIGID_FTDX1200 = 583,
|
||||||
|
NC_RIGID_FTDX9000D = 101,
|
||||||
|
NC_RIGID_FTDX9000Contest = 102,
|
||||||
|
NC_RIGID_FTDX9000MP = 103,
|
||||||
|
NC_RIGID_FTDX5000 = 362,
|
||||||
|
NC_RIGID_FTDX3000 = 460,
|
||||||
|
NC_RIGID_FTDX101D = 681,
|
||||||
|
NC_RIGID_FTDX101MP = 682
|
||||||
|
} nc_rigid_t;
|
||||||
|
|
||||||
|
int
|
||||||
|
getmyline(int fd, char *buf)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
int i = 0;
|
||||||
|
memset(buf, 0, BUFSIZE);
|
||||||
|
|
||||||
|
while (read(fd, &c, 1) > 0)
|
||||||
|
{
|
||||||
|
buf[i++] = c;
|
||||||
|
|
||||||
|
if (c == ';') { return strlen(buf); }
|
||||||
|
}
|
||||||
|
|
||||||
|
return strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
|
int openPort(char *comport) // doesn't matter for using pts devices
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
fd = open(comport, O_RDWR);
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
perror(comport);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
int openPort(char *comport) // doesn't matter for using pts devices
|
||||||
|
{
|
||||||
|
int fd = posix_openpt(O_RDWR);
|
||||||
|
char *name = ptsname(fd);
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
perror("pstname");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("name=%s\n", name);
|
||||||
|
|
||||||
|
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
|
||||||
|
{
|
||||||
|
perror("posix_openpt");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
char *pbuf;
|
||||||
|
int n;
|
||||||
|
int fd = openPort(argv[1]);
|
||||||
|
int freqa=14074000, freqb=140735000;
|
||||||
|
int modea=0,modeb=0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
buf[0]=0;
|
||||||
|
if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf);
|
||||||
|
else return 0;
|
||||||
|
|
||||||
|
if (strcmp(buf, "RM5;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "RM5100000;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("RM5"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strcmp(buf, "AN0;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "AN030;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("AN"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "IF;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "IF000503130001000+0000000000030000000;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("IF"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "ID;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
int id = 24;
|
||||||
|
snprintf(buf,sizeof(buf),"ID%03d;", id);
|
||||||
|
n = snprintf(buf, sizeof(buf), "ID%03d;", id);
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("ID"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
else if (strncmp(buf, "AI", 2) == 0)
|
||||||
|
{
|
||||||
|
if (strcmp(buf, "AI;"))
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
n = fprintf(fp, "%s", "AI0;");
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n <= 0) { perror("AI"); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
else if (strcmp(buf, "VS;") == 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
pbuf = "VS0;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n < 0) { perror("VS"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "EX032;") == 0)
|
||||||
|
{
|
||||||
|
static int ant = 0;
|
||||||
|
ant = (ant + 1) % 3;
|
||||||
|
printf("%s\n", buf);
|
||||||
|
usleep(50 * 1000);
|
||||||
|
snprintf(buf, sizeof(buf), "EX032%1d;", ant);
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
|
if (n < 0) { perror("EX032"); }
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "FA;") == 0)
|
||||||
|
{
|
||||||
|
sprintf(buf, "FA%011d;", freqa);
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "FB;") == 0)
|
||||||
|
{
|
||||||
|
sprintf(buf, "FA%011d;", freqa);
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
else if (strncmp(buf,"FA",2)==0)
|
||||||
|
{
|
||||||
|
sscanf(buf,"FA%d",&freqa);
|
||||||
|
}
|
||||||
|
else if (strncmp(buf,"FB",2)==0)
|
||||||
|
{
|
||||||
|
sscanf(buf,"FB%d",&freqb);
|
||||||
|
}
|
||||||
|
else if (strncmp(buf,"AI;",2)==0)
|
||||||
|
{
|
||||||
|
sprintf(buf, "AI0;");
|
||||||
|
write(fd, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (strlen(buf) > 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unknown command: %s\n", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Ładowanie…
Reference in New Issue