diff --git a/simulators/sim.h b/simulators/sim.h index b4de3454e..afb889042 100644 --- a/simulators/sim.h +++ b/simulators/sim.h @@ -92,3 +92,25 @@ int openPort(char *comport) // doesn't matter for using pts devices return fd; } #endif + +// Size of command buffer +#define BUFSIZE 256 + +int +getmyline5(int fd, unsigned char *buf) +{ + unsigned char c; + int i = 0; + int n = 0; + memset(buf, 0, BUFSIZE); + + while (i < 5 && read(fd, &c, 1) > 0) + { + buf[i++] = c; + n++; + } + + printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], + buf[4]); + return n; +} diff --git a/simulators/simft1000.c b/simulators/simft1000.c index 54d65c4df..14485a74d 100644 --- a/simulators/simft1000.c +++ b/simulators/simft1000.c @@ -5,7 +5,7 @@ #include #include -#define BUFSIZE 256 +#include "sim.h" float freqA = 14074000; float freqB = 14074500; @@ -17,28 +17,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -48,7 +26,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simft736.c b/simulators/simft736.c index fbea1dd2f..28b7c77b4 100644 --- a/simulators/simft736.c +++ b/simulators/simft736.c @@ -5,7 +5,7 @@ #include #include -#define BUFSIZE 256 +#include "sim.h" float freqA = 14074000; float freqB = 14074500; @@ -17,28 +17,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -48,7 +26,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simft747gx.c b/simulators/simft747gx.c index 1087fc175..a52076cb5 100644 --- a/simulators/simft747gx.c +++ b/simulators/simft747gx.c @@ -7,7 +7,7 @@ #include #include -#define BUFSIZE 256 +#include "sim.h" float freqA = 14074000; float freqB = 14074500; @@ -19,28 +19,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -50,7 +28,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simft817.c b/simulators/simft817.c index c14c0315b..583c24f16 100644 --- a/simulators/simft817.c +++ b/simulators/simft817.c @@ -5,7 +5,7 @@ #include #include -#define BUFSIZE 256 +#include "sim.h" int vfo = 0; // 0=A, !0=B float freqA = 14074000; @@ -18,28 +18,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -49,7 +27,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simft847.c b/simulators/simft847.c index 900406547..d05f4c721 100644 --- a/simulators/simft847.c +++ b/simulators/simft847.c @@ -6,7 +6,7 @@ #include //#include "hamlib/rig.h" -#define BUFSIZE 256 +#include "sim.h" /* In hono(u)r of the 10Hz resolution of the FT-847, vfo frequencies * are stored in decaHertz(daHz) @@ -19,28 +19,6 @@ int width_sub = 700; int vfo; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -52,7 +30,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simft897.c b/simulators/simft897.c index e12bc4d68..336e1951d 100644 --- a/simulators/simft897.c +++ b/simulators/simft897.c @@ -8,7 +8,7 @@ #include #include "hamlib/rig.h" -#define BUFSIZE 256 +#include "sim.h" float freqA = 14074000; float freqB = 14074500; @@ -20,28 +20,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -53,7 +31,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simft990.c b/simulators/simft990.c index 1139f0ee4..f10cf27fb 100644 --- a/simulators/simft990.c +++ b/simulators/simft990.c @@ -49,25 +49,6 @@ static void load_dat(const char *filename, unsigned char buf[1492]) static unsigned char alldata[1492]; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - #include "sim.h" @@ -80,7 +61,7 @@ int main(int argc, char *argv[]) while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { continue; } diff --git a/simulators/simjupiter.c b/simulators/simjupiter.c index badcc73b0..706546cae 100644 --- a/simulators/simjupiter.c +++ b/simulators/simjupiter.c @@ -5,7 +5,7 @@ #include #include -#define BUFSIZE 256 +#include "sim.h" float freqA = 14074000; float freqB = 14074500; @@ -17,28 +17,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -48,7 +26,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) { diff --git a/simulators/simspid.c b/simulators/simspid.c index a38811e88..1218d13f2 100644 --- a/simulators/simspid.c +++ b/simulators/simspid.c @@ -5,7 +5,7 @@ #include #include -#define BUFSIZE 256 +#include "sim.h" float freqA = 14074000; float freqB = 14074500; @@ -17,28 +17,6 @@ int width_main = 500; int width_sub = 700; -int -getmyline(int fd, unsigned char *buf) -{ - unsigned char c; - int i = 0; - int n = 0; - memset(buf, 0, BUFSIZE); - - while (i < 5 && read(fd, &c, 1) > 0) - { - buf[i++] = c; - n++; - } - - printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], - buf[4]); - return n; -} - -#include "sim.h" - - int main(int argc, char *argv[]) { unsigned char buf[BUFSIZE]; @@ -49,7 +27,7 @@ again: while (1) { - int bytes = getmyline(fd, buf); + int bytes = getmyline5(fd, buf); if (bytes == 0) {