Porównaj commity

...

10 Commity

Autor SHA1 Wiadomość Data
Mike Black W9MDB b358cdbd2e Fix usb_port.c to use new libusb format for pid:vid 2024-03-05 15:57:10 -06:00
Mike Black W9MDB f3b8330331 Update simft450.c 2024-03-05 07:24:44 -06:00
Mike Black W9MDB 6121197687 Fix spelling error in Makefile.am 2024-03-04 15:42:46 -06:00
Mike Black W9MDB 15a2b5a0dc Fix segfault on rigctl -m 2 -u
https://github.com/Hamlib/Hamlib/issues/1520
2024-03-04 12:23:00 -06:00
Mike Black W9MDB b9df1c7bda Add simft450.c 2024-03-04 08:38:00 -06:00
Mike Black W9MDB 4f3e40f3c6 Add simic910.c 2024-03-03 22:45:43 -06:00
Mike Black W9MDB bafb88432a Fix return value for rig_send_raw 2024-03-03 22:40:43 -06:00
Mike Black W9MDB 2212c47ad7 Update NEWS 2024-03-03 22:40:24 -06:00
Mike Black W9MDB f122f6422b Fix Icom switching to VFO mode when starting up in memory mode
https://github.com/Hamlib/Hamlib/issues/1431
2024-03-03 22:39:49 -06:00
Mike Black W9MDB 0868edbd65 Add simxiegux6100 2024-03-03 15:19:56 -06:00
9 zmienionych plików z 1355 dodań i 15 usunięć

1
NEWS
Wyświetl plik

