Beispiel #1
0
Datei: qtc_log.c Projekt: Tlf/tlf
int log_recv_qtc_to_disk(int qsonr)
{
    char qtclogline[100], temp[80];
    int qpos = 0, i, tempi;

    for(i=0; i<10; i++) {

        if (strlen(qtcreclist.qtclines[i].time) == 4 &&
                strlen(qtcreclist.qtclines[i].callsign) > 0 &&
                strlen(qtcreclist.qtclines[i].serial) > 0) { // all fields are filled
            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, " %s ", qtcreclist.qtclines[i].receivedtime);
            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", qtcreclist.callsign);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

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

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

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

            sprintf(temp, " %-14s", qtcreclist.qtclines[i].callsign);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            tempi = atoi(qtcreclist.qtclines[i].serial);
            if(tempi < 1000) {
                sprintf(temp, "  %03d    ", tempi);
            }
            else {
                sprintf(temp, " %04d    ", tempi);
            }
            qpos = add_to_qtcline(qtclogline, temp, 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_recv_qtc(qtclogline);

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

    /* clear all line infos */
    for(i=0; i<10; i++) {
        qtcreclist.qtclines[i].time[0] = '\0';
        qtcreclist.qtclines[i].callsign[0] = '\0';
        qtcreclist.qtclines[i].serial[0] = '\0';
        qtcreclist.qtclines[i].status = 0;
        qtcreclist.qtclines[i].confirmed = 0;
        qtcreclist.qtclines[i].receivedtime[0] = '\0';
    }
    for(i=0; i<QTC_RY_LINE_NR; i++) {
        qtc_ry_lines[i].content[0] = '\0';
        qtc_ry_lines[i].attr = 0;
    }
    qtc_ry_currline = 0;
    qtc_ry_copied = 0;

    /* clear record list */
    qtcreclist.count = 0;
    qtcreclist.serial = 0;
    qtcreclist.confirmed = 0;
    qtcreclist.sentcfmall = 0;
    qtcreclist.callsign[0] = '\0';

    return (0);
}
Beispiel #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);
}