diff --git a/src/dialogs/fl_digi.cxx b/src/dialogs/fl_digi.cxx index d2cac1cd..b37fd14b 100644 --- a/src/dialogs/fl_digi.cxx +++ b/src/dialogs/fl_digi.cxx @@ -3862,7 +3862,9 @@ void noop_controls() // create and then hide all controls not being used btnMacroTimer = new Fl_Button(defwidget); btnMacroTimer->hide(); - ReceiveText = new FTextRX(0,0,100,100); ReceiveText->hide(); + if(bWF_only) { + ReceiveText = new FTextRX(0,0,100,100); ReceiveText->hide(); + } TransmitText = new FTextTX(0,0,100,100); TransmitText->hide(); FHdisp = new Raster(0,0,10,100); FHdisp->hide(); @@ -4188,6 +4190,8 @@ int HAB_height = 0; void create_fl_digi_main_dl_fldigi() { + progdefaults.autoextract == true; + int fnt = fl_font(); int fsize = fl_size(); int freqheight = Hentry + 2 * pad; diff --git a/src/include/configuration.h b/src/include/configuration.h index 38980b4e..148d619a 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -1079,7 +1079,10 @@ "report.pskreporter.info") \ ELEM_(std::string, pskrep_port, "PSKREPPORT", \ "Reception report server port", \ - "4739") + "4739") \ + ELEM_(std::string, xmlFields, "", "", "7") \ + ELEM_(std::string, xmlField_delimiter, "", "", ",") \ + ELEM_(std::string, xmlSentence_delimiter, "", "", "$$") // declare the struct diff --git a/src/include/extra.h b/src/include/extra.h new file mode 100644 index 00000000..f3418e4b --- /dev/null +++ b/src/include/extra.h @@ -0,0 +1,10 @@ +#ifndef _EXTRA_H_ +#define _EXTRA_H_ + +#include + +void UpperCase(std::string& str); + +//void TrimSpaces( string& str); + +#endif \ No newline at end of file diff --git a/src/logger/rx_extract.cxx b/src/logger/rx_extract.cxx index f76a985d..e0629448 100644 --- a/src/logger/rx_extract.cxx +++ b/src/logger/rx_extract.cxx @@ -31,10 +31,40 @@ #include "fl_digi.h" #include "configuration.h" +//jcoxon +#include "extra.h" +// + using namespace std; -const char *beg = "[WRAP:beg]"; -const char *end = "[WRAP:end]"; +//jcoxon +void UpperCase(string& str) +{ + for(int i = 0; i < str.length(); i++) + { + str[i] = toupper(str[i]); + } + return; +} +// + +void TrimSpaces( string& str) +{ + + // Trim Both leading and trailing spaces + size_t startpos = str.find_first_not_of(" "); // Find the first character position after excluding leading blank spaces + size_t endpos = str.find_last_not_of("\r\n"); // Find the first character position from reverse af + + // if all spaces or empty return an empty string + if(( string::npos == startpos ) || ( string::npos == endpos)) + { + str = ""; + } + else + str = str.substr( startpos, endpos-startpos+1 ); +} + +const char *end = "\n"; #ifdef __WIN32__ const char *txtWrapInfo = "\ Detect the occurance of [WRAP:beg] and [WRAP:end]\n\ @@ -56,6 +86,20 @@ bool bInit = false; char dttm[64]; +//jcoxon +//Default rules +int total_string_length = 100; +int min_number_fields = 10; +int field_length = 10; + +int dodge_data = 0; +bool validate_output; +int number_commas; +int old_i = 0, field_number = 0; +string rx_buff_edit; +string tmpfield; +// + void rx_extract_reset() { rx_buff.clear(); @@ -66,6 +110,8 @@ void rx_extract_reset() void rx_extract_add(int c) { + extern int rjh_pfds[2]; + if (!c) return; if (!bInit) { @@ -76,7 +122,11 @@ void rx_extract_add(int c) memmove(rx_extract_buff, &rx_extract_buff[1], bufsize - 1); rx_extract_buff[bufsize - 1] = ch; - +//jcoxon + //Reads the stentence delimter previously read from the xml file. + //const char* beg = (progdefaults.xmlSentence_delimiter.empty() ? "UNKNOWN" : progdefaults.xmlSentence_delimiter.c_str()); + const char* beg = "$$"; +// if ( strstr(rx_extract_buff, beg) != NULL ) { rx_buff = beg; rx_extract_msg = "Extracting"; @@ -107,6 +157,48 @@ void rx_extract_add(int c) rx_extract_msg.append(WRAP_recv_dir); put_status(rx_extract_msg.c_str(), 20, STATUS_CLEAR); +//jcoxon + //Trim Spaces + TrimSpaces(rx_buff); + + // Find the sentence start marker and remove up to the end of it + // dkjhdskdkfdakhd $$icarus,... -> icarus,... + + rx_buff = rx_buff.substr( + rx_buff.find(progdefaults.xmlSentence_delimiter)+ + progdefaults.xmlSentence_delimiter.length()); + //I've removed the old swap callsign function as its not needed any longer. + + //Counts number of fields + number_commas = count(rx_buff.begin(), rx_buff.end(), progdefaults.xmlField_delimiter.at(0)); + + //Gets info for number of fields + //min_number_fields = atoi(progdefaults.xmlFields.c_str()); + + //Check rules - telem string length and number of fields and whether each field has been validated + if ((rx_buff.length() < total_string_length) and (number_commas == min_number_fields - 1)) { + string identity_callsign = (progdefaults.myCall.empty() ? "UNKNOWN" : progdefaults.myCall.c_str()); + UpperCase (identity_callsign); + + string postData = "string=" + rx_buff + "&identity=" + identity_callsign + "\n"; + + //We really don't want people sending status updates from UNKNOWN - somehow need to remind people to change their callsign + if (identity_callsign != "UNKNOWN") { +#if !defined(__CYGWIN__) + cout << "PARENT: sent " + postData ; +#endif + const char* data = postData.c_str(); + write (rjh_pfds[1],data,strlen(data)); + rx_extract_msg = "Data uploaded to server"; + put_status(rx_extract_msg.c_str(), 20, STATUS_CLEAR); + } + else { +#if !defined(__CYGWIN__) + cout << "Need to enter a callsign, please go to 'Configure' then 'Operator' and add a callsign/nickname.\n"; +#endif + } + } +// rx_extract_reset(); } else if (rx_buff.length() > 16384) { rx_extract_msg = "Extract length exceeded 16384 bytes"; diff --git a/src/main.cxx b/src/main.cxx index 7a297a07..6a6c2561 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -113,10 +113,7 @@ using namespace std; //jcoxon include files -#include -#include -#include -#include "misc/extra.h" +#include "misc/dlpipe.h" // string appname; diff --git a/src/misc/extra.h b/src/misc/dlpipe.h similarity index 95% rename from src/misc/extra.h rename to src/misc/dlpipe.h index 7e98e839..1cd2d197 100644 --- a/src/misc/extra.h +++ b/src/misc/dlpipe.h @@ -1,7 +1,9 @@ #ifndef _EXTRA_H_ #define _EXTRA_H_ - -//void UpperCase(string& str); +#include +#include +#include +#include //-------------------------------------// /* RJH Pipe vars */ diff --git a/src/misc/status.cxx b/src/misc/status.cxx index 2396ff2f..ad5acca7 100644 --- a/src/misc/status.cxx +++ b/src/misc/status.cxx @@ -393,6 +393,8 @@ void status::initLastState() if (bWF_only) fl_digi_main->resize(mainX, mainY, mainW, Hmenu + Hwfall + Hstatus + 4); +else if (bHAB) + fl_digi_main->resize(mainX, mainY, mainW, Hmenu + Hwfall + 100 + Hstatus + 4); else { fl_digi_main->resize(mainX, mainY, mainW, mainH); if (!(RxTextHeight > 0 && RxTextHeight < TiledGroup->h())) diff --git a/src/trx/trx.cxx b/src/trx/trx.cxx index cdc44d3f..1428b37c 100644 --- a/src/trx/trx.cxx +++ b/src/trx/trx.cxx @@ -51,6 +51,21 @@ LOG_FILE_SOURCE(debug::LOG_MODEM); using namespace std; +//New stuff added by jcoxon +#include +#include +#include "extra.h"; + +time_t rawtime; +struct tm * timeinfo; + +time_t seconds; +int status_count = 901; //Why 1001? well as it'll trigger the status update to be sent when fldigi starts +int old_seconds = 0; + +char date_time [80]; +// + void trx_reset_loop(); void trx_start_modem_loop(); void trx_receive_loop(); @@ -89,6 +104,10 @@ void trx_trx_receive_loop() { size_t numread; int current_samplerate; + + //jcoxon + extern int rjh_pfds[2]; + // assert(powerof2(SCBLOCKSIZE)); if (unlikely(!active_modem)) { @@ -126,6 +145,66 @@ void trx_trx_receive_loop() active_modem->rx_init(); while (1) { + //New stuff added by jcoxon + if (status_count >= 1000) { + seconds = time (NULL); +#if !defined(__CYGWIN__) + cout << seconds << "\n"; +#endif + if (int(seconds) > old_seconds + 900) { + //Send status update +#if !defined(__CYGWIN__) + cout << "Send status update\n"; +#endif + + string identity_callsign = (progdefaults.myCall.empty() ? "UNKNOWN" : progdefaults.myCall.c_str()); + UpperCase (identity_callsign); + //string string_lat = (progdefaults.myLat.empty() ? "UNKNOWN" : progdefaults.myLat.c_str()); + string string_lat = "52.0"; + UpperCase (string_lat); + //string string_lon = (progdefaults.myLon.empty() ? "UNKNOWN" : progdefaults.myLon.c_str()); + string string_lon = "0.0"; + UpperCase (string_lon); + //string string_radio = (progdefaults.myRadio.empty() ? "UNKNOWN" : progdefaults.myRadio.c_str()); + string string_radio = "radio"; + UpperCase (string_radio); + string string_antenna = (progdefaults.myAntenna.empty() ? "UNKNOWN" : progdefaults.myAntenna.c_str()); + UpperCase (string_antenna); + //string string_payload = (progdefaults.flight_sel.empty() ? "UNKNOWN" : progdefaults.flight_sel.c_str()); + string string_payload = "Test"; + UpperCase (string_payload); + + time ( &rawtime ); + timeinfo = gmtime ( &rawtime ); + strftime(date_time,80,"%Y-%m-%d %H:%M:%S",timeinfo); +#if !defined(__CYGWIN__) + cout << date_time << "\n"; +#endif +//-------------------------------------------------------- + string dlfldigi_version = "r100"; //Please update with revision number +//------------------------------------------------------- + //ZZ,Callsign,Date Time,Lat,Lon,Radio,Antenna + string rx_data ="ZZ," + identity_callsign + "," + date_time + "," + string_lat + "," + string_lon + "," + string_radio + "," + string_antenna + "," + dlfldigi_version + "," + string_payload; + string postData = "string=" + rx_data + "&identity=" + identity_callsign + "\n"; + + //We really don't want people sending status updates from UNKNOWN - somehow need to remind people to change their callsign + if (identity_callsign != "UNKNOWN") { + const char* data = postData.c_str(); + write (rjh_pfds[1],data,strlen(data)); + } + else { +#if !defined(__CYGWIN__) + cout << "Need to enter a callsign, please go to 'Configure' then 'Operator' and add a callsign/nickname.\n"; +#endif + } + old_seconds = seconds; + } + status_count = 0; + } + else { + status_count++; + } + //-------------------------- try { numread = 0; while (numread < SCBLOCKSIZE && trx_state == STATE_RX)