Add simicom9100.c and fix compilation of all others due to POSIX requirements

pull/1289/head
Mike Black W9MDB 2023-05-08 12:04:08 -05:00
rodzic 247f0f72cf
commit f45aea8859
22 zmienionych plików z 867 dodań i 124 usunięć

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -121,7 +127,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -132,7 +138,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -142,7 +148,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
//pbuf = "IF059014200000+000000700000;";
pbuf = "IF00007230000 -000000 0001000001 ;" ;
n = write(fd, pbuf, strlen(pbuf));
@ -153,7 +159,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -251,7 +257,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -263,7 +269,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -275,7 +281,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simft897 simft897.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simft747gx simft747gx.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simft897 simft897.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -121,7 +127,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -132,7 +138,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -172,7 +178,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
//pbuf = "IF00107041000+000000200000;";
pbuf = "IF00010138698 +00000000002000000 ;";
n = write(fd, pbuf, strlen(pbuf));
@ -183,7 +189,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = NC_RIGID_FTDX3000DM;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -194,7 +200,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AI;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);
@ -203,7 +209,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "AI0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
}
else if (strcmp(buf, "AB;") == 0)
{
@ -217,7 +223,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -229,12 +235,12 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "VS") == 0 && strlen(buf) > 3)
{
curr_vfo = buf[3] == '1' ? RIG_VFO_B : RIG_VFO_A;
usleep(50 * 1000);
hl_usleep(50 * 1000);
}
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "VS0;";
if (curr_vfo == RIG_VFO_B || curr_vfo == RIG_VFO_SUB) { pbuf[2] = '1'; }
@ -246,7 +252,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "FT;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "FT%c;", tx_vfo);
printf(" FT response#1=%s, tx_vfo=%c\n", resp, tx_vfo);
n = write(fd, resp, strlen(resp));
@ -264,7 +270,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "MD0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "MD0%c;", modeA);
n = write(fd, resp, strlen(resp));
@ -276,7 +282,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "MD1;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "MD1%c;", modeB);
n = write(fd, resp, strlen(resp));
@ -288,7 +294,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "SM0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "SM0111;");
n = write(fd, resp, strlen(resp));
@ -296,7 +302,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "TX;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "TX%d;", ptt);
n = write(fd, resp, strlen(resp));
@ -304,7 +310,7 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "TX", 2) == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
ptt = buf[2] == '0' ? 0 : 1;
}
else if (strcmp(buf, "EX032;") == 0)
@ -312,7 +318,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);
@ -322,14 +328,14 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "SH0;") == 0)
{
SNPRINTF(buf, sizeof(buf), "SH0%02d;", width);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
printf("%s n=%d\n", buf, n);
}
else if (strcmp(buf, "NA0;") == 0)
{
SNPRINTF(buf, sizeof(buf), "NA00;");
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
printf("%s n=%d\n", buf, n);
}

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simft897 simft897.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,7 +1,13 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simft990 simft990.c
// emulates 1.2 ROM FT990 which can only read 1492 bytes
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -119,7 +125,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -130,7 +136,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -140,7 +146,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "IF059014200000+000000700000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -168,7 +174,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = NC_RIGID_FTDX3000;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -184,7 +190,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AI;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);
@ -193,11 +199,11 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "AI0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
}
else if (strcmp(buf, "FT;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "FT%c;", tx_vfo);
printf(" FT response#1=%s, tx_vfo=%c\n", buf, tx_vfo);
n = write(fd, buf, strlen(buf));
@ -215,7 +221,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "MD0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "MD0%c;", modeA);
n = write(fd, buf, strlen(buf));
@ -227,7 +233,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "MD1;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "MD1%c;", modeB);
n = write(fd, buf, strlen(buf));
@ -246,7 +252,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -258,7 +264,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -270,7 +276,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -118,7 +124,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -129,7 +135,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -139,7 +145,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "IF059014200000+000000700000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -149,7 +155,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = NC_RIGID_FTDX3000;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -164,7 +170,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -178,7 +184,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -118,7 +124,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -129,7 +135,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -139,7 +145,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "IF059014200000+000000700000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -149,7 +155,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = NC_RIGID_FTDX3000;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -163,7 +169,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -120,7 +126,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -131,7 +137,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -141,7 +147,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "IF059014200000+000000700000;";
n = write(fd, pbuf, strlen(pbuf));
printf("n=%d\n", n);
@ -151,7 +157,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = NC_RIGID_FTDX3000;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -164,7 +170,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

Wyświetl plik

@ -4,7 +4,13 @@
// 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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Wyświetl plik

@ -0,0 +1,617 @@
// 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
struct ip_mreq
{
int dummy;
};
#include <hamlib/rig.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include "../src/misc.h"
#include "../src/multicast.h"
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.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
float freqA = 14074000;
float freqB = 14074500;
mode_t modeA = RIG_MODE_PKTUSB;
mode_t modeB = RIG_MODE_PKTUSB;
int datamodeA = 0;
int datamodeB = 0;
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;
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;
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??? c=x%02x\n", c);
return 0;
}
void frameParse(int fd, unsigned char *frame, int len)
{
double freq;
int n = 0;
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;
if (powerstat)
{
n = 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;
n = 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;
n = 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;
n = 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;
n = write(fd, frame, 6);
break;
case 0x0f:
if (frame[5] == 0) { split = 0; }
else if (frame[5] == 1) { split = 1; }
else { frame[6] = split; }
if (frame[5] == 0xfd)
{
printf("get split %d\n", 1);
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
n = 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);
n = 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);
n = write(fd, frame, 7);
printf("ACK x14 x08\n");
}
else
{
to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb;
dumphex(frame, 9);
n = 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;
n = 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;
n = 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;
n = 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;
n = write(fd, frame, 8);
}
break;
}
break;
case 0x18: // miscellaneous things
frame[5] = 1;
frame[6] = 0xfd;
n = write(fd, frame, 7);
break;
case 0x19: // miscellaneous things
frame[5] = 0x94;
frame[6] = 0xfd;
n = 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;
n = 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;
n = write(fd, frame, 8);
}
else
{
printf("AGC_TIME RESPONSE******************************");
agc_time = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
}
break;
case 0x07: // satmode
frame[4] = 0;
frame[7] = 0xfd;
n = write(fd, frame, 8);
break;
}
break;
case 0x1c:
switch (frame[5])
{
case 0:
if (frame[6] == 0xfd)
{
frame[6] = ptt;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[7] = 0xfb;
frame[8] = 0xfd;
n = write(fd, frame, 9);
}
break;
}
break;
#ifdef X25
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;
unsigned char frame2[11];
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] = 0xfd;
n = write(fd, frame2, 11);
n = write(fd, frame, 12);
}
else
{
freq = from_bcd(&frame[6], (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;
n = write(fd, frame, 6);
// 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;
n = write(fd, frame, 11);
}
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] = 0xfb;
frame[9] = 0xfd;
n = 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;
n = write(fd, frame, 6);
}
printf("\n");
break;
#else
case 0x25:
printf("x25 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
case 0x26:
printf("x26 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
#endif
default: printf("cmd 0x%02x unknown\n", frame[4]);
}
if (n == 0) { printf("Write failed=%s\n", strerror(errno)); }
// 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

@ -4,7 +4,13 @@
// 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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -601,7 +607,7 @@ int main(int argc, char **argv)
}
else
{
usleep(1000 * 1000);
hl_usleep(1000 * 1000);
}
rigStatus();

