|
|
|
@ -247,10 +247,9 @@ void CQnetITAP::Run(const char *cfgfile)
|
|
|
|
// there is something to read!
|
|
|
|
// there is something to read!
|
|
|
|
unsigned char buf[100];
|
|
|
|
unsigned char buf[100];
|
|
|
|
ssize_t len;
|
|
|
|
ssize_t len;
|
|
|
|
REPLY_TYPE rt = RT_NOTHING;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FD_ISSET(serfd, &readfds)) {
|
|
|
|
if (FD_ISSET(serfd, &readfds)) {
|
|
|
|
rt = GetITAPData(buf);
|
|
|
|
REPLY_TYPE rt = GetITAPData(buf);
|
|
|
|
|
|
|
|
|
|
|
|
if (rt == RT_ERROR)
|
|
|
|
if (rt == RT_ERROR)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -258,16 +257,6 @@ void CQnetITAP::Run(const char *cfgfile)
|
|
|
|
if (rt == RT_TIMEOUT)
|
|
|
|
if (rt == RT_TIMEOUT)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
} else if (FD_ISSET(ug2m, &readfds)) {
|
|
|
|
|
|
|
|
len = Gate2Modem.Read(buf, 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
|
|
|
|
printf("ERROR: Run: recvfrom(gsock) returned error %d, %s\n", errno, strerror(errno));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rt != RT_NOTHING) {
|
|
|
|
|
|
|
|
lastdata = std::chrono::steady_clock::now();
|
|
|
|
lastdata = std::chrono::steady_clock::now();
|
|
|
|
//printf("read %d bytes from ITAP\n", (int)buf[0]);
|
|
|
|
//printf("read %d bytes from ITAP\n", (int)buf[0]);
|
|
|
|
if (RT_DATA==rt || RT_HEADER==rt) {
|
|
|
|
if (RT_DATA==rt || RT_HEADER==rt) {
|
|
|
|
@ -275,12 +264,18 @@ void CQnetITAP::Run(const char *cfgfile)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
switch (rt) {
|
|
|
|
switch (rt) {
|
|
|
|
//case RT_HEADER_ACK:
|
|
|
|
case RT_HEADER_ACK:
|
|
|
|
// printf("DEBUG: Run: got header acknowledgement\n");
|
|
|
|
printf("HEADER_ACK");
|
|
|
|
// break;
|
|
|
|
for (int i=0; i<int(buf[0]) && i<100; i++)
|
|
|
|
//case RT_DATA_ACK:
|
|
|
|
printf(" %02X", buf[i]);
|
|
|
|
// printf("DEBUG: Run: got data acknowledgement\n");
|
|
|
|
printf("\n");
|
|
|
|
// break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RT_DATA_ACK:
|
|
|
|
|
|
|
|
printf("DATA_ACK");
|
|
|
|
|
|
|
|
for (int i=0; i<int(buf[0]) && i<100; i++)
|
|
|
|
|
|
|
|
printf(" %02X", buf[i]);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
case RT_PONG:
|
|
|
|
case RT_PONG:
|
|
|
|
if (! is_alive) {
|
|
|
|
if (! is_alive) {
|
|
|
|
printf("Icom Radio is connected.\n");
|
|
|
|
printf("Icom Radio is connected.\n");
|
|
|
|
@ -291,10 +286,23 @@ void CQnetITAP::Run(const char *cfgfile)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (0 == ::memcmp(buf, "DSTR", 4)) {
|
|
|
|
FD_CLR(serfd, &readfds);
|
|
|
|
//printf("read %d bytes from QnetGateway\n", (int)len);
|
|
|
|
}
|
|
|
|
if (ProcessGateway(len, buf))
|
|
|
|
|
|
|
|
|
|
|
|
if (FD_ISSET(ug2m, &readfds)) {
|
|
|
|
|
|
|
|
len = Gate2Modem.Read(buf, 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
|
|
|
|
printf("ERROR: Run: recvfrom(gsock) returned error %d, %s\n", errno, strerror(errno));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 == memcmp(buf, "DSTR", 4)) {
|
|
|
|
|
|
|
|
//printf("read %d bytes from QnetGateway\n", (int)len);
|
|
|
|
|
|
|
|
if (ProcessGateway(len, buf))
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FD_CLR(ug2m, &readfds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|