better Run()?

pull/12/head
Tom Early 7 years ago
parent 281b3d9fcb
commit 57d13e046f

@ -247,10 +247,9 @@ void CQnetITAP::Run(const char *cfgfile)
// there is something to read!
unsigned char buf[100];
ssize_t len;
REPLY_TYPE rt = RT_NOTHING;
if (FD_ISSET(serfd, &readfds)) {
rt = GetITAPData(buf);
REPLY_TYPE rt = GetITAPData(buf);
if (rt == RT_ERROR)
break;
@ -258,16 +257,6 @@ void CQnetITAP::Run(const char *cfgfile)
if (rt == RT_TIMEOUT)
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();
//printf("read %d bytes from ITAP\n", (int)buf[0]);
if (RT_DATA==rt || RT_HEADER==rt) {
@ -275,12 +264,18 @@ void CQnetITAP::Run(const char *cfgfile)
break;
} else {
switch (rt) {
//case RT_HEADER_ACK:
// printf("DEBUG: Run: got header acknowledgement\n");
// break;
//case RT_DATA_ACK:
// printf("DEBUG: Run: got data acknowledgement\n");
// break;
case RT_HEADER_ACK:
printf("HEADER_ACK");
for (int i=0; i<int(buf[0]) && i<100; i++)
printf(" %02X", buf[i]);
printf("\n");
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:
if (! is_alive) {
printf("Icom Radio is connected.\n");
@ -291,11 +286,24 @@ void CQnetITAP::Run(const char *cfgfile)
break;
}
}
} else if (0 == ::memcmp(buf, "DSTR", 4)) {
FD_CLR(serfd, &readfds);
}
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 (0 == memcmp(buf, "DSTR", 4)) {
//printf("read %d bytes from QnetGateway\n", (int)len);
if (ProcessGateway(len, buf))
break;
}
FD_CLR(ug2m, &readfds);
}
}
::close(serfd);

@ -36,8 +36,7 @@ enum REPLY_TYPE {
RT_DATA,
RT_HEADER_ACK,
RT_DATA_ACK,
RT_PONG,
RT_NOTHING
RT_PONG
};
// Icom Terminal and Access Point Mode data structure

Loading…
Cancel
Save

Powered by TurnKey Linux.