Wyświetl plik

@ -4,7 +4,13 @@
// 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
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -467,7 +473,7 @@ int main(int argc, char **argv)
}
else
{
usleep(1000 * 1000);
hl_usleep(1000 * 1000);
}
rigStatus();

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simft897 simft897.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -116,7 +122,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
@ -127,7 +133,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
@ -138,7 +144,7 @@ int main(int argc, char *argv[])
{
char ifbuf[256];
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "IF000503130001000+0000000000030000000;";
sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ;
@ -151,42 +157,42 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "NB;") == 0)
{
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "NB0;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "RA;") == 0)
{
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "RA01;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "RG;") == 0)
{
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "RG055;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "MG;") == 0)
{
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "MG050;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "AG;") == 0)
{
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "AG100;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "FV;") == 0)
{
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf));
continue;
@ -221,7 +227,7 @@ int main(int argc, char *argv[])
//usleep(mysleep * 1000);
pbuf = "FW240";
n = write(fd, pbuf, strlen(pbuf));
usleep(20 * 1000);
hl_usleep(20 * 1000);
pbuf = "0;";
n = write(fd, pbuf, strlen(pbuf));
continue;
@ -233,7 +239,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -250,7 +256,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -262,7 +268,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
@ -276,7 +282,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(mysleep * 1000);
hl_usleep(mysleep * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
// printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -114,7 +120,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
@ -125,7 +131,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
@ -136,7 +142,7 @@ int main(int argc, char *argv[])
{
char ifbuf[256];
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "IF000503130001000+0000000000030000000;";
sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa);
//pbuf = "IF00010138698 +00000000002000000 ;
@ -149,14 +155,14 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "FV;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "FV1.2;";
n = write(fd, pbuf, strlen(pbuf));
continue;
}
else if (strcmp(buf, "FW;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "FW2400;";
n = write(fd, pbuf, strlen(pbuf));
continue;
@ -164,7 +170,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = 24;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -181,7 +187,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -193,7 +199,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "VS0;";
n = write(fd, pbuf, strlen(pbuf));
// printf("n=%d\n", n);
@ -207,7 +213,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
// printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simspid simspid.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simspid simspid.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -113,7 +119,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "ID") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "ID TM-D700\r");
n = write(fd, buf, strlen(buf));
printf("n=%d\n", n);

Wyświetl plik

@ -1,6 +1,12 @@
// can run this using rigctl/rigctld and socat pty devices
// gcc -o simyaesu simyaesu.c
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
struct ip_mreq
{
int dummy;
};
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@ -143,7 +149,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "RM5;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM5100000;";
n = write(fd, pbuf, strlen(pbuf));
//printf("n=%d\n", n);
@ -153,7 +159,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "RM8;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM8197000;";
n = write(fd, pbuf, strlen(pbuf));
//printf("n=%d\n", n);
@ -163,7 +169,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "RM9;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "RM9089000;";
n = write(fd, pbuf, strlen(pbuf));
//printf("n=%d\n", n);
@ -174,7 +180,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AN0;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "AN030;";
n = write(fd, pbuf, strlen(pbuf));
//printf("n=%d\n", n);
@ -205,7 +211,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "IF;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "IF00107041000+000000200000;";
n = write(fd, pbuf, strlen(pbuf));
//printf("n=%d\n", n);
@ -215,7 +221,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
int id = NC_RIGID_FT991;
SNPRINTF(buf, sizeof(buf), "ID%03d;", id);
n = write(fd, buf, strlen(buf));
@ -226,7 +232,7 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "AI;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "AI0;");
n = write(fd, buf, strlen(buf));
//printf("n=%d\n", n);
@ -235,7 +241,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "AI0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
}
else if (strcmp(buf, "AB;") == 0)
{
@ -249,7 +255,7 @@ int main(int argc, char *argv[])
if (strcmp(buf, "AI;"))
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = fprintf(fp, "%s", "AI0;");
printf("n=%d\n", n);
@ -261,12 +267,12 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "VS") == 0 && strlen(buf) > 3)
{
curr_vfo = buf[3] == '1' ? RIG_VFO_B : RIG_VFO_A;
usleep(50 * 1000);
hl_usleep(50 * 1000);
}
else if (strcmp(buf, "VS;") == 0)
{
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
pbuf = "VS0;";
if (curr_vfo == RIG_VFO_B || curr_vfo == RIG_VFO_SUB) { pbuf[2] = '1'; }
@ -278,7 +284,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "FT;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "FT%c;", tx_vfo);
printf(" FT response#1=%s, tx_vfo=%c\n", resp, tx_vfo);
n = write(fd, resp, strlen(resp));
@ -296,7 +302,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "MD0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "MD0%c;", modeA);
n = write(fd, resp, strlen(resp));
@ -308,7 +314,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "MD1;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "MD1%c;", modeB);
n = write(fd, resp, strlen(resp));
@ -320,7 +326,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "SM0;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "SM0111;");
n = write(fd, resp, strlen(resp));
@ -328,7 +334,7 @@ int main(int argc, char *argv[])
}
else if (strcmp(buf, "TX;") == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(resp, sizeof(resp), "TX%d;", ptt);
n = write(fd, resp, strlen(resp));
@ -336,7 +342,7 @@ int main(int argc, char *argv[])
}
else if (strncmp(buf, "TX", 2) == 0)
{
usleep(50 * 1000);
hl_usleep(50 * 1000);
ptt = buf[2] == '0' ? 0 : 1;
}
else if (strcmp(buf, "EX032;") == 0)
@ -344,7 +350,7 @@ int main(int argc, char *argv[])
static int ant = 0;
ant = (ant + 1) % 3;
printf("%s\n", buf);
usleep(50 * 1000);
hl_usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant);
n = write(fd, buf, strlen(buf));
//printf("n=%d\n", n);
@ -354,39 +360,39 @@ int main(int argc, char *argv[])
else if (strcmp(buf, "NA0;") == 0)
{
SNPRINTF(buf, sizeof(buf), "NA00;");
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
//printf("%s n=%d\n", buf, n);
}
else if (strcmp(buf, "RF0;") == 0)
{
SNPRINTF(buf, sizeof(buf), "RF0%d;", roofing_filter_main);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "RF1;") == 0)
{
SNPRINTF(buf, sizeof(buf), "RF1%d;", roofing_filter_sub);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "RF", 2) == 0)
{
SNPRINTF(buf, sizeof(buf), "RF%c%d;", buf[2],
buf[2] == 0 ? roofing_filter_main : roofing_filter_sub);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "SH0;") == 0)
{
SNPRINTF(buf, sizeof(buf), "SH%c%02d;", buf[2], width_main);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "SH1;") == 0)
{
SNPRINTF(buf, sizeof(buf), "SH%c%02d;", buf[2], width_sub);
usleep(50 * 1000);
hl_usleep(50 * 1000);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "SH", 2) == 0 && strlen(buf) > 4)