kopia lustrzana https://github.com/Hamlib/Hamlib
Fix dummy rig to recognize Main/Sub VFOS -- this fixes "M CW 500"
Fix rig.c set_mode to recognize curr_vfo correctly https://github.com/Hamlib/Hamlib/issues/689pull/691/head
rodzic
78a697e582
commit
7f60e1fcb0
|
@ -469,15 +469,23 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s %s\n", __func__,
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s %s\n", __func__,
|
||||||
rig_strvfo(vfo), rig_strrmode(mode), buf);
|
rig_strvfo(vfo), rig_strrmode(mode), buf);
|
||||||
|
|
||||||
|
vfo = vfo_fixup(rig, vfo);
|
||||||
switch (vfo)
|
switch (vfo)
|
||||||
{
|
{
|
||||||
|
case RIG_VFO_MAIN:
|
||||||
case RIG_VFO_A: priv->vfo_a.mode = mode; priv->vfo_a.width = width; break;
|
case RIG_VFO_A: priv->vfo_a.mode = mode; priv->vfo_a.width = width; break;
|
||||||
|
|
||||||
|
case RIG_VFO_SUB:
|
||||||
case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width; break;
|
case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width; break;
|
||||||
|
|
||||||
case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width; break;
|
case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width; break;
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown VFO=%s\n", __func__, rig_strvfo(vfo));
|
||||||
|
RETURNFUNC(-RIG_EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vfo = vfo_fixup(rig, vfo);
|
||||||
|
|
||||||
if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); }
|
if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); }
|
||||||
|
|
||||||
if (width == RIG_PASSBAND_NORMAL)
|
if (width == RIG_PASSBAND_NORMAL)
|
||||||
|
@ -2127,7 +2135,7 @@ struct rig_caps dummy_caps =
|
||||||
RIG_MODEL(RIG_MODEL_DUMMY),
|
RIG_MODEL(RIG_MODEL_DUMMY),
|
||||||
.model_name = "Dummy",
|
.model_name = "Dummy",
|
||||||
.mfg_name = "Hamlib",
|
.mfg_name = "Hamlib",
|
||||||
.version = "20210428.0",
|
.version = "20210504.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_OTHER,
|
.rig_type = RIG_TYPE_OTHER,
|
||||||
|
@ -2292,7 +2300,7 @@ struct rig_caps dummy_no_vfo_caps =
|
||||||
RIG_MODEL(RIG_MODEL_DUMMY_NOVFO),
|
RIG_MODEL(RIG_MODEL_DUMMY_NOVFO),
|
||||||
.model_name = "Dummy No VFO",
|
.model_name = "Dummy No VFO",
|
||||||
.mfg_name = "Hamlib",
|
.mfg_name = "Hamlib",
|
||||||
.version = "20210428.0",
|
.version = "20210504.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_OTHER,
|
.rig_type = RIG_TYPE_OTHER,
|
||||||
|
|
|
@ -2154,8 +2154,9 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
RETURNFUNC(-RIG_ENAVAIL);
|
RETURNFUNC(-RIG_ENAVAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vfo == RIG_VFO_CURR) vfo = rig->state.current_vfo;
|
||||||
|
|
||||||
if ((caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
if ((caps->targetable_vfo & RIG_TARGETABLE_MODE)
|
||||||
|| vfo == RIG_VFO_CURR
|
|
||||||
|| vfo == rig->state.current_vfo)
|
|| vfo == rig->state.current_vfo)
|
||||||
{
|
{
|
||||||
TRACE;
|
TRACE;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// can run this using rigctl/rigctld and socat pty devices
|
// can run this using rigctl/rigctld and socat pty devices
|
||||||
// socat -d -d pty,raw,echo=0 pty,raw,echo=0
|
// gcc -o simyaesu simyaesu.c
|
||||||
|
#define _XOPEN_SOURCE 600
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -31,13 +34,13 @@ typedef enum nc_rigid_e
|
||||||
} nc_rigid_t;
|
} nc_rigid_t;
|
||||||
|
|
||||||
int
|
int
|
||||||
getmyline(FILE *fp, char *buf)
|
getmyline(int fd, char *buf)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
memset(buf, 0, BUFSIZE);
|
memset(buf, 0, BUFSIZE);
|
||||||
|
|
||||||
while ((c = fgetc(fp)) != EOF)
|
while (read(fd, &c, 1) > 0)
|
||||||
{
|
{
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
|
|
||||||
|
@ -46,63 +49,101 @@ getmyline(FILE *fp, char *buf)
|
||||||
|
|
||||||
return strlen(buf);
|
return strlen(buf);
|
||||||
}
|
}
|
||||||
int main()
|
|
||||||
|
#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 buf[256];
|
||||||
|
char *pbuf;
|
||||||
int n;
|
int n;
|
||||||
FILE *fp = fopen("/dev/pts/3", "r+");
|
int fd = openPort(argv[1]);
|
||||||
|
|
||||||
//,while(getmyline(fp,buf))
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
getmyline(fp, buf);
|
getmyline(fd, buf);
|
||||||
|
printf("Cmd:%s\n", buf);
|
||||||
|
|
||||||
if (strcmp(buf, "RM5;") == 0)
|
if (strcmp(buf, "RM5;") == 0)
|
||||||
{
|
{
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
n = fprintf(fp, "%s", "RM5100000;");
|
pbuf = "RM5100000;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n <= 0) { perror("RM5"); }
|
if (n <= 0) { perror("RM5"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(buf, "AN0;") == 0)
|
if (strcmp(buf, "AN0;") == 0)
|
||||||
{
|
{
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
n = fprintf(fp, "%s", "AN030;");
|
pbuf = "AN030;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n <= 0) { perror("AN"); }
|
if (n <= 0) { perror("AN"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
else if (strcmp(buf, "IF;") == 0)
|
else if (strcmp(buf, "IF;") == 0)
|
||||||
{
|
{
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
n = fprintf(fp, "%s", "IF059014200000+000000700000;");
|
pbuf = "IF059014200000+000000700000;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n <= 0) { perror("IF"); }
|
if (n <= 0) { perror("IF"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
else if (strcmp(buf, "ID;") == 0)
|
else if (strcmp(buf, "ID;") == 0)
|
||||||
{
|
{
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
int id = NC_RIGID_FTDX101D;
|
int id = NC_RIGID_FTDX3000;
|
||||||
// int id = NC_RIGID_FTDX3000;
|
snprintf(buf,sizeof(buf),"ID%03d;", id);
|
||||||
n = fprintf(fp, "ID%03d;", id);
|
n = snprintf(buf, sizeof(buf), "ID%03d;", id);
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n <= 0) { perror("ID"); }
|
if (n <= 0) { perror("ID"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -116,8 +157,6 @@ int main()
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n <= 0) { perror("AI"); }
|
if (n <= 0) { perror("AI"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,12 +165,11 @@ int main()
|
||||||
{
|
{
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
n = fprintf(fp, "%s", "VS0;");
|
pbuf = "VS0;";
|
||||||
|
n = write(fd, pbuf, strlen(pbuf));
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n < 0) { perror("VS"); }
|
if (n < 0) { perror("VS"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
else if (strcmp(buf, "EX032;") == 0)
|
else if (strcmp(buf, "EX032;") == 0)
|
||||||
{
|
{
|
||||||
|
@ -139,12 +177,11 @@ int main()
|
||||||
ant = (ant + 1) % 3;
|
ant = (ant + 1) % 3;
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
n = fprintf(fp, "EX032%1d;", ant);
|
snprintf(buf, sizeof(buf), "EX032%1d;", ant);
|
||||||
|
n = write(fd, buf, strlen(buf));
|
||||||
printf("n=%d\n", n);
|
printf("n=%d\n", n);
|
||||||
|
|
||||||
if (n < 0) { perror("EX032"); }
|
if (n < 0) { perror("EX032"); }
|
||||||
|
|
||||||
fflush(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strlen(buf) > 0)
|
else if (strlen(buf) > 0)
|
||||||
|
|
Ładowanie…
Reference in New Issue