@ -13,6 +13,7 @@ Version 5.x -- future
* Change FT1000MP Mark V model names to align with FT1000MP
Version 4.6
* Added --set-conf=filter_usb, filter_usbd, and filter_cw to allow Icom rigs set mode to set filter number too
* Added macros for applications to obtain pointers to Hamlib structures(issues #1445, #1420, #487).
Internal conversion is still a WIP, but use of these macros will make the final cutover transparent to applications.
* Added Guohe Q900 entry

Wyświetl plik

@ -863,6 +863,8 @@ rig_debug(RIG_DEBUG_ERR, "## %s\n", buf);
int level;
sscanf(p, "%d", &level);
rig->caps->parm_gran[i].step.s = 0;
if (RIG_PARM_IS_FLOAT(level))
{
double min, max, step;
@ -2812,7 +2814,7 @@ struct rig_caps netrigctl_caps =
RIG_MODEL(RIG_MODEL_NETRIGCTL),
.model_name = "NET rigctl",
.mfg_name = "Hamlib",
.version = "20240226.0",
.version = "20240304.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_OTHER,

Wyświetl plik

@ -819,6 +819,8 @@ static int icom_check_ack(int ack_len, unsigned char *ackbuf)
return RIG_OK;
}
#if 0 // this causes the rig to go into VFO mode when it is in memory mode
// we have to give up on determining active VFO for Icom rigs
// figure out what VFO is current for rigs with 0x25 command
static int icom_current_vfo_x25(RIG *rig, vfo_t *vfo)
{
@ -884,6 +886,7 @@ static int icom_current_vfo_x25(RIG *rig, vfo_t *vfo)
*vfo = vfo_current;
return RIG_OK;
}
#endif
static int icom_current_vfo_to_vfo_with_band(RIG *rig, vfo_t *vfo_current)
{
@ -934,6 +937,7 @@ static vfo_t icom_current_vfo(RIG *rig)
struct rig_state *rs = &rig->state;
struct icom_priv_data *priv = rs->priv;
#if 0
// Icom rigs with both Main/Sub receivers and A/B VFOs cannot use the 0x25 command to read Sub receiver frequency
if (rs->targetable_vfo & RIG_TARGETABLE_FREQ && !VFO_HAS_MAIN_SUB_A_B_ONLY)
{
@ -950,6 +954,7 @@ static vfo_t icom_current_vfo(RIG *rig)
return vfo_current;
}
}
#endif
if (rs->cache.ptt)
{
@ -1741,6 +1746,11 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
retval = icom_get_freq_x25(rig, vfo, &freq_len, freqbuf, &freqbuf_offset);
if (freq_len == 3 && freqbuf[2] == 0xff)
{ // then we are in VFO mode
*freq = 0;
return RIG_OK;
}
if (retval == RIG_OK)
{
// 0x25 cmd is 1 byte longer than 0x03 cmd

Wyświetl plik

@ -35,7 +35,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20240211"
#define BACKEND_VER "20240303"
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)

Wyświetl plik

@ -8,7 +8,7 @@ DISTCLEANFILES =
bin_PROGRAMS =
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g simxiegux6100
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g simxiegux6100 simic910 simft450
simelecraft_SOURCES = simelecraft.c
simkenwood_SOURCES = simkenwood.c

Wyświetl plik

@ -0,0 +1,611 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include "../include/hamlib/rig.h"
#define BUFSIZE 256
float freqA = 14074000;
float freqB = 14074500;
char tx_vfo = '0';
char rx_vfo = '0';
char modeA = '1';
char modeB = '1';
int ks = 20;
int bandselect = 5;
int width = 21;
int narrow = 0;
int vd = 0;
int sm0 = 0;
int sm1 = 0;
int vs = 0;
int vx = 0;
int pa = 0;
int ra = 0;
int ag = 0;
int pc = 100;
int is = 0;
int bp_on = 0;
int bp_pos = 0;
int rl = 0;
int nb = 0;
int nr = 0;
int tx = 0;
int mg = 0;
int rg = 100;
int vg = 0;
int kr = 0;
int bi = 0;
int gt = 0;
int ex016 = 0;
int ex020 = 0;
// 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); }
}
if (strlen(buf) == 0) { hl_usleep(10 * 1000); }
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]);
while (1)
{
if (getmyline(fd, buf))
{
// printf("Cmd:%s\n", buf);
}
else { continue; }
if (strcmp(buf, ";") == 0)
{
pbuf = "?;";
n = write(fd, pbuf, strlen(pbuf));
}
else if (strcmp(buf, "RM4;") == 0)
{
hl_usleep(50 * 1000);
pbuf = "RM4100;";
n = write(fd, pbuf, strlen(pbuf));
if (n <= 0) { perror("RM4"); }
}
else if (strcmp(buf, "RM5;") == 0)
{
hl_usleep(50 * 1000);
pbuf = "RM4100000;";
n = write(fd, pbuf, strlen(pbuf));
if (n <= 0) { perror("RM5"); }
}
else if (strcmp(buf, "RM6;") == 0)
{
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
if (n <= 0) { perror("AN"); }
}
else if (strcmp(buf, "IF;") == 0)
{
hl_usleep(50 * 1000);
pbuf = "IF059014200000+000000700000;";
n = write(fd, pbuf, strlen(pbuf));
if (n <= 0) { perror("IF"); }
}
else if (strcmp(buf, "FA;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FA%08.0f;", freqA);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "FA", 2) == 0)
{
sscanf(buf, "FA%f", &freqA);
}
else if (strcmp(buf, "FB;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FB%08.0f;", freqB);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "FB", 2) == 0)
{
sscanf(buf, "FB%f", &freqB);
}
else if (strcmp(buf, "ID;") == 0)
{
hl_usleep(50 * 1000);
int id = NC_RIGID_FTDX3000;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
if (n <= 0) { perror("ID"); }
}
else if (strcmp(buf, "PS;") == 0)
{
SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "AI;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf));
if (n <= 0) { perror("ID"); }
}
else if (strcmp(buf, "AI0;") == 0)
{
hl_usleep(50 * 1000);
}
else if (strcmp(buf, "FT;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "FT%c;", tx_vfo);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("FT"); }
}
else if (strncmp(buf, "FT", 2) == 0)
{
tx_vfo = buf[2];
}
else if (strcmp(buf, "MD0;") == 0)
{
printf("MD=%s\n", buf);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "MD0%c;", modeA);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("MD0;"); }
}
else if (strncmp(buf, "MD0", 3) == 0)
{
modeA = buf[3];
}
else if (strcmp(buf, "MD1;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "MD1%c;", modeB);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("MD0;"); }
}
else if (strncmp(buf, "MD1", 3) == 0)
{
modeB = buf[3];
}
#if 0
else if (strncmp(buf, "AI", 2) == 0)
{
if (strcmp(buf, "AI;"))
{
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
if (n <= 0) { perror("AI"); }
}
}
#endif
else if (strcmp(buf, "VS;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "VS%d;", vs);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("VS"); }
}
else if (strncmp(buf, "VS", 2) == 0)
{
sscanf(buf, "VS%d", &vs);
}
else if (strcmp(buf, "KR;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "KR%d;", kr);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("KR"); }
}
else if (strncmp(buf, "KR", 2) == 0)
{
sscanf(buf, "KR%d", &kr);
}
else if (strcmp(buf, "BI;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "BI%d;", bi);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("BI"); }
}
else if (strncmp(buf, "BI", 2) == 0)
{
sscanf(buf, "BI%d", &bi);
}
else if (strcmp(buf, "VX;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "VX%d;", vx);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("VX"); }
}
else if (strncmp(buf, "VX", 2) == 0)
{
sscanf(buf, "VX%d", &vx);
}
else if (strcmp(buf, "PA;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "PA%d;", pa);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("PA"); }
}
else if (strncmp(buf, "PA", 2) == 0)
{
sscanf(buf, "PA%d", &vs);
}
else if (strcmp(buf, "RA;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "RA%d;", ra);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("RA"); }
}
else if (strncmp(buf, "RA", 2) == 0)
{
sscanf(buf, "RA%d", &ra);
}
else if (strcmp(buf, "AG;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "AG%d;", ag);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("AG"); }
}
else if (strncmp(buf, "AG", 2) == 0)
{
sscanf(buf, "AG%d", &ag);
}
else if (strcmp(buf, "PC;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "PC%03d;", pc);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("PC"); }
}
else if (strncmp(buf, "PC", 2) == 0)
{
sscanf(buf, "PC%d", &pc);
}
else if (strcmp(buf, "VG;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "VG%03d;", vg);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("VG"); }
}
else if (strncmp(buf, "VG", 2) == 0)
{
sscanf(buf, "VG%d", &vg);
}
else if (strcmp(buf, "RG0;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "RG0%03d;", rg);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("RG"); }
}
else if (strncmp(buf, "RG", 2) == 0)
{
sscanf(buf, "RG0%d", &rg);
}
else if (strcmp(buf, "GT0;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "GT0%0d;", gt);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("GT"); }
}
else if (strncmp(buf, "GT", 2) == 0)
{
sscanf(buf, "GT0%d", &gt);
}
else if (strcmp(buf, "TX;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "TX+%04d;", tx);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("TX"); }
}
else if (strncmp(buf, "TX", 2) == 0)
{
sscanf(buf, "TX%d", &tx);
}
else if (strcmp(buf, "IS;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "IS+%04d;", is);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("IS"); }
}
else if (strncmp(buf, "IS", 2) == 0)
{
sscanf(buf, "IS%d", &is);
}
else if (strcmp(buf, "RL0;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "RL0%d;", rl);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("RL"); }
}
else if (strncmp(buf, "RL", 2) == 0)
{
sscanf(buf, "RL0%02d", &rl);
}
else if (strcmp(buf, "BP00;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "BP0%d;", bp_on);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("BP"); }
}
else if (strncmp(buf, "BP00", 4) == 0)
{
sscanf(buf, "BP00%d", &bp_on);
}
else if (strcmp(buf, "BP01;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "BP0%d;", bp_pos);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("BP"); }
}
else if (strncmp(buf, "BP01", 4) == 0)
{
sscanf(buf, "BP01%d", &bp_pos);
}
else if (strcmp(buf, "NB0;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "NB0%d;", nb);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("NB"); }
}
else if (strncmp(buf, "NB0", 3) == 0)
{
sscanf(buf, "NB0%d", &nb);
}
else if (strcmp(buf, "NR0;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "NR0%d;", nr);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("NR"); }
}
else if (strncmp(buf, "NR0", 3) == 0)
{
sscanf(buf, "NR0%d", &nr);
}
else if (strcmp(buf, "EX032;") == 0)
{
static int ant = 0;
ant = (ant + 1) % 3;
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("EX032"); }
}
else if (strcmp(buf, "EX016;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX016%04d;", ex016);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("EX016"); }
}
else if (strcmp(buf, "EX020;") == 0)
{
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX020%04d;", ex020);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("EX016"); }
}
else if (strncmp(buf, "EX020", 5) == 0)
{
sscanf(buf, "EX020%d\n", &ex020);
}
else if (strncmp(buf, "KS;", 3) == 0)
{
sprintf(buf, "KS%d;", ks);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "KS", 2) == 0)
{
sscanf(buf, "KS%03d", &ks);
}
else if (strncmp(buf, "MG;", 3) == 0)
{
sprintf(buf, "MG%03d;", mg);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "MG", 2) == 0)
{
sscanf(buf, "MG%03d", &mg);
}
else if (strncmp(buf, "BS;", 3) == 0) // cannot query BS
{
sprintf(buf, "BS%02d;", bandselect);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "SH0;", 4) == 0)
{
sprintf(buf, "SH0%02d;", width);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "SH0", 3) == 0)
{
sscanf(buf, "SH0%02d", &width);
}
else if (strncmp(buf, "NA0;", 4) == 0)
{
sprintf(buf, "NA0%d;", narrow);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "NA0", 3) == 0)
{
sscanf(buf, "NA0%d", &narrow);
}
else if (strncmp(buf, "VD;", 3) == 0)
{
sprintf(buf, "VD%d;", vd);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "VD", 2) == 0)
{
sscanf(buf, "VD%d", &vd);
}
else if (strncmp(buf, "SM0;", 4) == 0)
{
sprintf(buf, "SM0%d;", sm0);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "SM0", 3) == 0)
{
sscanf(buf, "SM0%3d", &sm0);
}
else if (strncmp(buf, "SM1;", 4) == 0)
{
sprintf(buf, "SM1%d;", sm1);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "SM1", 3) == 0)
{
sscanf(buf, "SM1%3d", &sm1);
}
else if (strlen(buf) > 0)
{
fprintf(stderr, "Unknown command: %s\n", buf);
}
}
return 0;
}

Wyświetl plik

@ -0,0 +1,696 @@
// 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 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <hamlib/rig.h>
#include "../src/misc.h"
#include <termios.h>
#include <unistd.h>
#include "sim.h"
#define BUFSIZE 256
#define X25
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
double freqA = 145123456;
double freqB = 1407450;
mode_t modeA = RIG_MODE_PKTUSB;
mode_t modeB = RIG_MODE_PKTUSB;
int datamodeA = 0;
int datamodeB = 0;
int filterA = 1;
int filterB = 2;
pbwidth_t widthA = 0;
pbwidth_t widthB = 1;
ant_t ant_curr = 0;
int ant_option = 0;
int ptt = 0;
int satmode = 0;
int agc_time = 1;
int ovf_status = 0;
int powerstat = 1;
int keyspd = 25;
int datamode = 0;
int filter = 0;
void dumphex(const 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;
again:
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;
}
if (i > 2 && c == 0xfe)
{
printf("Turning power on due to 0xfe string\n");
powerstat = 1;
int j;
for (j = i; j < 175; ++j)
{
if (read(fd, &c, 1) < 0) { break; }
}
i = 0;
goto again;
}
}
printf("Error %s\n", strerror(errno));
return 0;
}
void frameParse(int fd, unsigned char *frame, int len)
{
double freq;
if (len == 0)
{
printf("%s: len==0\n", __func__);
return;
}
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);
int freq_len = 5;
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
{
if (freqA > 5.85e9) { freq_len = 6; }
printf("get_freqA len=%d\n", freq_len);
to_bcd(&frame[5], (long long)freqA, freq_len * 2);
}
else
{
if (freqB > 5.85e9) { freq_len = 6; }
printf("get_freqB len=%d\n", freq_len);
to_bcd(&frame[5], (long long)freqB, freq_len * 2);
}
frame[5 + freq_len] = 0xfd;
if (powerstat)
{
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 0xa0: freqB = freqA; modeB = modeA; break;
case 0xb0: current_vfo = RIG_VFO_SUB; exit(1); 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] == 0xfd)
{
printf("get split %d\n", split);
frame[5] = split;
frame[6] = 0xfd;
WRITE(fd, frame, 7);
}
else
{
printf("set split %d\n", 1);
split = frame[5];
frame[4] = 0xfb;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
}
break;
case 0x12: // we're simulating the 3-byte version -- not the 2-byte
if (frame[5] != 0xfd)
{
printf("Set ant %d\n", -1);
ant_curr = frame[5];
ant_option = frame[6];
dump_hex(frame, 8);
}
else
{
printf("Get ant\n");
}
frame[5] = ant_curr;
frame[6] = ant_option;
frame[7] = 0xfd;
printf("WRITE 8 bytes\n");
dump_hex(frame, 8);
WRITE(fd, frame, 8);
break;
case 0x14:
switch (frame[5])
{
static int power_level = 0;
case 0x07:
case 0x08:
if (frame[6] != 0xfd)
{
frame[6] = 0xfb;
dumphex(frame, 7);
WRITE(fd, frame, 7);
printf("ACK x14 x08\n");
}
else
{
to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb;
dumphex(frame, 9);
WRITE(fd, frame, 9);
printf("SEND x14 x08\n");
}
break;
case 0x0a:
printf("Using power level %d\n", power_level);
power_level += 10;
if (power_level > 250) { power_level = 0; }
to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd;
WRITE(fd, frame, 9);
break;
case 0x0c:
dumphex(frame, 10);
printf("subcmd=0x0c #1\n");
if (frame[6] != 0xfd) // then we have data
{
printf("subcmd=0x0c #1\n");
keyspd = from_bcd(&frame[6], 2);
frame[6] = 0xfb;
WRITE(fd, frame, 7);
}
else
{
printf("subcmd=0x0c #1\n");
to_bcd(&frame[6], keyspd, 2);
frame[8] = 0xfd;
WRITE(fd, frame, 9);
}
break;
}
break;
case 0x15:
switch (frame[5])
{
static int meter_level = 0;
case 0x07:
frame[6] = ovf_status;
frame[7] = 0xfd;
WRITE(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0;
break;
case 0x11:
printf("Using meter level %d\n", meter_level);
meter_level += 10;
if (meter_level > 250) { meter_level = 0; }
to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd;
WRITE(fd, frame, 9);
break;
}
case 0x16:
switch (frame[5])
{
case 0x5a:
if (frame[6] == 0xfe)
{
satmode = frame[6];
}
else
{
frame[6] = satmode;
frame[7] = 0xfd;
WRITE(fd, frame, 8);
}
break;
}
break;
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
WRITE(fd, frame, 7);
break;
case 0x19: // miscellaneous things
frame[5] = 0x94;
frame[6] = 0xfd;
WRITE(fd, frame, 7);
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;
case 0x04: // AGC TIME
printf("frame[6]==x%02x, frame[7]=0%02x\n", frame[6], frame[7]);
if (frame[6] == 0xfd) // the we are reading
{
frame[6] = agc_time;
frame[7] = 0xfd;
WRITE(fd, frame, 8);
}
else
{
printf("AGC_TIME RESPONSE******************************");
agc_time = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
}
break;
case 0x06: // datamode
if (frame[5] == 0xfd)
{
frame[6] = datamode;
frame[7] = filter;
frame[8] = 0xfd;
WRITE(fd, frame, 9);
}
else
{
datamode = frame[6];
filter = frame[7];
frame[4] = 0xfb;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
}
case 0x07: // satmode
frame[4] = 0;
frame[7] = 0xfd;
WRITE(fd, frame, 8);
break;
}
break;
case 0x1c:
switch (frame[5])
{
case 0:
if (frame[6] == 0xfd)
{
int tmp = frame[2];
frame[2] = frame[3];
frame[3] = tmp;
frame[6] = ptt;
frame[7] = 0xfd;
WRITE(fd, frame, 8);
}
else
{
ptt = frame[6];
int tmp = frame[2];
frame[2] = frame[3];
frame[3] = tmp;
frame[4] = 0xfb;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
}
break;
}
break;
#ifdef X25
case 0x25:
if (frame[6] == 0xfd)
{
freq_len = 5;
if (frame[5] == 0x00)
{
if (freqA > 5.85e9) { freq_len = 6; }
to_bcd(&frame[6], (long long)freqA, freq_len * 2);
printf("X25 get_freqA=%.0f\n", freqA);
frame[6 + freq_len] = 0xfd;
WRITE(fd, frame, 7 + freq_len);
}
else
{
if (freqB > 5.85e9) { freq_len = 6; }
to_bcd(&frame[6], (long long)freqB, freq_len * 2);
printf("X25 get_freqB=%.0f\n", freqB);
frame[6 + freq_len] = 0xfd;
WRITE(fd, frame, 7 + freq_len);
}
//unsigned char frame2[12];
#if 0
frame2[0] = 0xfe;
frame2[1] = 0xfe;
frame2[2] = 0x00; // send transceive frame
frame2[3] = frame[3]; // send transceive frame
frame2[4] = 0x00;
frame2[5] = 0x70;
frame2[6] = 0x28;
frame2[7] = 0x57;
frame2[8] = 0x03;
frame2[9] = 0x00;
frame2[10] = 0x00;
frame2[11] = 0xfd;
WRITE(fd, frame2, 12);
#endif
}
else
{
freq_len = 5;
if (frame[11] != 0xfd) { freq_len = 6; }
freq = from_bcd(&frame[6], freq_len * 2);
printf("set_freq to %.0f\n", freq);
if (frame[5] == 0x00) { freqA = freq; }
else { freqB = freq; }
int tmp = frame[2];
frame[2] = frame[3];
frame[3] = tmp;
frame[4] = 0xfb;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
#if 0
// send async frame
frame[2] = 0x00; // async freq
frame[3] = 0xa2;
frame[4] = 0x00;
frame[5] = 0x00;
frame[6] = 0x10;
frame[7] = 0x01;
frame[8] = 0x96;
frame[9] = 0x12;
frame[10] = 0xfd;
WRITE(fd, frame, 11);
#endif
}
break;
case 0x26:
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
if (frame[6] == 0xfd) // then a query
{
for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); }
frame[6] = frame[5] == 0 ? modeA : modeB;
frame[7] = frame[5] == 0 ? datamodeA : datamodeB;
frame[8] = frame[5] == 0 ? filterA : filterB;
frame[9] = 0xfd;
WRITE(fd, frame, 10);
}
else
{
for (int i = 0; i < 12; ++i) { printf("%02x:", frame[i]); }
if (frame[6] == 0)
{
modeA = frame[7];
datamodeA = frame[8];
}
else
{
modeB = frame[7];
datamodeB = frame[8];
}
frame[4] = 0xfb;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
}
printf("\n");
break;
#else
case 0x25:
printf("x25 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
break;
case 0x26:
printf("x26 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
WRITE(fd, frame, 6);
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=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA,
datamodeA,
widthA,
freqA);
printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB,
datamodeB,
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());
#ifdef X25
printf("x25/x26 command recognized\n");
#else
printf("x25/x26 command rejected\n");
#endif
#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]);
}
if (powerstat)
{
frameParse(fd, buf, len);
}
else
{
hl_usleep(1000 * 1000);
}
rigStatus();
}
return 0;
}

