process slow data from modem

pull/14/head
Tom Early 6 years ago
parent 76c0b48fc4
commit a72f121ffa

@ -97,6 +97,28 @@ bool CLocation::Parse(const char *instr)
return true; return true;
} }
const char *CLocation::APRS(std::string &call, const char *station)
{
char last;
call.resize(8, ' ');
last = call.at(7);
auto pos = call.find(' ');
if (call.npos != pos) {
call.resize(pos+1);
}
double latmin, lonmin;
double lat = modf(fabs(latitude), &latmin);
latmin *= 60.0;
double lon = modf(fabs(longitude), &lonmin);
lonmin *= 60.0;
if (last == ' ')
snprintf(aprs, 128, "%s>APDPRS,DSTAR*,qAR,%s:!%02d%04.2f%c/%03d%04.2f%c/A\r\n", call.c_str(), station, int(lat), latmin, (latitude>=0) ? 'N' : 'S', int(lon), lonmin, (longitude>=0) ? 'E' : 'W');
else
snprintf(aprs, 128, "%s-%c>APDPRS,DSTAR*,qAR,%s:!%02d%04.2f%c/%03d%04.2f%c/A\r\n", call.c_str(), last, station, int(lat), latmin, (latitude>=0) ? 'N' : 'S', int(lon), lonmin, (longitude>=0) ? 'E' : 'W');
return aprs;
}
double CLocation::Latitude() const double CLocation::Latitude() const
{ {
return latitude; return latitude;

@ -18,6 +18,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <string>
class CLocation class CLocation
{ {
public: public:
@ -26,8 +28,10 @@ public:
double Latitude() const; double Latitude() const;
double Longitude() const; double Longitude() const;
const char* MaidenHead() const; const char* MaidenHead() const;
const char* APRS(std::string &call, const char *station);
private: private:
char maidenhead[7]; char maidenhead[7];
char aprs[128];
double latitude, longitude; double latitude, longitude;
std::regex gps; std::regex gps;
}; };

File diff suppressed because it is too large Load Diff

@ -51,29 +51,29 @@ using STOREPEATER = struct torepeater_tag {
using SBANDTXT = struct band_txt_tag { using SBANDTXT = struct band_txt_tag {
unsigned short streamID; unsigned short streamID;
unsigned char flags[3]; unsigned char flags[3];
char lh_mycall[CALL_SIZE + 1]; std::string mycall, sfx, urcall, rpt1, rpt2, txt, dest_rptr;
char lh_sfx[5]; time_t last_time, gps_last_time;
char lh_yrcall[CALL_SIZE + 1]; bool sent_key_on_msg, is_gps_sent;
char lh_rpt1[CALL_SIZE + 1];
char lh_rpt2[CALL_SIZE + 1];
time_t last_time;
char txt[64]; // Only 20 are used
unsigned short txt_cnt;
bool sent_key_on_msg;
std::string dest_rptr;
// try to process GPS mode: GPRMC and ID
char temp_line[256];
unsigned short temp_line_cnt;
char gprmc[256];
char gpid[256];
bool is_gps_sent;
time_t gps_last_time;
int num_dv_frames; int num_dv_frames;
int num_dv_silent_frames; int num_dv_silent_frames;
int num_bit_errors; int num_bit_errors;
void Initialize()
{
streamID = 0x0U;
last_time = gps_last_time = 0;
is_gps_sent = sent_key_on_msg = false;
num_dv_frames = num_dv_silent_frames = num_bit_errors = 0;
flags[0] = flags[1] = flags[2] = 0x0U;
mycall.clear();
sfx.clear();
urcall.clear();
rpt1.clear();
rpt2.clear();
txt.clear();
dest_rptr.clear();
}
}; };
using SSD = struct sd_tag { using SSD = struct sd_tag {
@ -87,9 +87,6 @@ using SSD = struct sd_tag {
void Init() { ih = im = ig = 0; first = true; } void Init() { ih = im = ig = 0; first = true; }
}; };
class CQnetGateway : public CKRBase class CQnetGateway : public CKRBase
{ {
public: public:
@ -103,11 +100,7 @@ private:
int link_family[3] = { AF_UNSPEC, AF_UNSPEC, AF_UNSPEC }; int link_family[3] = { AF_UNSPEC, AF_UNSPEC, AF_UNSPEC };
// network type // network type
int af_family[2] = { AF_UNSPEC, AF_UNSPEC }; int af_family[2] = { AF_UNSPEC, AF_UNSPEC };
// text stuff
bool new_group[3] = { true, true, true };
short to_print[3] = { 0, 0, 0 };
bool ABC_grp[3] = { false, false, false };
bool C_seen[3] = { false, false, false };
int Index[3] = { -1, -1, -1 }; int Index[3] = { -1, -1, -1 };
SPORTIP g2_external, g2_ipv6_external, ircddb[2]; SPORTIP g2_external, g2_ipv6_external, ircddb[2];
@ -172,6 +165,11 @@ private:
// for bit error rate calcs // for bit error rate calcs
CDStarDecode decode; CDStarDecode decode;
// g2 data
std::string lhcallsign[3], lhsfx[3];
unsigned char nextctrl[3] = { 0U, 0U, 0U };
std::string superframe[3];
// dtmf stuff // dtmf stuff
int dtmf_buf_count[3]; int dtmf_buf_count[3];
char dtmf_buf[3][MAX_DTMF_BUF + 1]; char dtmf_buf[3][MAX_DTMF_BUF + 1];
@ -190,9 +188,11 @@ private:
bool Printable(unsigned char *string); bool Printable(unsigned char *string);
void ProcessTimeouts(); void ProcessTimeouts();
void ProcessSlowData(unsigned char *data, const unsigned short sid); void ProcessSlowData(unsigned char *data, const unsigned short sid);
void ProcessIncomingSD(const SDSVT &dsvt); void ProcessIncomingSD(const SDSVT &dsvt, const int source_sock);
void ProcessOutGoingSD(const SDSVT &dsvt);
bool ProcessG2Msg(const unsigned char *data, const int mod, std::string &smrtgrp); bool ProcessG2Msg(const unsigned char *data, const int mod, std::string &smrtgrp);
void ProcessG2(const ssize_t g2buflen, SDSVT &g2buf, const int sock_source); void ProcessG2(const ssize_t g2buflen, SDSVT &g2buf, const int sock_source);
void ProcessG2Header(const SDSVT &g2buf, const int source_sock);
void ProcessModem(const ssize_t len, SDSVT &dsvt); void ProcessModem(const ssize_t len, SDSVT &dsvt);
bool Flag_is_ok(unsigned char flag); bool Flag_is_ok(unsigned char flag);
void UnpackCallsigns(const std::string &str, std::set<std::string> &set, const std::string &delimiters = ","); void UnpackCallsigns(const std::string &str, std::set<std::string> &set, const std::string &delimiters = ",");
@ -202,16 +202,10 @@ private:
// read configuration file // read configuration file
bool ReadConfig(char *); bool ReadConfig(char *);
/* aprs functions, borrowed from my retired IRLP node 4201 */
void gps_send(short int rptr_idx);
bool verify_gps_csum(char *gps_text, char *csum_text);
void build_aprs_from_gps_and_send(short int rptr_idx);
void qrgs_and_maps(); void qrgs_and_maps();
void set_dest_rptr(const char mod, std::string &call); void set_dest_rptr(const char mod, std::string &call);
bool validate_csum(SBANDTXT &bt, bool is_gps);
// for incoming slow header stuff; // for incoming slow header stuff;
SSD Sd[4]; SSD sdin[4], sdout[3];
}; };

@ -185,7 +185,7 @@ bool CTCPReaderWriterClient::Write(const unsigned char *buffer, const unsigned i
ssize_t ret = send(m_fd, (char *)buffer, length, 0); ssize_t ret = send(m_fd, (char *)buffer, length, 0);
if (ret != ssize_t(length)) { if (ret != ssize_t(length)) {
if (ret < 0) if (ret < 0)
fprintf(stderr, "Error returned from send, err=%d\n", errno); fprintf(stderr, "Error returned from send, err=%s\n", strerror(errno));
else else
fprintf(stderr, "Error only wrote %d of %d bytes\n", int(ret), int(length)); fprintf(stderr, "Error only wrote %d of %d bytes\n", int(ret), int(length));
return true; return true;

Loading…
Cancel
Save

Powered by TurnKey Linux.