added status html page generation
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 21 Dec 2015 00:22:46 +0000 (00:22 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 21 Dec 2015 00:22:46 +0000 (00:22 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2555 01035d8c-6547-0410-b346-abe4f91aad63

freebeacon/freebeacon.c

index 9de2111115a9710e10127e7767d000dd27babb43..98fbf0e58d23903464b4743072c29899cce68eb2 100644 (file)
@@ -173,6 +173,8 @@ void printHelp(const struct option* long_options, int num_opts, char* argv[])
                        option_parameters = " pathToWaveFiles (path to where wave files are written)";
                 } else if (strcmp("rpigpio", long_options[i].name) == 0) {
                        option_parameters = " GPIO (BCM GPIO number on Raspberry Pi for Tx PTT)";
+                } else if (strcmp("statuspagefile", long_options[i].name) == 0) {
+                       option_parameters = " statusPageFileName (where to write status web page)";
                 }
                fprintf(stderr, "\t--%s%s\n", long_options[i].name, option_parameters);
        }
@@ -294,6 +296,7 @@ int main(int argc, char *argv[]) {
     int                 sfFs;
     int                 fssc;                 
     int                 triggerf, txfilenamef, callsignf, sampleratef, wavefilepathf, rpigpiof;
+    int                 statuspagef;
     int                 sync;
     char                commport[MAX_CHAR];
     char                callsign[MAX_CHAR];
@@ -304,6 +307,8 @@ int main(int argc, char *argv[]) {
     unsigned int        logCounter;
     char                waveFileWritePath[MAX_CHAR];
     char                rpigpio[MAX_CHAR], rpigpio_path[MAX_CHAR];
+    char                statusPageFileName[MAX_CHAR];
+    FILE               *fstatus;
 
     /* debug raw file */
 
@@ -326,6 +331,7 @@ int main(int argc, char *argv[]) {
     sfRecFileDecAudio = NULL;
     strcpy(waveFileWritePath, ".");
     *rpigpio = 0;
+    *statusPageFileName = 0;
 
     if (Pa_Initialize()) {
         fprintf(stderr, "Port Audio failed to initialize");
@@ -342,6 +348,7 @@ int main(int argc, char *argv[]) {
         { "callsign", required_argument, &callsignf, 1 },
         { "samplerate", required_argument, &sampleratef, 1 },
         { "wavefilewritepath", required_argument, &wavefilepathf, 1 },
+        { "statuspagefile", required_argument, &statuspagef, 1 },
         { "rpigpio", required_argument, &rpigpiof, 1 },
         { "list", no_argument, NULL, 'l' },
         { "help", no_argument, NULL, 'h' },
@@ -370,6 +377,8 @@ int main(int argc, char *argv[]) {
                 fssc = atoi(optarg);
             } else if (strcmp(long_options[option_index].name, "wavefilewritepath") == 0) {
                 strcpy(waveFileWritePath, optarg);
+            } else if (strcmp(long_options[option_index].name, "statuspagefile") == 0) {
+                strcpy(statusPageFileName, optarg);
             } else if (strcmp(long_options[option_index].name, "rpigpio") == 0) {
                 strcpy(rpigpio, optarg);
                 sys_gpio("/sys/class/gpio/unexport", rpigpio);
@@ -502,6 +511,7 @@ int main(int argc, char *argv[]) {
     fprintf(stderr, "trigger string: %s\ntxFileName: %s\n", triggerString, txFileName);
     fprintf(stderr, "PortAudio devNum: %d\nsamplerate: %d\n", devNum, fssc);
     fprintf(stderr, "WaveFileWritePath: %s\n", waveFileWritePath);
+    fprintf(stderr, "statusPageFile: %s\n", statusPageFileName);
     if (com_handle != COM_HANDLE_INVALID) {
         fprintf(stderr, "Comm Port for PTT: %s\n", commport);
     }
@@ -740,12 +750,22 @@ int main(int argc, char *argv[]) {
             break;
         }
 
-        if (verbose) {
-            if (logCounter++ == LOG_COUNTER) {
-                logCounter = 0;
+        if (logCounter++ == LOG_COUNTER) {
+            logCounter = 0;
+            if (verbose) {
                 fprintf(stderr, "state: %-20s  peak: %6d  sync: %d  SNR: %3.1f  triggered: %d\n", 
                         state_str[state], peak, sync, snr_est, triggered);
             }
+            if (*statusPageFileName) {
+                fstatus = fopen(statusPageFileName, "wt");
+                if (fstatus != NULL) {
+                    fprintf(fstatus, "<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"2\">\n</head>\n<body>\n");
+                    fprintf(fstatus, "state: %s peak: %d sync: %d SNR: %3.1f triggered: %d\n", 
+                            state_str[state], peak, sync, snr_est, triggered);
+                    fprintf(fstatus, "</body>\n</html>\n");
+                }
+                fclose(fstatus);
+            }
         }
 
         state = next_state;