Example #1
0
File: qtc_log.c Project: Tlf/tlf
int log_sent_qtc_to_disk(int qsonr)
{
    char qtclogline[100], temp[80];
    int qpos = 0, i;

    for(i=0; i<10; i++) {
        if (qtclist.qtclines[i].saved == 0 && qtclist.qtclines[i].flag == 1 && qtclist.qtclines[i].sent == 1) { // not saved and marked for sent

            memset(qtclogline, sizeof(qtclogline)/sizeof(qtclogline[0]), ' ');
            qpos = 0;

            // QTC:  3799 PH 2003-03-23 0711 YB1AQS        001/10     DL8WPX        0330 DL6RAI        1021
            // QTC: 21086 RY 2001-11-10 0759 HA3LI           1/10     YB1AQS        0003 KB3TS          003

            sprintf(temp, "%3s", band[bandinx]);
            if (trxmode == CWMODE) {
                strcat(temp, "CW  ");
            }
            else if (trxmode == SSBMODE) {
                strcat(temp, "SSB ");
            }
            else {
                strcat(temp, "DIG ");
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, "%04d", qsonr);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d", qtclist.qtclines[i].qsoline+1);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %s ", qtclist.qtclines[i].senttime);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            if (lan_active == 1) {
                qtclogline[qpos++] = thisnode;	// set node ID...
            } else {
                qtclogline[qpos++] = ' ';
            }
            qtclogline[qpos++] = ' ';

            sprintf(temp, "%-14s", qtclist.callsign);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d", qtclist.serial);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d ", qtclist.count);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            strcpy(qtclogline+qpos, qtclist.qtclines[i].qtc);
            qpos+=strlen(qtclist.qtclines[i].qtc);

            qpos = add_to_qtcline(qtclogline, "    ", qpos);

            if (trx_control == 1) {
                snprintf(temp, 8, "%7.1f", freq);
            }
            else {
                snprintf(temp, 8, "      *");
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            qtclogline[qpos] = '\n';
            qtclogline[qpos + 1] = '\0';

            store_sent_qtc(qtclogline);

            // send qtc to other nodes......
            if (lan_active == 1) {
                send_lan_message(QTCSENTRY, qtclogline);
            }
        }
    }

    for(i=0; i<10; i++) {
        qtclist.qtclines[i].qtc[0] = '\0';
        qtclist.qtclines[i].flag = 0;
        qtclist.qtclines[i].saved = 0;
        qtclist.qtclines[i].sent = 0;
        qtclist.qtclines[i].senttime[0] = '\0';
    }

    qtclist.count = 0;
    qtclist.marked = 0;
    qtclist.totalsent = 0;

    return (0);
}
Example #2
0
void *background_process(void *ptr)
{

    extern int landebug;
    extern struct tm *time_ptr;

    static int i, t;
    static char prmessage[256];
    static int lantimesync = 0;
    static int fldigi_rpc_cnt = 0;

    int n;

    char debugbuffer[160];
    FILE *fp;

    i = 1;

    while (i) {

	while (stop_backgrnd_process == 1) {
	    sleep(1);
	}


	usleep(10000);

	if (packetinterface != 0) {
	    receive_packet();

	}

	if (trxmode == DIGIMODE && digikeyer != NO_KEYER)
	    rx_rtty();

	/*
	 * calling Fldigi XMLRPC method, which reads the Fldigi's carrier
	 * this function helps to show the correct freq of the RIG: reads
	 * the carrier value from Fldigi, and stores in a variable; then
	 * it readable by fldigi_get_carrier()
	 * only need at every 2nd cycle
	 * see fldigixmlrpc.[ch]
	 */
	if (trxmode == DIGIMODE && (digikeyer == GMFSK || digikeyer == FLDIGI)
		&& trx_control == 1) {
	    if (fldigi_rpc_cnt == 0) {
		fldigi_xmlrpc_get_carrier();
	    }
	    fldigi_rpc_cnt = 1 - fldigi_rpc_cnt;
	}

	if (stop_backgrnd_process == 0) {
	    write_keyer();
	    cw_simulator();
	}

	if (lan_active == 1) {
	    if (lan_message[0] == '\0') {

		if (lan_recv() < 0) {
		    recv_error++;
		} else {
		    lan_message[strlen(lan_message) - 1] = '\0';

		}
	    }

	    if (landebug == 1) {
		if ((fp = fopen("debuglog", "a")) == NULL) {
		    fprintf(stdout,
			    "store_qso.c: Error opening debug file.\n");

		}
		else {
		    get_time();
		    strftime(debugbuffer, 80, "%H:%M:%S-", time_ptr);
		    if (strlen(lan_message) > 2) {
			strcat(debugbuffer, lan_message);
			strcat(debugbuffer, "\n");
			fputs(debugbuffer, fp);
		    }

		    fclose(fp);
		}
	    }
	    if ((*lan_message != '\0') && (lan_message[0] == thisnode)) {
		mvprintw(24, 0,
		   "Warning: NODE ID CONFLICT ?! You should use another ID! ");
		refreshp();
		sleep(5);
	    }

	    if ((*lan_message != '\0')
		&& (lan_message[0] != thisnode)
		&& (stop_backgrnd_process != 1)) {

		switch (lan_message[1]) {

		case LOGENTRY:

		    log_to_disk(true);
		    break;

		case QTCRENTRY:

		    store_recv_qtc(lan_message+2);
		    break;

		case QTCSENTRY:

		    store_sent_qtc(lan_message+2);
		    break;

		case QTCFLAG:

		    parse_qtc_flagline(lan_message+2);
		    break;

		case CLUSTERMSG:
		    strncpy(prmessage, lan_message + 2, 80);
		    if (strstr(prmessage, call) != NULL)	// alert for cluster messages
		    {
			mvprintw(24, 0,
				 "                                                                           ");
			mvprintw(24, 0, "%s", prmessage);
			refreshp();
		    }

		    addtext(prmessage);
		    break;
		case TLFSPOT:
		    strncpy(prmessage, lan_message + 2, 80);
		    lanspotflg = 1;
		    addtext(prmessage);
		    lanspotflg = 0;
		    break;
		case TLFMSG:
		    for (t = 0; t < 4; t++)
			strcpy(talkarray[t], talkarray[t + 1]);

		    talkarray[4][0] = lan_message[0];
		    talkarray[4][1] = ':';
		    talkarray[4][2] = '\0';
		    strncat(talkarray[4], lan_message + 2, 60);
		    mvprintw(24, 0,
			     "                                                                           ");
		    mvprintw(24, 0, " MSG from %s", talkarray[4]);
		    refreshp();
		    break;
		case FREQMSG:
		    if ((lan_message[0] >= 'A')
			&& (lan_message[0] <= 'A' + MAXNODES)) {
			node_frequencies[lan_message[0] - 'A'] =
			    atof(lan_message + 2);
			break;
		    }
		case INCQSONUM:

		    n = atoi(lan_message + 2);

		    if (highqsonr < n)
			highqsonr = n;

		    if ((qsonum <= n) && (n > 0)) {
			qsonum = highqsonr + 1;
			qsonr_to_str();
		    }
		    lan_message[0] = '\0';

		case TIMESYNC:
		    if ((lan_message[0] >= 'A')
			&& (lan_message[0] <= 'A' + MAXNODES)) {
			lantime = atoi(lan_message + 2);

			if (lantimesync == 1)
			    timecorr =
				((4 * timecorr) + lantime -
				 (time(0) + (timeoffset * 3600L))) / 5;
			else {
			    timecorr =
				lantime - (time(0) + (timeoffset * 3600L));
			    lantimesync = 1;
			}

			break;
		    }
		}

		lan_message[0] = '\0';
		lan_message[1] = '\0';

	    }

	}

	gettxinfo();		/* get freq info from TRX */

    }

    return (NULL);
}