Wyświetl plik

@ -8701,7 +8701,9 @@ HAMLIB_EXPORT(int) rig_send_raw(RIG *rig, const unsigned char *send,
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: simulating response for model %s\n",
__func__, rig->caps->model_name);
memcpy(reply, send, send_len);
retval = send_len;
return retval;
}
else
{

Wyświetl plik

@ -67,10 +67,11 @@ static libusb_device_handle *find_and_open_device(const hamlib_port_t *port)
char string[256];
int i, r;
rig_debug(RIG_DEBUG_VERBOSE, "%s called LIBUSB_API_VERSION=%x\n", __func__, LIBUSB_API_VERSION);
rig_debug(RIG_DEBUG_VERBOSE, "%s called LIBUSB_API_VERSION=%x\n", __func__,
LIBUSB_API_VERSION);
rig_debug(RIG_DEBUG_VERBOSE,
"%s: looking for device %04x:%04x...",
"%s: looking for device %04x:%04x...\n",
__func__,
port->parm.usb.vid,
port->parm.usb.pid);
@ -93,7 +94,7 @@ static libusb_device_handle *find_and_open_device(const hamlib_port_t *port)
libusb_get_device_descriptor(dev, &desc);
rig_debug(RIG_DEBUG_VERBOSE,
" %04x:%04x,",
" %04x:%04x\n",
desc.idVendor,
desc.idProduct);
@ -243,33 +244,50 @@ int usb_port_open(hamlib_port_t *port)
pathname[HAMLIB_FILPATHLEN - 1] = '\0';
p = pathname;
q = strchr(p, ':');
if (q)
if (strlen(pathname) == 9)
{
// then is new new libusb format with just vid:pid
int n = sscanf(pathname, "%x:%x", &port->parm.usb.vid, &port->parm.usb.pid);
if (n != 2)
{
rig_debug(RIG_DEBUG_ERR, "%s: unable to parse vid:pid from '%s'\n", __func__,
pathname);
return -RIG_EINVAL;
}
}
else
{
++q;
port->parm.usb.vid = strtol(q, NULL, 16);
p = q;
q = strchr(p, ':');
if (q)
{
++q;
port->parm.usb.pid = strtol(q, NULL, 16);
port->parm.usb.vid = strtol(q, NULL, 16);
p = q;
q = strchr(p, ':');
if (q)
{
++q;
port->parm.usb.vendor_name = q;
port->parm.usb.pid = strtol(q, NULL, 16);
p = q;
q = strchr(p, ':');
if (q)
{
*q++ = '\0';
port->parm.usb.product = q;
++q;
port->parm.usb.vendor_name = q;
p = q;
q = strchr(p, ':');
if (q)
{
*q++ = '\0';
port->parm.usb.product = q;
}
}
}
}