Merge branch 'itry'

pull/12/head
Tom Early 7 years ago
commit 2a90fa7531

@ -130,7 +130,8 @@ REPLY_TYPE CQnetITAP::GetITAPData(unsigned char *buf)
{ {
// Shamelessly adapted from Jonathan G4KLX's CIcomController::GetResponse() // Shamelessly adapted from Jonathan G4KLX's CIcomController::GetResponse()
// and CSerialController::read() // and CSerialController::read()
// Get the start of the frame or nothing at all
// Get the buffer size or nothing at all
int ret = ::read(serfd, buf, 1U); int ret = ::read(serfd, buf, 1U);
if (ret < 0) { if (ret < 0) {
printf("Error when reading first byte from the Icom radio %d: %s", errno, strerror(errno)); printf("Error when reading first byte from the Icom radio %d: %s", errno, strerror(errno));
@ -153,14 +154,6 @@ REPLY_TYPE CQnetITAP::GetITAPData(unsigned char *buf)
unsigned int offset = 1U; unsigned int offset = 1U;
while (offset < length) { while (offset < length) {
fd_set fds;
FD_ZERO(&fds);
FD_SET(serfd, &fds);
int n = ::select(serfd+1, &fds, NULL, NULL, NULL); // wait untill it's ready. won't return a zero.
if (n < 0) {
printf("ERROR: GetITAPData: select returned error %d: %s\n", errno, strerror(errno));
return RT_ERROR;
}
ret = ::read(serfd, buf + offset, length - offset); ret = ::read(serfd, buf + offset, length - offset);
if (ret<0 && errno!=EAGAIN) { if (ret<0 && errno!=EAGAIN) {
@ -246,41 +239,18 @@ 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;
REPLY_TYPE rt = RT_NOTHING;
if (FD_ISSET(serfd, &readfds)) {
rt = GetITAPData(buf);
if (rt == RT_ERROR)
break;
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) { if (keep_running && FD_ISSET(serfd, &readfds)) {
lastdata = std::chrono::steady_clock::now(); lastdata = std::chrono::steady_clock::now();
//printf("read %d bytes from ITAP\n", (int)buf[0]); switch (GetITAPData(buf)) {
if (RT_DATA==rt || RT_HEADER==rt) { case RT_ERROR:
keep_running = false;
break;
case RT_DATA:
case RT_HEADER:
if (ProcessITAP(buf)) if (ProcessITAP(buf))
keep_running = false;
break; 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_PONG: case RT_PONG:
if (! is_alive) { if (! is_alive) {
printf("Icom Radio is connected.\n"); printf("Icom Radio is connected.\n");
@ -290,12 +260,24 @@ void CQnetITAP::Run(const char *cfgfile)
default: default:
break; break;
} }
FD_CLR(serfd, &readfds);
}
if (keep_running && FD_ISSET(ug2m, &readfds)) {
ssize_t len = Gate2Modem.Read(buf, 100);
if (len < 0) {
printf("ERROR: Run: recvfrom(gsock) returned error %d, %s\n", errno, strerror(errno));
break;
} }
} else if (0 == ::memcmp(buf, "DSTR", 4)) {
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

@ -397,7 +397,7 @@ ModuleMenu () {
elif [[ "$key" == ad* ]]; then eval ${mod}_ack_delay="$value" elif [[ "$key" == ad* ]]; then eval ${mod}_ack_delay="$value"
elif [[ "$key" == po* ]]; then eval ${mod}_power="$value" elif [[ "$key" == po* ]]; then eval ${mod}_power="$value"
elif [[ "$key" == sq* ]]; then eval ${mod}_squelch="$value" elif [[ "$key" == sq* ]]; then eval ${mod}_squelch="$value"
elif [[ "$key" == sn* ]]; then eval ${mod}_serial_number="$value" elif [[ "$key" == sn* ]]; then eval ${mod}_serial_number="${value^^}"
elif [[ "$key" == rn* ]]; then eval ${mod}_rf_on="$value" elif [[ "$key" == rn* ]]; then eval ${mod}_rf_on="$value"
elif [[ "$key" == rf* ]]; then eval ${mod}_rf_off="$value" elif [[ "$key" == rf* ]]; then eval ${mod}_rf_off="$value"
elif [[ "$key" == rl* ]]; then eval ${mod}_rx_level="$value" elif [[ "$key" == rl* ]]; then eval ${mod}_rx_level="$value"
@ -449,6 +449,11 @@ ModuleMenu () {
WriteCFGFile () { WriteCFGFile () {
local m p q outFile local m p q outFile
if [ -z "$ircddb_login" ]; then
echo "You MUST set your ircddb login callsign (in the ircddb section)!"
read -p "Press <Enter> to continue: " ans
return
fi
outFile='./qn.cfg' outFile='./qn.cfg'
echo "# Created on `date`" > $outFile echo "# Created on `date`" > $outFile
# gateway_ section # gateway_ section

@ -3,6 +3,6 @@
#define LINK_VERSION "QnetLink7.0.1" #define LINK_VERSION "QnetLink7.0.1"
#define DVAP_VERSION "QnetDVAP-6.0.0" #define DVAP_VERSION "QnetDVAP-6.0.0"
#define RELAY_VERSION "QnetRelay-1.0.1" #define RELAY_VERSION "QnetRelay-1.0.1"
#define ITAP_VERSION "QnetITAP-1.0.0" #define ITAP_VERSION "QnetITAP-1.0.1"
#define DVRPTR_VERSION "QnetDVRPTR-6.0.1" #define DVRPTR_VERSION "QnetDVRPTR-6.0.1"
#define MMDVM_VERSION "QnetGateway-MMDVM-1.0.0" #define MMDVM_VERSION "QnetGateway-MMDVM-1.0.0"

Loading…
Cancel
Save

Powered by TurnKey Linux.