2022-07-31 07:10:15 -05:00
|
|
|
// can run this using rigctl/rigctld and socat pty devices
|
|
|
|
|
// emulates 1.2 ROM FT990 which can only read 1492 bytes
|
2023-05-08 12:04:08 -05:00
|
|
|
#define _XOPEN_SOURCE 700
|
|
|
|
|
// since we are POSIX here we need this
|
2022-07-31 07:10:15 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2025-08-05 22:16:48 +02:00
|
|
|
#include "sim.h"
|
2022-07-31 07:10:15 -05:00
|
|
|
|
|
|
|
|
float freqA = 14074000;
|
|
|
|
|
float freqB = 14074500;
|
|
|
|
|
char tx_vfo = '0';
|
|
|
|
|
char rx_vfo = '0';
|
|
|
|
|
char modeA = '1';
|
|
|
|
|
char modeB = '1';
|
|
|
|
|
int width_main = 500;
|
|
|
|
|
int width_sub = 700;
|
|
|
|
|
|
2025-08-05 21:41:32 +02:00
|
|
|
#define ALL_DATA_SIZE 1492
|
2022-07-31 07:10:15 -05:00
|
|
|
|
2025-08-05 21:41:32 +02:00
|
|
|
static void load_dat(const char *filename, unsigned char buf[ALL_DATA_SIZE])
|
2022-07-31 07:10:15 -05:00
|
|
|
{
|
|
|
|
|
FILE *fp = fopen(filename, "r");
|
|
|
|
|
char line[4096];
|
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
|
|
while (fgets(line, sizeof(line), fp))
|
|
|
|
|
{
|
|
|
|
|
char *s = strdup(line);
|
|
|
|
|
unsigned int val;
|
|
|
|
|
char *p = strtok(line, " \r\n");
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
sscanf(p, "%x", &val);
|
|
|
|
|
buf[n++] = val;
|
|
|
|
|
}
|
2025-08-05 20:38:57 +02:00
|
|
|
while ((p = strtok(NULL, " \r\n")));
|
2022-07-31 07:10:15 -05:00
|
|
|
|
|
|
|
|
strtok(s, "\r\n");
|
|
|
|
|
//printf("n=%d, %s\n",n,s);
|
|
|
|
|
free(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(fp);
|
2025-08-05 22:16:48 +02:00
|
|
|
printf("%d bytes read from file %s\n", n, filename);
|
2022-07-31 07:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-05 21:41:32 +02:00
|
|
|
static unsigned char alldata[ALL_DATA_SIZE];
|
2022-07-31 07:10:15 -05:00
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2025-08-05 20:49:41 +02:00
|
|
|
unsigned char buf[BUFSIZE];
|
2022-07-31 07:10:15 -05:00
|
|
|
int fd = openPort(argv[1]);
|
|
|
|
|
|
|
|
|
|
load_dat("simft990.dat", alldata);
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2025-08-03 22:26:23 +02:00
|
|
|
int bytes = getmyline5(fd, buf);
|
2022-07-31 07:10:15 -05:00
|
|
|
|
|
|
|
|
if (bytes == 0) { continue; }
|
|
|
|
|
|
|
|
|
|
if (bytes != 5)
|
|
|
|
|
{
|
|
|
|
|
printf("Not 5 bytes? bytes=%d\n", bytes);
|
2025-08-05 22:16:48 +02:00
|
|
|
continue;
|
2022-07-31 07:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-05 22:16:48 +02:00
|
|
|
// Protocol of rigs/yaesu/ft990v12.c
|
|
|
|
|
|
2022-07-31 07:10:15 -05:00
|
|
|
if (buf[4] == 0x10)
|
|
|
|
|
{
|
2025-08-05 21:41:32 +02:00
|
|
|
write(fd, alldata, ALL_DATA_SIZE);
|
2022-07-31 07:10:15 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|