traceit to printf

pull/1/head
Tom Early 8 years ago
parent f8b801fc5a
commit 89dbfb2999

@ -28,8 +28,6 @@
#include "DVAPDongle.h"
extern void traceit(const char *fmt,...);
CDVAPDongle::CDVAPDongle() : MAX_REPL_CNT(20u)
{
}
@ -58,10 +56,10 @@ bool CDVAPDongle::Initialize(char *serialno, int frequency, int offset, int powe
close(serfd);
serfd = -1;
ok = false;
traceit("Device %s is already locked/used\n", device);
printf("Device %s is already locked/used\n", device);
continue;
}
traceit("Device %s now locked for exclusive use\n", device);
printf("Device %s now locked for exclusive use\n", device);
ok = get_ser(device, serialno);
if (!ok) {
@ -149,7 +147,7 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr)
case 0xc012u:
break; // these are all expected headers
default:
traceit("unknown header=0x%d\n", (unsigned)dr.header);
printf("unknown header=0x%d\n", (unsigned)dr.header);
if (syncit())
return RT_ERR;
return RT_TIMEOUT;
@ -228,7 +226,7 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr)
case 0xc012u:
return RT_DAT;
}
traceit("Unrecognized data from dvap: header=%#x control=%#x\n", (unsigned)dr.header, (unsigned)dr.param.control);
printf("Unrecognized data from dvap: header=%#x control=%#x\n", (unsigned)dr.header, (unsigned)dr.param.control);
if (syncit())
return RT_ERR;
return RT_TIMEOUT;
@ -241,7 +239,7 @@ bool CDVAPDongle::syncit()
fd_set fds;
short cnt = 0;
traceit("Starting syncing dvap\n");
printf("Starting syncing dvap\n");
memset(data, 0x00, 7);
dvapreg.header = 0x2007u;
dvapreg.param.control = 0x90u;
@ -255,7 +253,7 @@ bool CDVAPDongle::syncit()
if (n <= 0) {
cnt ++;
if (cnt > 100) {
traceit("syncit() uncessful...stopping\n");
printf("syncit() uncessful...stopping\n");
return true;
}
} else {
@ -274,7 +272,7 @@ bool CDVAPDongle::syncit()
}
}
}
traceit("Stopping syncing dvap\n");
printf("Stopping syncing dvap\n");
return false;
}
@ -287,7 +285,7 @@ bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number)
int rc = write_to_dvp(&dvapreg, 4);
if (rc != 4) {
traceit("Failed to send request to get dvap serial#\n");
printf("Failed to send request to get dvap serial#\n");
return false;
}
@ -297,16 +295,16 @@ bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number)
reply = GetReply(dvapreg);
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to receive dvap serial#\n");
printf("Reached max number of requests to receive dvap serial#\n");
return false;
}
} while (reply != RT_SER);
if (0 == strcmp(dvapreg.param.sstr, dvap_serial_number)) {
traceit("Using %s: %s, because serial number matches your dvap_rptr.cfg\n", dvp, dvap_serial_number);
printf("Using %s: %s, because serial number matches your dvap_rptr.cfg\n", dvp, dvap_serial_number);
return true;
}
traceit("Device %s has serial %s, but does not match your config value %s\n", dvp, dvapreg.param.sstr, dvap_serial_number);
printf("Device %s has serial %s, but does not match your config value %s\n", dvp, dvapreg.param.sstr, dvap_serial_number);
return false;
}
@ -319,7 +317,7 @@ bool CDVAPDongle::get_name()
int rc = write_to_dvp(&dvapreg, 4);
if (rc != 4) {
traceit("Failed to send request to get dvap name\n");
printf("Failed to send request to get dvap name\n");
return false;
}
@ -329,17 +327,17 @@ bool CDVAPDongle::get_name()
reply = GetReply(dvapreg);
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to receive dvap name\n");
printf("Reached max number of requests to receive dvap name\n");
return false;
}
} while (reply != RT_NAME);
if (0x10u!=dvapreg.header || 0x1u!=dvapreg.param.control || strncmp(dvapreg.param.sstr, "DVAP Dongle", 11)) {
traceit("Failed to receive dvap name, got %s\n", dvapreg.param.sstr);
printf("Failed to receive dvap name, got %s\n", dvapreg.param.sstr);
return false;
}
traceit("Device name: %.*s\n", 11, dvapreg.param.sstr);
printf("Device name: %.*s\n", 11, dvapreg.param.sstr);
return true;
}
@ -353,7 +351,7 @@ bool CDVAPDongle::get_fw()
int rc = write_to_dvp(&dvapreg, 5);
if (rc != 5) {
traceit("Failed to send request to get dvap fw\n");
printf("Failed to send request to get dvap fw\n");
return false;
}
@ -363,13 +361,13 @@ bool CDVAPDongle::get_fw()
reply = GetReply(dvapreg);
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to receive dvap fw\n");
printf("Reached max number of requests to receive dvap fw\n");
return false;
}
} while (reply != RT_FW);
unsigned int ver = dvapreg.param.ustr[1] + 256 * dvapreg.param.ustr[2];
traceit("dvap fw ver: %u.%u\n", ver / 100, ver % 100);
printf("dvap fw ver: %u.%u\n", ver / 100, ver % 100);
return true;
}
@ -384,7 +382,7 @@ bool CDVAPDongle::set_modu()
int rc = write_to_dvp(&dvapreg, 5);
if (rc != 5) {
traceit("Failed to send request to set dvap modulation\n");
printf("Failed to send request to set dvap modulation\n");
return false;
}
@ -395,7 +393,7 @@ bool CDVAPDongle::set_modu()
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to set dvap modulation\n");
printf("Reached max number of requests to set dvap modulation\n");
return false;
}
} while (reply != RT_MODU);
@ -413,7 +411,7 @@ bool CDVAPDongle::set_mode()
int rc = write_to_dvp(&dvapreg, 5);
if (rc != 5) {
traceit("Failed to send request to set dvap mode\n");
printf("Failed to send request to set dvap mode\n");
return false;
}
@ -424,7 +422,7 @@ bool CDVAPDongle::set_mode()
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to set dvap mode\n");
printf("Reached max number of requests to set dvap mode\n");
return false;
}
} while (reply != RT_MODE);
@ -440,17 +438,17 @@ bool CDVAPDongle::set_sql(int squelch)
dvapreg.header = 0x5u;
dvapreg.param.control = 0x80u;
if (squelch < -128) {
traceit("Squelch setting of %d too small, resetting...\n", squelch);
printf("Squelch setting of %d too small, resetting...\n", squelch);
squelch = -128;
} else if (squelch > -45) {
traceit("Squelch setting of %d too large, resetting...\n", squelch);
printf("Squelch setting of %d too large, resetting...\n", squelch);
squelch = -45;
}
dvapreg.param.byte = (int8_t)squelch;
int rc = write_to_dvp(&dvapreg, 5);
if (rc != 5) {
traceit("Failed to send request to set dvap sql\n");
printf("Failed to send request to set dvap sql\n");
return false;
}
@ -461,11 +459,11 @@ bool CDVAPDongle::set_sql(int squelch)
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to set dvap sql\n");
printf("Reached max number of requests to set dvap sql\n");
return false;
}
} while (reply != RT_SQL);
traceit("DVAP squelch is %d dB\n", (int)dvapreg.param.byte);
printf("DVAP squelch is %d dB\n", (int)dvapreg.param.byte);
return true;
}
@ -477,17 +475,17 @@ bool CDVAPDongle::set_pwr(int power)
dvapreg.header = 0x6u;
dvapreg.param.control = 0x138u;
if (power < -12) {
traceit("Power setting of %d is too low, resetting...\n", power);
printf("Power setting of %d is too low, resetting...\n", power);
power = -12;
} else if (power > 10) {
traceit("Power setting of %d is too high, resetting...\n", power);
printf("Power setting of %d is too high, resetting...\n", power);
power = 10;
}
dvapreg.param.word = (int16_t)power;
int rc = write_to_dvp(&dvapreg, 6);
if (rc != 6) {
traceit("Failed to send request to set dvap pwr\n");
printf("Failed to send request to set dvap pwr\n");
return false;
}
@ -498,11 +496,11 @@ bool CDVAPDongle::set_pwr(int power)
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to set dvap pwr\n");
printf("Reached max number of requests to set dvap pwr\n");
return false;
}
} while (reply != RT_PWR);
traceit("DVAP power is %d dB\n", (int)dvapreg.param.word);
printf("DVAP power is %d dB\n", (int)dvapreg.param.word);
return true;
}
@ -514,17 +512,17 @@ bool CDVAPDongle::set_off(int offset)
dvapreg.header = 0x6u;
dvapreg.param.control = 0x400u;
if (offset < -2000) {
traceit("Offset of %d is too low, resetting...\n", offset);
printf("Offset of %d is too low, resetting...\n", offset);
offset = -2000;
} else if (offset > 2000) {
traceit("Offset of %d is too high, resetting...\n", offset);
printf("Offset of %d is too high, resetting...\n", offset);
offset = 2000;
}
dvapreg.param.word = (int16_t)offset;
int rc = write_to_dvp(&dvapreg, 6);
if (rc != 6) {
traceit("Failed to send request to set dvap offset\n");
printf("Failed to send request to set dvap offset\n");
return false;
}
@ -535,11 +533,11 @@ bool CDVAPDongle::set_off(int offset)
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to set dvap offset\n");
printf("Reached max number of requests to set dvap offset\n");
return false;
}
} while (reply != RT_OFF);
traceit("DVAP offset is %d Hz\n", (int)dvapreg.param.word);
printf("DVAP offset is %d Hz\n", (int)dvapreg.param.word);
return true;
}
@ -554,7 +552,7 @@ bool CDVAPDongle::set_freq(int frequency)
int rc = write_to_dvp(&dvapreg, 4);
if (rc != 4) {
traceit("Failed to send request for frequency limits\n");
printf("Failed to send request for frequency limits\n");
return false;
}
@ -565,18 +563,18 @@ bool CDVAPDongle::set_freq(int frequency)
cnt++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests for dvap frequency limits\n");
printf("Reached max number of requests for dvap frequency limits\n");
return false;
}
} while (reply != RT_FREQ_LIMIT);
traceit("DVAP Frequency limits are from %d to %d Hz\n", dvapreg.param.twod[0], dvapreg.param.twod[1]);
printf("DVAP Frequency limits are from %d to %d Hz\n", dvapreg.param.twod[0], dvapreg.param.twod[1]);
// okay, now we know the frequency limits, get on with the show...
if (frequency < dvapreg.param.twod[0]) {
traceit("Frequency of %d is too small, resetting...\n", frequency);
printf("Frequency of %d is too small, resetting...\n", frequency);
frequency = dvapreg.param.twod[0];
} else if (frequency > dvapreg.param.twod[1]) {
traceit("Frequency of %d is too large, resetting...\n", frequency);
printf("Frequency of %d is too large, resetting...\n", frequency);
frequency = dvapreg.param.twod[1];
}
@ -587,7 +585,7 @@ bool CDVAPDongle::set_freq(int frequency)
rc = write_to_dvp(&dvapreg, 8);
if (rc != 8) {
traceit("Failed to send request to set dvap frequency\n");
printf("Failed to send request to set dvap frequency\n");
return false;
}
@ -598,11 +596,11 @@ bool CDVAPDongle::set_freq(int frequency)
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to set dvap frequency\n");
printf("Reached max number of requests to set dvap frequency\n");
return false;
}
} while (reply != RT_FREQ);
traceit("DVAP frequency is %d Hz\n", dvapreg.param.dword);
printf("DVAP frequency is %d Hz\n", dvapreg.param.dword);
return true;
}
@ -617,7 +615,7 @@ bool CDVAPDongle::start_dvap()
int rc = write_to_dvp(&dvapreg, 5);
if (rc != 5) {
traceit("Failed to send request to start the dvap dongle\n");
printf("Failed to send request to start the dvap dongle\n");
return false;
}
@ -628,7 +626,7 @@ bool CDVAPDongle::start_dvap()
cnt ++;
if (cnt >= MAX_REPL_CNT) {
traceit("Reached max number of requests to start the dvap dongle\n");
printf("Reached max number of requests to start the dvap dongle\n");
return false;
}
} while (reply != RT_START);
@ -654,7 +652,7 @@ int CDVAPDongle::write_to_dvp(const void *buffer, const unsigned int len)
while (ptr < len) {
ssize_t n = write(serfd, buf + ptr, len - ptr);
if (n < 0) {
traceit("Error %d writing to dvap, message=%s\n", errno, strerror(errno));
printf("Error %d writing to dvap, message=%s\n", errno, strerror(errno));
return -1;
}
@ -691,7 +689,7 @@ int CDVAPDongle::read_from_dvp(void *buffer, unsigned int len)
n = select(serfd + 1, &fds, NULL, NULL, NULL);
if (n < 0) {
traceit("select error=%d on dvap\n", errno);
printf("select error=%d on dvap\n", errno);
return -1;
}
@ -711,19 +709,19 @@ bool CDVAPDongle::OpenSerial(char *device)
serfd = open(device, O_RDWR | O_NOCTTY | O_NDELAY, 0);
if (serfd < 0) {
traceit("Failed to open device [%s], error=%d, message=%s\n", device, errno, strerror(errno));
printf("Failed to open device [%s], error=%d, message=%s\n", device, errno, strerror(errno));
return false;
}
if (isatty(serfd) == 0) {
traceit("Device %s is not a tty device\n", device);
printf("Device %s is not a tty device\n", device);
close(serfd);
serfd = -1;
return false;
}
if (tcgetattr(serfd, &t) < 0) {
traceit("tcgetattr failed for %s, error=%d, message-%s\n", device, errno, strerror(errno));
printf("tcgetattr failed for %s, error=%d, message-%s\n", device, errno, strerror(errno));
close(serfd);
serfd = -1;
return false;
@ -741,7 +739,7 @@ bool CDVAPDongle::OpenSerial(char *device)
cfsetispeed(&t, B230400);
if (tcsetattr(serfd, TCSANOW, &t) < 0) {
traceit("tcsetattr failed for %s, error=%dm message=%s\n", device, errno, strerror(errno));
printf("tcsetattr failed for %s, error=%dm message=%s\n", device, errno, strerror(errno));
close(serfd);
serfd = -1;
return false;

@ -75,7 +75,7 @@ void IRCClient::Entry()
int result = getAllIPV4Addresses(local_addr, 0, &numAddr, &myaddr, 1);
if ((result != 0) || (numAddr != 1)) {
traceit("IRCClient::Entry: local address not parseable, using 0.0.0.0\n");
printf("IRCClient::Entry: local address not parseable, using 0.0.0.0\n");
memset(&myaddr, 0x00, sizeof(struct sockaddr_in));
}
@ -88,7 +88,7 @@ void IRCClient::Entry()
switch (state) {
case 0:
if (terminateThread) {
traceit("IRCClient::Entry: thread terminated at state=%d\n", state);
printf("IRCClient::Entry: thread terminated at state=%d\n", state);
return;
}
@ -96,7 +96,7 @@ void IRCClient::Entry()
timer = 30;
if (getAllIPV4Addresses(host_name, port, &numAddr, addr, MAXIPV4ADDR) == 0) {
//traceit("IRCClient::Entry: number of DNS entries %d\n", numAddr);
//printf("IRCClient::Entry: number of DNS entries %d\n", numAddr);
if (numAddr > 0) {
currentAddr = 0;
state = 1;
@ -108,7 +108,7 @@ void IRCClient::Entry()
case 1:
if (terminateThread) {
traceit("IRCClient::Entry: thread terminated at state=%d\n", state);
printf("IRCClient::Entry: thread terminated at state=%d\n", state);
return;
}
@ -116,12 +116,12 @@ void IRCClient::Entry()
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0) {
traceit("IRCClient::Entry: could not create socket!\n");
printf("IRCClient::Entry: could not create socket!\n");
timer = 30;
state = 0;
} else {
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
traceit("IRCClient::Entry: fcntl error\n");
printf("IRCClient::Entry: fcntl error\n");
close(sock);
timer = 30;
state = 0;
@ -131,12 +131,12 @@ void IRCClient::Entry()
int res;
if ((h[0] != 0) || (h[1] != 0) || (h[2] != 0) || (h[3] != 0))
traceit("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
printf("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
res = bind(sock, (struct sockaddr *) &myaddr, sizeof (struct sockaddr_in));
if (res != 0) {
traceit("IRCClient::Entry: bind error\n");
printf("IRCClient::Entry: bind error\n");
close(sock);
state = 0;
timer = 30;
@ -145,20 +145,20 @@ void IRCClient::Entry()
h = (unsigned char *) &(addr[currentAddr].sin_addr);
//traceit("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
//printf("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
res = connect(sock, (struct sockaddr *) (addr + currentAddr), sizeof (struct sockaddr_in));
if (res == 0) {
traceit("IRCClient::Entry: connected to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
printf("IRCClient::Entry: connected to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
state = 4;
} else {
if (errno == EINPROGRESS) {
//traceit("IRCClient::Entry: connect in progress\n");
//printf("IRCClient::Entry: connect in progress\n");
state = 3;
timer = 10; // 5 second timeout
} else {
traceit("IRCClient::Entry: connect\n");
printf("IRCClient::Entry: connect\n");
close(sock);
currentAddr++;
if (currentAddr >= numAddr) {
@ -185,7 +185,7 @@ void IRCClient::Entry()
int res = select(sock+1, NULL, &myset, NULL, &tv);
if (res < 0) {
traceit("IRCClient::Entry: select\n");
printf("IRCClient::Entry: select\n");
close(sock);
state = 0;
timer = 30;
@ -196,13 +196,13 @@ void IRCClient::Entry()
val_len = sizeof value;
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) {
traceit("IRCClient::Entry: getsockopt error\n");
printf("IRCClient::Entry: getsockopt error\n");
close(sock);
state = 0;
timer = 30;
} else {
if (value != 0) {
traceit("IRCClient::Entry: SO_ERROR=%d\n", value);
printf("IRCClient::Entry: SO_ERROR=%d\n", value);
close(sock);
currentAddr ++;
if (currentAddr >= numAddr) {
@ -213,14 +213,14 @@ void IRCClient::Entry()
timer = 2;
}
} else {
traceit("IRCClient::Entry: connected2\n");
printf("IRCClient::Entry: connected2\n");
state = 4;
}
}
} else if (timer == 0) {
// select timeout and timer timeout
//traceit("IRCClient::Entry: connect timeout\n");
//printf("IRCClient::Entry: connect timeout\n");
close(sock);
currentAddr++;
if (currentAddr >= numAddr) {
@ -278,17 +278,17 @@ void IRCClient::Entry()
int r = send(sock, buf, len, 0);
if (r != len) {
traceit("IRCClient::Entry: short write %d < %d\n", r, len);
printf("IRCClient::Entry: short write %d < %d\n", r, len);
timer = 0;
state = 6;
}
/* else
{
traceit("write %d bytes (%s)\n", len, out.c_str());
printf("write %d bytes (%s)\n", len, out.c_str());
} */
} else {
traceit("IRCClient::Entry: no NL at end, len=%d\n", len);
printf("IRCClient::Entry: no NL at end, len=%d\n", len);
timer = 0;
state = 6;
@ -317,7 +317,7 @@ void IRCClient::Entry()
close(sock);
if (terminateThread) { // request to end the thread
traceit("IRCClient::Entry: thread terminated at state=%d\n", state);
printf("IRCClient::Entry: thread terminated at state=%d\n", state);
return;
}

@ -32,7 +32,7 @@ CIRCDDB::~CIRCDDB()
// A false return implies a network error, or unable to log in
bool CIRCDDB::open()
{
traceit("start");
printf("start");
return d->client->startWork() && d->app->startWork();
}
@ -65,27 +65,27 @@ bool CIRCDDB::sendHeard(const std::string &myCall, const std::string &myCallExt,
const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3)
{
if (myCall.size() != 8) {
traceit("CIRCDDB::sendHeard:myCall: len != 8");
printf("CIRCDDB::sendHeard:myCall: len != 8");
return false;
}
if (myCallExt.size() != 4) {
traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
printf("CIRCDDB::sendHeard:myCallExt: len != 4");
return false;
}
if (yourCall.size() != 8) {
traceit("CIRCDDB::sendHeard:yourCall: len != 8");
printf("CIRCDDB::sendHeard:yourCall: len != 8");
return false;
}
if (rpt1.size() != 8) {
traceit("CIRCDDB::sendHeard:rpt1: len != 8");
printf("CIRCDDB::sendHeard:rpt1: len != 8");
return false;
}
if (rpt2.size() != 8) {
traceit("CIRCDDB::sendHeard:rpt2: len != 8");
printf("CIRCDDB::sendHeard:rpt2: len != 8");
return false;
}
@ -97,27 +97,27 @@ bool CIRCDDB::sendHeardWithTXMsg(const std::string &myCall, const std::string &m
unsigned char flag2, unsigned char flag3, const std::string &network_destination, const std::string &tx_message)
{
if (myCall.size() != 8) {
traceit("CIRCDDB::sendHeard:myCall: len != 8");
printf("CIRCDDB::sendHeard:myCall: len != 8");
return false;
}
if (myCallExt.size() != 4) {
traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
printf("CIRCDDB::sendHeard:myCallExt: len != 4");
return false;
}
if (yourCall.size() != 8) {
traceit("CIRCDDB::sendHeard:yourCall: len != 8");
printf("CIRCDDB::sendHeard:yourCall: len != 8");
return false;
}
if (rpt1.size() != 8) {
traceit("CIRCDDB::sendHeard:rpt1: len != 8");
printf("CIRCDDB::sendHeard:rpt1: len != 8");
return false;
}
if (rpt2.size() != 8) {
traceit("CIRCDDB::sendHeard:rpt2: len != 8");
printf("CIRCDDB::sendHeard:rpt2: len != 8");
return false;
}
@ -127,7 +127,7 @@ bool CIRCDDB::sendHeardWithTXMsg(const std::string &myCall, const std::string &m
dest = " ";
if (dest.size() != 8) {
traceit("CIRCDDB::sendHeard:network_destination: len != 8");
printf("CIRCDDB::sendHeard:network_destination: len != 8");
return false;
}
@ -154,42 +154,42 @@ bool CIRCDDB::sendHeardWithTXStats(const std::string &myCall, const std::string
unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors)
{
if (num_dv_frames<= 0 || num_dv_frames>65535) {
traceit("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535");
printf("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535");
return false;
}
if (num_dv_silent_frames > num_dv_frames) {
traceit("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames");
printf("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames");
return false;
}
if (num_bit_errors > 4*num_dv_frames) { // max 4 bit errors per frame
traceit("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)");
printf("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)");
return false;
}
if (myCall.size() != 8) {
traceit("CIRCDDB::sendHeard:myCall: len != 8");
printf("CIRCDDB::sendHeard:myCall: len != 8");
return false;
}
if (myCallExt.size() != 4) {
traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
printf("CIRCDDB::sendHeard:myCallExt: len != 4");
return false;
}
if (yourCall.size() != 8) {
traceit("CIRCDDB::sendHeard:yourCall: len != 8");
printf("CIRCDDB::sendHeard:yourCall: len != 8");
return false;
}
if (rpt1.size() != 8) {
traceit("CIRCDDB::sendHeard:rpt1: len != 8");
printf("CIRCDDB::sendHeard:rpt1: len != 8");
return false;
}
if (rpt2.size() != 8) {
traceit("CIRCDDB::sendHeard:rpt2: len != 8");
printf("CIRCDDB::sendHeard:rpt2: len != 8");
return false;
}
@ -222,7 +222,7 @@ bool CIRCDDB::sendHeardWithTXStats(const std::string &myCall, const std::string
bool CIRCDDB::findGateway(const std::string &gatewayCallsign)
{
if (gatewayCallsign.size() != 8) {
traceit("CIRCDDB::findGateway: len != 8");
printf("CIRCDDB::findGateway: len != 8");
return false;
}
std::string gcs = gatewayCallsign;
@ -234,7 +234,7 @@ bool CIRCDDB::findGateway(const std::string &gatewayCallsign)
bool CIRCDDB::findRepeater(const std::string &repeaterCallsign)
{
if (repeaterCallsign.size() != 8) {
traceit("CIRCDDB::findRepeater: len != 8");
printf("CIRCDDB::findRepeater: len != 8");
return false;
}
std::string rcs = repeaterCallsign;
@ -246,7 +246,7 @@ bool CIRCDDB::findRepeater(const std::string &repeaterCallsign)
bool CIRCDDB::findUser(const std::string &userCallsign)
{
if (userCallsign.size() != 8) {
traceit("CIRCDDB::findUser: len != 8");
printf("CIRCDDB::findUser: len != 8");
return false;
}
std::string ucs = userCallsign;
@ -269,24 +269,24 @@ bool CIRCDDB::receiveRepeater(std::string &repeaterCallsign, std::string &gatewa
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_REPEATER) {
traceit("CIRCDDB::receiveRepeater: unexpected response type");
printf("CIRCDDB::receiveRepeater: unexpected response type");
return false;
}
IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) {
traceit("CIRCDDB::receiveRepeater: no message");
printf("CIRCDDB::receiveRepeater: no message");
return false;
}
if (m->getCommand().compare("IDRT_REPEATER")) {
traceit("CIRCDDB::receiveRepeater: wrong message type");
printf("CIRCDDB::receiveRepeater: wrong message type");
return false;
}
if (m->getParamCount() != 3) {
traceit("CIRCDDB::receiveRepeater: unexpected number of message parameters");
printf("CIRCDDB::receiveRepeater: unexpected number of message parameters");
return false;
}
@ -306,24 +306,24 @@ bool CIRCDDB::receiveGateway(std::string &gatewayCallsign, std::string &address,
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_GATEWAY) {
traceit("CIRCDDB::receiveGateway: unexpected response type");
printf("CIRCDDB::receiveGateway: unexpected response type");
return false;
}
IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) {
traceit("CIRCDDB::receiveGateway: no message");
printf("CIRCDDB::receiveGateway: no message");
return false;
}
if (m->getCommand().compare("IDRT_GATEWAY")) {
traceit("CIRCDDB::receiveGateway: wrong message type");
printf("CIRCDDB::receiveGateway: wrong message type");
return false;
}
if (m->getParamCount() != 2) {
traceit("CIRCDDB::receiveGateway: unexpected number of message parameters");
printf("CIRCDDB::receiveGateway: unexpected number of message parameters");
return false;
}
@ -349,24 +349,24 @@ bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsi
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_USER) {
traceit("CIRCDDB::receiveUser: unexpected response type");
printf("CIRCDDB::receiveUser: unexpected response type");
return false;
}
IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) {
traceit("CIRCDDB::receiveUser: no message");
printf("CIRCDDB::receiveUser: no message");
return false;
}
if (m->getCommand().compare("IDRT_USER")) {
traceit("CIRCDDB::receiveUser: wrong message type");
printf("CIRCDDB::receiveUser: wrong message type");
return false;
}
if (m->getParamCount() != 5) {
traceit("CIRCDDB::receiveUser: unexpected number of message parameters");
printf("CIRCDDB::receiveUser: unexpected number of message parameters");
return false;
}

@ -165,7 +165,7 @@ void IRCDDBApp::rptrQTH(const std::string &rptrcall, double latitude, double lon
d->locationMap[rptrcall] = f;
d->locationMapMutex.unlock();
traceit("IRCDDB RPTRQTH: %s\n", f.c_str());
printf("IRCDDB RPTRQTH: %s\n", f.c_str());
std::regex urlNonValid("[^[:graph:]]+");
@ -179,7 +179,7 @@ void IRCDDBApp::rptrQTH(const std::string &rptrcall, double latitude, double lon
d->urlMap[rptrcall] = g;
d->urlMapMutex.unlock();
traceit("IRCDDB RPTRURL: %s\n", g.c_str());
printf("IRCDDB RPTRURL: %s\n", g.c_str());
std::string sw = swVersion;
while (std::regex_search(sw, sm, nonValid))
@ -190,7 +190,7 @@ void IRCDDBApp::rptrQTH(const std::string &rptrcall, double latitude, double lon
d->swMap[rptrcall] = h;
d->swMapMutex.unlock();
traceit("IRCDDB RPTRSW: %s\n", h.c_str());
printf("IRCDDB RPTRSW: %s\n", h.c_str());
d->infoTimer = 5; // send info in 5 seconds
}
@ -211,7 +211,7 @@ void IRCDDBApp::rptrQRG(const std::string &rptrcall, double txFrequency, double
d->moduleMap[rptrcall] = g;
d->moduleMapMutex.unlock();
traceit("IRCDDB RPTRQRG: %s\n", g.c_str());
printf("IRCDDB RPTRQRG: %s\n", g.c_str());
d->infoTimer = 5; // send info in 5 seconds
}
@ -255,7 +255,7 @@ IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType()
return IDRT_GATEWAY;
}
traceit("IRCDDBApp::getMessageType: unknown msg type: %s\n", msgType.c_str());
printf("IRCDDBApp::getMessageType: unknown msg type: %s\n", msgType.c_str());
return IDRT_NONE;
}
@ -289,7 +289,7 @@ void IRCDDBApp::userJoin(const std::string &nick, const std::string &name, const
d->user[lnick] = u;
d->userMapMutex.unlock();
//traceit("add %d: (%s) (%s)\n", d->user.size(), nick.c_str(), host.c_str());
//printf("add %d: (%s) (%s)\n", d->user.size(), nick.c_str(), host.c_str());
if (d->initReady) {
unsigned hyphenPos = nick.find('-');
@ -306,7 +306,7 @@ void IRCDDBApp::userJoin(const std::string &nick, const std::string &name, const
d->replyQ.putMessage(m2);
}
}
//traceit("user %d\n", u.usn);
//printf("user %d\n", u.usn);
}
void IRCDDBApp::userLeave(const std::string &nick)
@ -318,11 +318,11 @@ void IRCDDBApp::userLeave(const std::string &nick)
d->user.erase(lnick);
d->userMapMutex.unlock();
// traceit("rm %d: %s\n" d->user.size(), nick.c_str());
// printf("rm %d: %s\n" d->user.size(), nick.c_str());
if (d->currentServer.length() > 0) {
if (d->user.count(d->myNick) != 1) {
traceit("IRCDDBApp::userLeave: could not find own nick\n");
printf("IRCDDBApp::userLeave: could not find own nick\n");
return;
}
@ -351,13 +351,13 @@ void IRCDDBApp::userListReset()
void IRCDDBApp::setCurrentNick(const std::string &nick)
{
d->myNick = nick;
traceit("IRCDDBApp::setCurrentNick %s\n", nick.c_str());
printf("IRCDDBApp::setCurrentNick %s\n", nick.c_str());
}
void IRCDDBApp::setBestServer(const std::string &ircUser)
{
d->bestServer = ircUser;
traceit("IRCDDBApp::setBestServer %s\n", ircUser.c_str());
printf("IRCDDBApp::setBestServer %s\n", ircUser.c_str());
}
void IRCDDBApp::setTopic(const std::string &topic)
@ -454,7 +454,7 @@ std::string IRCDDBApp::getIPAddress(std::string &zonerp_cs)
ipAddr = o.host;
}
}
// traceit("getIP %d (%s) (%s)\n", i, ircUser.c_str(), ipAddr.c_str());
// printf("getIP %d (%s) (%s)\n", i, ircUser.c_str(), ipAddr.c_str());
}
d->userMapMutex.unlock();
@ -679,7 +679,7 @@ void IRCDDBApp::doNotFound(std::string &msg, std::string &retval)
long tableID = std::stol(tk);
if ((tableID < 0) || (tableID >= numberOfTables)) {
traceit("invalid table ID %d", tableID);
printf("invalid table ID %ld", tableID);
return;
}
@ -713,7 +713,7 @@ void IRCDDBApp::doUpdate(std::string &msg)
if (std::regex_match(tk, d->tablePattern)) {
tableID = stol(tk);
if ((tableID < 0) || (tableID >= numberOfTables)) {
traceit("invalid table ID %d", tableID);
printf("invalid table ID %d", tableID);
return;
}
@ -755,7 +755,7 @@ void IRCDDBApp::doUpdate(std::string &msg)
if (! std::regex_match(value, d->dbPattern))
return; // no valid key
//traceit("TABLE %d %s %s\n", tableID, key.c_str(), value.c_str());
//printf("TABLE %d %s %s\n", tableID, key.c_str(), value.c_str());
if (tableID == 1) {
d->rptrMapMutex.lock();
@ -934,7 +934,7 @@ void IRCDDBApp::Entry()
break;
case 2: // choose server
traceit("IRCDDBApp: state=2 choose new 's-'-user\n");
printf("IRCDDBApp: state=2 choose new 's-'-user\n");
if (getSendQ() == NULL) {
d->state = 10;
} else {
@ -964,7 +964,7 @@ void IRCDDBApp::Entry()
if (sendlistTableID < 0) {
d->state = 6; // end of sendlist
} else {
traceit("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID);
printf("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID);
d->state = 4; // send "SENDLIST"
d->timer = 900; // 15 minutes max for update
}
@ -1010,7 +1010,7 @@ void IRCDDBApp::Entry()
if (getSendQ() == NULL) {
d->state = 10; // disconnect DB
} else {
traceit("IRCDDBApp: state=6 initialization completed\n");
printf("IRCDDBApp: state=6 initialization completed\n");
d->infoTimer = 2;

@ -94,7 +94,7 @@ void IRCMessageQueue::putMessage( IRCMessage * m )
{
accessMutex.lock();
//traceit("IRCMessageQueue::putMessage\n");
//printf("IRCMessageQueue::putMessage\n");
IRCMessageQueueItem * k = new IRCMessageQueueItem(m);

@ -6,8 +6,6 @@
#include "IRCutils.h"
#include "IRCProtocol.h"
extern void traceit(const char *fmt,...);
#define CIRCDDB_VERSION "2.0.0"
IRCProtocol::IRCProtocol(IRCApplication *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo)
@ -67,7 +65,7 @@ void IRCProtocol::setNetworkReady(bool b)
{
if (b == true) {
if (state != 0)
traceit("IRCProtocol::setNetworkReady: unexpected state");
printf("IRCProtocol::setNetworkReady: unexpected state");
state = 1;
chooseNewNick();
@ -93,7 +91,7 @@ bool IRCProtocol::processQueues(IRCMessageQueue *recvQ, IRCMessageQueue *sendQ)
}
// d.Replace(std::string("%"), std::string("%%"), true);
// d.Replace(std::string("\\"), std::string("\\\\"), true);
traceit("%s\n", d.c_str());
printf("%s\n", d.c_str());
#endif
if (0 == m->command.compare("004")) {

@ -24,11 +24,11 @@ static int doRead(int sock, char * buf, int buf_size)
res = select(sock+1, &rdset, NULL, &errset, &tv);
if ( res < 0 ) {
traceit("IRCReceiver::doread: select() error.\n");
printf("IRCReceiver::doread: select() error.\n");
return -1;
} else if ( res > 0 ) {
if (FD_ISSET(sock, &errset)) {
traceit("IRCReceiver::doRead: FD_ISSET error\n");
printf("IRCReceiver::doRead: FD_ISSET error\n");
return -1;
}
@ -36,10 +36,10 @@ static int doRead(int sock, char * buf, int buf_size)
res = recv(sock, buf, buf_size, 0);
if (res < 0) {
traceit("IRCReceiver::doRead: recv error\n");
printf("IRCReceiver::doRead: recv error\n");
return -1;
} else if (res == 0) {
traceit("IRCReceiver::doRead: EOF read==0\n");
printf("IRCReceiver::doRead: EOF read==0\n");
return -1;
} else
return res;

@ -105,7 +105,7 @@ int getAllIPV4Addresses(const char * name, unsigned short port, unsigned int * n
return 0;
} else {
traceit("getaddrinfo: %s\n", gai_strerror(r));
printf("getaddrinfo: %s\n", gai_strerror(r));
return 1;
}
@ -140,29 +140,6 @@ char *getCurrentTime(void)
return buffer;
}
void traceit(const char *fmt,...)
{
time_t ltime;
struct tm tm;
const short BFSZ = 512;
char buf[BFSZ];
time(&ltime);
localtime_r(&ltime, &tm);
snprintf(buf,BFSZ - 1,"%02d/%02d/%02d %d:%02d:%02d:",
tm.tm_mon+1,tm.tm_mday,tm.tm_year % 100,
tm.tm_hour,tm.tm_min,tm.tm_sec);
va_list args;
va_start(args,fmt);
vsnprintf(buf + strlen(buf), BFSZ - strlen(buf) -1, fmt, args);
va_end(args);
fprintf(stdout, "%s", buf);
return;
}
void ToUpper(std::string &str)
{
for (auto it=str.begin(); it!=str.end(); it++) {

@ -33,8 +33,6 @@ void safeStringCopy(char * dest, const char * src, unsigned int buf_size);
char *getCurrentTime(void);
void traceit(const char *fmt,...);
void ToUpper(std::string &str);
void ToLower(std::string &str);

@ -33,7 +33,7 @@
void CAPRS::SelectBand(short int rptr_idx, unsigned short streamID)
{
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("ERROR in aprs_select_band, invalid mod %d\n", rptr_idx);
printf("ERROR in aprs_select_band, invalid mod %d\n", rptr_idx);
return;
}
@ -70,7 +70,7 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha
}
if ((rptr_idx < 0) || (rptr_idx > 2)) {
// traceit("ERROR in aprs_process_text: rptr_idx %d is invalid\n", rptr_idx);
// printf("ERROR in aprs_process_text: rptr_idx %d is invalid\n", rptr_idx);
return;
}
@ -113,7 +113,7 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha
*p = '\0';
sprintf(aprs_buf, "%s,qAR,%s:%s\r\n", hdr, m_rptr->mod[rptr_idx].call.c_str(), aud);
// traceit("GPS-A=%s", aprs_buf);
// printf("GPS-A=%s", aprs_buf);
int rc = WriteSock(aprs_buf, strlen(aprs_buf));
if (rc == -1) {
if ((errno == EPIPE) ||
@ -127,11 +127,11 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha
(errno == ENETUNREACH) ||
(errno == EHOSTDOWN) ||
(errno == ENOTCONN)) {
traceit("CAPRS::ProcessText(): APRS_HOST closed connection,error=%d\n",errno);
printf("CAPRS::ProcessText(): APRS_HOST closed connection,error=%d\n",errno);
close(aprs_sock);
aprs_sock = -1;
} else /* if it is WOULDBLOCK, we will not go into a loop here */
traceit("CAPRS::ProcessText(): send error=%d\n", errno);
printf("CAPRS::ProcessText(): send error=%d\n", errno);
}
time(&aprs_streamID[rptr_idx].last_time);
@ -177,7 +177,7 @@ bool CAPRS::WriteData(short int rptr_idx, unsigned char *data)
{
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("CAPRS::WriteData: rptr_idx %d is invalid\n", rptr_idx);
printf("CAPRS::WriteData: rptr_idx %d is invalid\n", rptr_idx);
return false;
}
@ -210,7 +210,7 @@ bool CAPRS::WriteData(short int rptr_idx, unsigned char *data)
void CAPRS::SyncIt(short int rptr_idx)
{
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("CAPRS::SyncIt(): rptr_idx %d is invalid\n", rptr_idx);
printf("CAPRS::SyncIt(): rptr_idx %d is invalid\n", rptr_idx);
return;
}
@ -221,7 +221,7 @@ void CAPRS::SyncIt(short int rptr_idx)
void CAPRS::Reset(short int rptr_idx)
{
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("CAPRS::Reset(): rptr_idx %d is invalid\n", rptr_idx);
printf("CAPRS::Reset(): rptr_idx %d is invalid\n", rptr_idx);
return;
}
@ -236,7 +236,7 @@ void CAPRS::Reset(short int rptr_idx)
unsigned int CAPRS::GetData(short int rptr_idx, unsigned char *data, unsigned int len)
{
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("CAPRS::GetData: rptr_idx %d is invalid\n", rptr_idx);
printf("CAPRS::GetData: rptr_idx %d is invalid\n", rptr_idx);
return 0;
}
@ -266,7 +266,7 @@ void CAPRS::Open(const std::string OWNER)
bool ok = ResolveRmt(m_rptr->aprs.ip.c_str(), SOCK_STREAM, &aprs_addr);
if (!ok) {
traceit("Can't resolve APRS_HOST %s\n", m_rptr->aprs.ip.c_str());
printf("Can't resolve APRS_HOST %s\n", m_rptr->aprs.ip.c_str());
return;
}
@ -278,24 +278,24 @@ void CAPRS::Open(const std::string OWNER)
aprs_sock = socket(PF_INET, SOCK_STREAM, 0);
if (aprs_sock == -1) {
traceit("Failed to create aprs socket,error=%d\n",errno);
printf("Failed to create aprs socket,error=%d\n",errno);
return;
}
fcntl(aprs_sock,F_SETFL,O_NONBLOCK);
val = 1;
if (setsockopt(aprs_sock,IPPROTO_TCP,TCP_NODELAY,(char *)&val, sizeof(val)) == -1) {
traceit("setsockopt TCP_NODELAY TCP for aprs socket failed,error=%d\n",errno);
printf("setsockopt TCP_NODELAY TCP for aprs socket failed,error=%d\n",errno);
close(aprs_sock);
aprs_sock = -1;
return;
}
traceit("Trying to connect to APRS...\n");
printf("Trying to connect to APRS...\n");
int rc = connect(aprs_sock, (struct sockaddr *)&aprs_addr, aprs_addr_len);
if (rc != 0) {
if (errno == EINPROGRESS) {
traceit("Waiting for up to %d seconds for APRS_HOST\n", MAX_WAIT);
printf("Waiting for up to %d seconds for APRS_HOST\n", MAX_WAIT);
while (MAX_WAIT > 0) {
tv.tv_sec = 0;
tv.tv_usec = 0;
@ -304,7 +304,7 @@ void CAPRS::Open(const std::string OWNER)
rc = select(aprs_sock + 1, NULL, &fdset, NULL, &tv);
if (rc < 0) {
traceit("Failed to connect to APRS...select,error=%d\n", errno);
printf("Failed to connect to APRS...select,error=%d\n", errno);
close(aprs_sock);
aprs_sock = -1;
return;
@ -315,7 +315,7 @@ void CAPRS::Open(const std::string OWNER)
val = 1; /* Assume it fails */
val_len = sizeof(val);
if (getsockopt(aprs_sock, SOL_SOCKET, SO_ERROR, (char *) &val, &val_len) < 0) {
traceit("Failed to connect to APRS...getsockopt, error=%d\n", errno);
printf("Failed to connect to APRS...getsockopt, error=%d\n", errno);
close(aprs_sock);
aprs_sock = -1;
return;
@ -327,19 +327,19 @@ void CAPRS::Open(const std::string OWNER)
}
}
if (MAX_WAIT == 0) {
traceit("Failed to connect to APRS...timeout\n");
printf("Failed to connect to APRS...timeout\n");
close(aprs_sock);
aprs_sock = -1;
return;
}
} else {
traceit("Failed to connect to APRS, error=%d\n", errno);
printf("Failed to connect to APRS, error=%d\n", errno);
close(aprs_sock);
aprs_sock = -1;
return;
}
}
traceit("Connected to APRS %s:%d\n", m_rptr->aprs.ip.c_str(), m_rptr->aprs.port);
printf("Connected to APRS %s:%d\n", m_rptr->aprs.ip.c_str(), m_rptr->aprs.port);
/* login to aprs */
sprintf(snd_buf, "user %s pass %d vers g2_ircddb 2.99 UDP 5 ", OWNER.c_str(), m_rptr->aprs_hash);
@ -349,7 +349,7 @@ void CAPRS::Open(const std::string OWNER)
strcat(snd_buf, "filter ");
strcat(snd_buf, m_rptr->aprs_filter.c_str());
}
// traceit("APRS login command:[%s]\n", snd_buf);
// printf("APRS login command:[%s]\n", snd_buf);
strcat(snd_buf, "\r\n");
while (true) {
@ -359,11 +359,11 @@ void CAPRS::Open(const std::string OWNER)
recv(aprs_sock, rcv_buf, sizeof(rcv_buf), 0);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} else {
traceit("APRS login command failed, error=%d\n", errno);
printf("APRS login command failed, error=%d\n", errno);
break;
}
} else {
// traceit("APRS login command sent\n");
// printf("APRS login command sent\n");
break;
}
}
@ -375,7 +375,7 @@ void CAPRS::Open(const std::string OWNER)
bool CAPRS::AddData(short int rptr_idx, unsigned char *data)
{
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("CAPRS::AddData(): rptr_idx %d is invalid\n", rptr_idx);
printf("CAPRS::AddData(): rptr_idx %d is invalid\n", rptr_idx);
return false;
}
@ -427,7 +427,7 @@ bool CAPRS::AddData(short int rptr_idx, unsigned char *data)
aprs_pack[rptr_idx].len++;
if (aprs_pack[rptr_idx].len >= 300) {
traceit("ERROR in aprs_add_data: Expected END of APRS data\n");
printf("ERROR in aprs_add_data: Expected END of APRS data\n");
aprs_pack[rptr_idx].len = 0;
aprs_pack[rptr_idx].al = al_none;
}
@ -441,7 +441,7 @@ bool CAPRS::AddData(short int rptr_idx, unsigned char *data)
aprs_pack[rptr_idx].al = al_end;
return true;
} else {
traceit("BAD checksum in APRS data\n");
printf("BAD checksum in APRS data\n");
aprs_pack[rptr_idx].al = al_none;
aprs_pack[rptr_idx].len = 0;
}
@ -459,7 +459,7 @@ bool CAPRS::CheckData(short int rptr_idx)
char buf[5];
if ((rptr_idx < 0) || (rptr_idx > 2)) {
traceit("CAPRS::CheckData(): rptr_idx %d is invalid\n", rptr_idx);
printf("CAPRS::CheckData(): rptr_idx %d is invalid\n", rptr_idx);
return false;
}
my_sum = CalcCRC(aprs_pack[rptr_idx].data + 10, aprs_pack[rptr_idx].len - 10);
@ -528,7 +528,7 @@ bool CAPRS::ResolveRmt(const char *name, int type, struct sockaddr_in *addr)
int rc = getaddrinfo(name, NULL, &hints, &res);
if (rc != 0) {
traceit("getaddrinfo return error code %d for [%s]\n", rc, name);
printf("getaddrinfo return error code %d for [%s]\n", rc, name);
return false;
}

@ -97,7 +97,6 @@ static unsigned int space = 0;
static unsigned int aseed = 0;
/* helper routines */
void traceit(const char *fmt,...);
static int read_config(const char *cfgFile);
static void sig_catch(int signum);
static int open_sock();
@ -156,30 +155,6 @@ static void sig_catch(int signum)
exit(0);
}
/* log the event */
void traceit(const char *fmt,...)
{
time_t ltime;
struct tm mytm;
const int TRACE_BFSZ = 256;
char trace_buf[TRACE_BFSZ];
time(&ltime);
localtime_r(&ltime,&mytm);
snprintf(trace_buf,TRACE_BFSZ - 1,"%02d/%02d/%02d %02d:%02d:%02d:",
mytm.tm_mon+1,mytm.tm_mday,mytm.tm_year % 100,
mytm.tm_hour,mytm.tm_min,mytm.tm_sec);
va_list args;
va_start(args,fmt);
vsnprintf(trace_buf + strlen(trace_buf), TRACE_BFSZ - strlen(trace_buf) - 1, fmt, args);
va_end(args);
fprintf(stdout, "%s", trace_buf);
return;
}
bool get_value(const Config &cfg, const char *path, int &value, int min, int max, int default_value)
{
if (cfg.lookupValue(path, value)) {
@ -187,7 +162,7 @@ bool get_value(const Config &cfg, const char *path, int &value, int min, int max
value = default_value;
} else
value = default_value;
traceit("%s = [%d]\n", path, value);
printf("%s = [%d]\n", path, value);
return true;
}
@ -198,7 +173,7 @@ bool get_value(const Config &cfg, const char *path, double &value, double min, d
value = default_value;
} else
value = default_value;
traceit("%s = [%lg]\n", path, value);
printf("%s = [%lg]\n", path, value);
return true;
}
@ -206,7 +181,7 @@ bool get_value(const Config &cfg, const char *path, bool &value, bool default_va
{
if (! cfg.lookupValue(path, value))
value = default_value;
traceit("%s = [%s]\n", path, value ? "true" : "false");
printf("%s = [%s]\n", path, value ? "true" : "false");
return true;
}
@ -215,12 +190,12 @@ bool get_value(const Config &cfg, const char *path, std::string &value, int min,
if (cfg.lookupValue(path, value)) {
int l = value.length();
if (l<min || l>max) {
traceit("%s is invalid\n", path, value.c_str());
printf("%s is invalid\n", path);
return false;
}
} else
value = default_value;
traceit("%s = [%s]\n", path, value.c_str());
printf("%s = [%s]\n", path, value.c_str());
return true;
}
@ -230,17 +205,17 @@ static int read_config(const char *cfgFile)
int i;
Config cfg;
traceit("Reading file %s\n", cfgFile);
printf("Reading file %s\n", cfgFile);
// Read the file. If there is an error, report it and exit.
try {
cfg.readFile(cfgFile);
}
catch(const FileIOException &fioex) {
traceit("Can't read %s\n", cfgFile);
printf("Can't read %s\n", cfgFile);
return 1;
}
catch(const ParseException &pex) {
traceit("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError());
printf("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError());
return 1;
}
@ -254,7 +229,7 @@ static int read_config(const char *cfgFile)
}
}
if (i >= 3) {
traceit("dvap not defined in any module!\n");
printf("dvap not defined in any module!\n");
return 1;
}
RPTR_MOD = 'A' + i;
@ -262,7 +237,7 @@ static int read_config(const char *cfgFile)
if (cfg.lookupValue(std::string(dvap_path+".callsign").c_str(), value) || cfg.lookupValue("ircddb.login", value)) {
int l = value.length();
if (l<3 || l>CALL_SIZE-2) {
traceit("Call '%s' is invalid length!\n", value.c_str());
printf("Call '%s' is invalid length!\n", value.c_str());
return 1;
} else {
for (i=0; i<l; i++) {
@ -272,16 +247,16 @@ static int read_config(const char *cfgFile)
value.resize(CALL_SIZE, ' ');
}
strcpy(RPTR, value.c_str());
traceit("%s.login = [%s]\n", dvap_path.c_str(), RPTR);
printf("%s.login = [%s]\n", dvap_path.c_str(), RPTR);
} else {
traceit("%s.login is not defined!\n", dvap_path.c_str());
printf("%s.login is not defined!\n", dvap_path.c_str());
return 1;
}
if (cfg.lookupValue("ircddb.login", value)) {
int l = value.length();
if (l<3 || l>CALL_SIZE-2) {
traceit("Call '%s' is invalid length!\n", value.c_str());
printf("Call '%s' is invalid length!\n", value.c_str());
return 1;
} else {
for (i=0; i<l; i++) {
@ -291,9 +266,9 @@ static int read_config(const char *cfgFile)
value.resize(CALL_SIZE, ' ');
}
strcpy(OWNER, value.c_str());
traceit("ircddb.login = [%s]\n", OWNER);
printf("ircddb.login = [%s]\n", OWNER);
} else {
traceit("ircddb.login is not defined!\n");
printf("ircddb.login is not defined!\n");
return 1;
}
@ -316,7 +291,7 @@ static int read_config(const char *cfgFile)
if (get_value(cfg, "gateway.ip", value, 7, IP_SIZE, "127.0.0.1"))
strcpy(G2_INTERNAL_IP, value.c_str());
else {
traceit("gateway.ip '%s' is invalid!\\n", value.c_str());
printf("gateway.ip '%s' is invalid!\\n", value.c_str());
return 1;
}
@ -325,7 +300,7 @@ static int read_config(const char *cfgFile)
if (get_value(cfg, std::string(dvap_path+".serial_number").c_str(), value, 8, 10, "APXXXXXX"))
strcpy(DVP_SERIAL, value.c_str());
else {
traceit("%s.serial_number '%s' is invalid!\n", dvap_path.c_str(), value.c_str());
printf("%s.serial_number '%s' is invalid!\n", dvap_path.c_str(), value.c_str());
return 1;
}
@ -350,7 +325,7 @@ static int read_config(const char *cfgFile)
get_value(cfg, std::string(dvap_path+".acknowledge").c_str(), RPTR_ACK, false);
inactiveMax = (REMOTE_TIMEOUT * 1000) / WAIT_FOR_PACKETS;
traceit("Max loops = %d\n", inactiveMax);
printf("Max loops = %d\n", inactiveMax);
/* convert to Microseconds */
WAIT_FOR_PACKETS *= 1000;
@ -364,7 +339,7 @@ static int open_sock()
insock = socket(PF_INET, SOCK_DGRAM, 0);
if (insock == -1) {
traceit("Failed to create insock, error=%d, message=%s\n",errno,strerror(errno));
printf("Failed to create insock, error=%d, message=%s\n",errno,strerror(errno));
return -1;
}
@ -374,7 +349,7 @@ static int open_sock()
inaddr.sin_addr.s_addr = inet_addr(RPTR_VIRTUAL_IP);
int rc = bind(insock, (struct sockaddr *)&inaddr, sizeof(inaddr));
if (rc == -1) {
traceit("Failed to bind server socket, error=%d, message=%s\n", errno,strerror(errno));
printf("Failed to bind server socket, error=%d, message=%s\n", errno,strerror(errno));
close(insock);
insock = -1;
return -1;
@ -466,7 +441,7 @@ static void readFrom20000()
ctrl_in = 0x80;
written_to_q = true;
traceit("Start G2: streamid=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n",
printf("Start G2: streamid=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n",
net_buf.vpkt.streamid,
net_buf.vpkt.hdr.flag[0], net_buf.vpkt.hdr.flag[1], net_buf.vpkt.hdr.flag[2],
net_buf.vpkt.hdr.mycall, net_buf.vpkt.hdr.sfx, net_buf.vpkt.hdr.urcall,
@ -519,7 +494,7 @@ static void readFrom20000()
if (net_buf.vpkt.streamid == streamid) {
if (net_buf.vpkt.ctrl == ctrl_in) {
/* do not update written_to_q, ctrl_in */
; // traceit("dup\n");
; // printf("dup\n");
} else {
ctrl_in = net_buf.vpkt.ctrl;
written_to_q = true;
@ -562,7 +537,7 @@ static void readFrom20000()
seq_no = 0;
if ((net_buf.vpkt.ctrl & 0x40) != 0) {
traceit("End G2: streamid=%04x\n", net_buf.vpkt.streamid);
printf("End G2: streamid=%04x\n", net_buf.vpkt.streamid);
streamid = 0;
@ -593,7 +568,7 @@ static void readFrom20000()
if (!written_to_q) {
if (busy20000) {
if (++inactive == inactiveMax) {
traceit("G2 Timeout...\n");
printf("G2 Timeout...\n");
streamid = 0;
@ -647,25 +622,25 @@ int main(int argc, const char **argv)
short cnt = 0;
setvbuf(stdout, NULL, _IOLBF, 0);
traceit("dvap_rptr VERSION %s\n", VERSION);
printf("dvap_rptr VERSION %s\n", VERSION);
if (argc != 2) {
traceit("Usage: dvap_rptr dvap_rptr.cfg\n");
printf("Usage: dvap_rptr dvap_rptr.cfg\n");
return 1;
}
rc = read_config(argv[1]);
if (rc != 0) {
traceit("Failed to process config file %s\n", argv[1]);
printf("Failed to process config file %s\n", argv[1]);
return 1;
}
if (strlen(RPTR) != 8) {
traceit("Bad RPTR value, length must be exactly 8 bytes\n");
printf("Bad RPTR value, length must be exactly 8 bytes\n");
return 1;
}
if ((RPTR_MOD != 'A') && (RPTR_MOD != 'B') && (RPTR_MOD != 'C')) {
traceit("Bad RPTR_MOD value, must be one of A or B or C\n");
printf("Bad RPTR_MOD value, must be one of A or B or C\n");
return 1;
}
@ -688,15 +663,15 @@ int main(int argc, const char **argv)
act.sa_handler = sig_catch;
sigemptyset(&act.sa_mask);
if (sigaction(SIGTERM, &act, 0) != 0) {
traceit("sigaction-TERM failed, error=%d\n", errno);
printf("sigaction-TERM failed, error=%d\n", errno);
return 1;
}
if (sigaction(SIGHUP, &act, 0) != 0) {
traceit("sigaction-HUP failed, error=%d\n", errno);
printf("sigaction-HUP failed, error=%d\n", errno);
return 1;
}
if (sigaction(SIGINT, &act, 0) != 0) {
traceit("sigaction-INT failed, error=%d\n", errno);
printf("sigaction-INT failed, error=%d\n", errno);
return 1;
}
@ -710,17 +685,17 @@ int main(int argc, const char **argv)
close(serfd);
return 1;
}
traceit("DVAP opened and initialized!\n");
printf("DVAP opened and initialized!\n");
dstar_dv_init();
std::future<void> readthread;
try {
readthread = std::async(std::launch::async, ReadDVAPThread);
} catch (const std::exception &e) {
traceit("Unable to start ReadDVAPThread(). Exception: %s\n", e.what());
printf("Unable to start ReadDVAPThread(). Exception: %s\n", e.what());
keep_running = false;
}
traceit("Started ReadDVAPThread()\n");
printf("Started ReadDVAPThread()\n");
while (keep_running) {
time(&tnow);
@ -729,7 +704,7 @@ int main(int argc, const char **argv)
if (rc < 0) {
cnt ++;
if (cnt > 5) {
traceit("Could not send KEEPALIVE signal to dvap 5 times...exiting\n");
printf("Could not send KEEPALIVE signal to dvap 5 times...exiting\n");
keep_running = false;
}
} else
@ -741,7 +716,7 @@ int main(int argc, const char **argv)
readthread.get();
close(insock);
traceit("dvap_rptr exiting\n");
printf("dvap_rptr exiting\n");
return 0;
}
@ -764,15 +739,15 @@ static void RptrAckThread(SDVAP_ACK_ARG *parg)
act.sa_handler = sig_catch;
sigemptyset(&act.sa_mask);
if (sigaction(SIGTERM, &act, 0) != 0) {
traceit("sigaction-TERM failed, error=%d\n", errno);
printf("sigaction-TERM failed, error=%d\n", errno);
return;
}
if (sigaction(SIGHUP, &act, 0) != 0) {
traceit("sigaction-HUP failed, error=%d\n", errno);
printf("sigaction-HUP failed, error=%d\n", errno);
return;
}
if (sigaction(SIGINT, &act, 0) != 0) {
traceit("sigaction-INT failed, error=%d\n", errno);
printf("sigaction-INT failed, error=%d\n", errno);
return;
}
@ -902,17 +877,17 @@ static void ReadDVAPThread()
act.sa_handler = sig_catch;
sigemptyset(&act.sa_mask);
if (sigaction(SIGTERM, &act, 0) != 0) {
traceit("sigaction-TERM failed, error=%d\n", errno);
printf("sigaction-TERM failed, error=%d\n", errno);
keep_running = false;
return;
}
if (sigaction(SIGHUP, &act, 0) != 0) {
traceit("sigaction-HUP failed, error=%d\n", errno);
printf("sigaction-HUP failed, error=%d\n", errno);
keep_running = false;
return;
}
if (sigaction(SIGINT, &act, 0) != 0) {
traceit("sigaction-INT failed, error=%d\n", errno);
printf("sigaction-INT failed, error=%d\n", errno);
keep_running = false;
return;
}
@ -949,16 +924,16 @@ static void ReadDVAPThread()
// read from the dvap and process
reply = dongle.GetReply(dr);
if (reply == RT_ERR) {
traceit("Detected ERROR event from DVAP dongle, stopping...n");
printf("Detected ERROR event from DVAP dongle, stopping...n");
break;
} else if (reply == RT_STOP) {
traceit("Detected STOP event from DVAP dongle, stopping...\n");
printf("Detected STOP event from DVAP dongle, stopping...\n");
break;
} else if (reply == RT_START) {
traceit("Detected START event from DVAP dongle\n");
printf("Detected START event from DVAP dongle\n");
// else if (reply == RT_PTT) {
// ptt = (dvp_buf[4] == 0x01);
// traceit("Detected PTT=%s\n", ptt?"on":"off");
// printf("Detected PTT=%s\n", ptt?"on":"off");
} else if (reply == RT_STS) {
space = (unsigned int)dr.param.sstr[2];
if (status_cntr < 3000)
@ -967,7 +942,7 @@ static void ReadDVAPThread()
num_dv_frames = 0;
num_bit_errors = 0;
traceit("From DVAP: flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n",
printf("From DVAP: flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n",
dr.frame.hdr.flag[0], dr.frame.hdr.flag[1], dr.frame.hdr.flag[2],
dr.frame.hdr.mycall, dr.frame.hdr.sfx, dr.frame.hdr.urcall,
dr.frame.hdr.rpt2, dr.frame.hdr.rpt1);
@ -990,7 +965,7 @@ static void ReadDVAPThread()
temp_yrcall[CALL_SIZE] = '\0';
temp_ptr = strstr(temp_yrcall, INVALID_YRCALL_KEY);
if (temp_ptr == temp_yrcall) { // found it at first position
traceit("YRCALL value [%s] starts with the INVALID_YRCALL_KEY [%s], resetting to CQCQCQ\n",
printf("YRCALL value [%s] starts with the INVALID_YRCALL_KEY [%s], resetting to CQCQCQ\n",
temp_yrcall, INVALID_YRCALL_KEY);
memcpy(dr.frame.hdr.urcall, "CQCQCQ ", 8);
}
@ -1028,11 +1003,11 @@ static void ReadDVAPThread()
*/
if (memcmp(RPTR, OWNER, RPTR_SIZE) != 0) {
if (memcmp(net_buf.vpkt.hdr.mycall, RPTR, RPTR_SIZE) != 0) {
traceit("mycall=[%.8s], not equal to %s\n", net_buf.vpkt.hdr.mycall, RPTR);
printf("mycall=[%.8s], not equal to %s\n", net_buf.vpkt.hdr.mycall, RPTR);
ok = false;
}
} else if (memcmp(net_buf.vpkt.hdr.mycall, " ", 8) == 0) {
traceit("Invalid value for mycall=[%.8s]\n", net_buf.vpkt.hdr.mycall);
printf("Invalid value for mycall=[%.8s]\n", net_buf.vpkt.hdr.mycall);
ok = false;
}
@ -1043,7 +1018,7 @@ static void ReadDVAPThread()
(net_buf.vpkt.hdr.mycall[i] != ' ')) {
memset(net_buf.vpkt.hdr.mycall, ' ', 8);
ok = false;
traceit("Invalid value for MYCALL\n");
printf("Invalid value for MYCALL\n");
break;
}
}
@ -1152,14 +1127,14 @@ static void ReadDVAPThread()
dvap_busy = false;
static SDVAP_ACK_ARG dvap_ack_arg;
dvap_ack_arg.ber = (num_dv_frames==0) ? 0.f : 100.f * (float)num_bit_errors / (float)(num_dv_frames * 24);
traceit("End of dvap audio, ber=%.02f\n", dvap_ack_arg.ber);
printf("End of dvap audio, ber=%.02f\n", dvap_ack_arg.ber);
if (RPTR_ACK && !busy20000) {
memcpy(dvap_ack_arg.mycall, mycall, 8);
try {
std::async(std::launch::async, RptrAckThread, &dvap_ack_arg);
} catch (const std::exception &e) {
traceit("Failed to start RptrAckThread(). Exception: %s\n", e.what());
printf("Failed to start RptrAckThread(). Exception: %s\n", e.what());
}
}
}
@ -1175,7 +1150,7 @@ static void ReadDVAPThread()
dongle.Stop();
close(serfd);
traceit("ReadDVAPThread exiting\n");
printf("ReadDVAPThread exiting\n");
keep_running = false;
return;

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save

Powered by TurnKey Linux.