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()
// 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);
if (ret < 0) {
printf("Error when reading first byte from the Icom radio %d: %s", errno, strerror(errno));
@ -153,17 +154,9 @@ REPLY_TYPE CQnetITAP::GetITAPData(unsigned char *buf)
unsigned int offset = 1U;
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);
if (ret < 0 && errno!=EAGAIN) {
if (ret<0 && errno!=EAGAIN) {
printf("Error when reading buffer from the Icom radio %d: %s\n", errno, strerror(errno));
return RT_ERROR;
}
@ -246,55 +239,44 @@ 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);
if (rt == RT_ERROR)
break;
if (rt == RT_TIMEOUT)
continue;
if (keep_running && FD_ISSET(serfd, &readfds)) {
lastdata = std::chrono::steady_clock::now();
switch (GetITAPData(buf)) {
case RT_ERROR:
keep_running = false;
break;
case RT_DATA:
case RT_HEADER:
if (ProcessITAP(buf))
keep_running = false;
break;
case RT_PONG:
if (! is_alive) {
printf("Icom Radio is connected.\n");
is_alive = true;
}
break;
default:
break;
}
FD_CLR(serfd, &readfds);
}
} else if (FD_ISSET(ug2m, &readfds)) {
len = Gate2Modem.Read(buf, 100);
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;
}
}
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) {
if (ProcessITAP(buf))
if (0 == memcmp(buf, "DSTR", 4)) {
//printf("read %d bytes from QnetGateway\n", (int)len);
if (ProcessGateway(len, buf))
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:
if (! is_alive) {
printf("Icom Radio is connected.\n");
is_alive = true;
}
break;
default:
break;
}
}
} else if (0 == ::memcmp(buf, "DSTR", 4)) {
//printf("read %d bytes from QnetGateway\n", (int)len);
if (ProcessGateway(len, buf))
break;
FD_CLR(ug2m, &readfds);
}
}

@ -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

@ -397,7 +397,7 @@ ModuleMenu () {
elif [[ "$key" == ad* ]]; then eval ${mod}_ack_delay="$value"
elif [[ "$key" == po* ]]; then eval ${mod}_power="$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" == rf* ]]; then eval ${mod}_rf_off="$value"
elif [[ "$key" == rl* ]]; then eval ${mod}_rx_level="$value"
@ -449,10 +449,15 @@ ModuleMenu () {
WriteCFGFile () {
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'
echo "# Created on `date`" > $outFile
# gateway_ section
echo "ircddb_login='$ircddb_login'" >> $outFile
echo "ircddb_login='$ircddb_login'" >> $outFile
[ -z "${ircddb_host+x}" ] || echo "ircddb_host='${ircddb_host}'" >> $outFile
[ -z "${ircddb_port+x}" ] || echo "ircddb_host=${ircddb_port}" >> $outFile
[ -z "${ircddb_password+x}" ] || echo "ircddb_password='${ircddb_password}'" >> $outFile

@ -3,6 +3,6 @@
#define LINK_VERSION "QnetLink7.0.1"
#define DVAP_VERSION "QnetDVAP-6.0.0"
#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 MMDVM_VERSION "QnetGateway-MMDVM-1.0.0"

Loading…
Cancel
Save

Powered by TurnKey Linux.