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! // 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,11 +286,24 @@ void CQnetITAP::Run(const char *cfgfile)
break; 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); //printf("read %d bytes from QnetGateway\n", (int)len);
if (ProcessGateway(len, buf)) if (ProcessGateway(len, buf))
break; break;
} }
FD_CLR(ug2m, &readfds);
}
} }
::close(serfd); ::close(serfd);

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

Loading…
Cancel
Save

Powered by TurnKey Linux.