コード例 #1
0
ファイル: unixinput.c プロジェクト: Analias/multimon-ng
int main(int argc, char *argv[])
{
    int c;
    int errflg = 0;
    int quietflg = 0;
    int i;
    char **itype;
    int mask_first = 1;
    int sample_rate = -1;
    unsigned int overlap = 0;
    char *input_type = "hw";

    while ((c = getopt(argc, argv, "t:a:s:v:b:f:g:d:o:cqhAmrxynipeu")) != EOF) {
        switch (c) {
        case 'h':
        case '?':
            errflg++;
            break;
            
        case 'q':
            quietflg++;
            break;
            
        case 'A':
            aprs_mode = 1;
            memset(dem_mask, 0, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; (unsigned int) i < NUMDEMOD; i++)
                if (!strcasecmp("AFSK1200", dem[i]->name)) {
                    MASK_SET(i);
                    break;
                }
            break;
            
        case 'v':
            verbose_level = strtoul(optarg, 0, 0);
            break;

        case 'b':
            pocsag_error_correction = strtoul(optarg, 0, 0);
            if(pocsag_error_correction > 2 || pocsag_error_correction < 0)
            {
                fprintf(stderr, "Invalid error correction value!\n");
                pocsag_error_correction = 2;
            }
            break;

        case'p':
            pocsag_show_partial_decodes = 1;
            break;

        case'u':
            pocsag_heuristic_pruning = 1;
            break;

        case'e':
            pocsag_prune_empty = 1;
            break;
            
        case 'm':
            mute_sox = 1;
            break;
            
        case 'r':
            repeatable_sox = 1;
            break;
            
        case 't':
            for (itype = (char **)allowed_types; *itype; itype++)
                if (!strcmp(*itype, optarg)) {
                    input_type = *itype;
                    goto intypefound;
                }
            fprintf(stderr, "invalid input type \"%s\"\n"
                    "allowed types: ", optarg);
            for (itype = (char **)allowed_types; *itype; itype++)
                fprintf(stderr, "%s ", *itype);
            fprintf(stderr, "\n");
            errflg++;
intypefound:
            break;
            
        case 'a':
            if (mask_first)
                memset(dem_mask, 0, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; (unsigned int) i < NUMDEMOD; i++)
                if (!strcasecmp(optarg, dem[i]->name)) {
                    MASK_SET(i);
                    break;
                }
            if ((unsigned int) i >= NUMDEMOD) {
                fprintf(stderr, "invalid mode \"%s\"\n", optarg);
                errflg++;
            }
            break;
            
        case 's':
            if (mask_first)
                memset(dem_mask, 0xff, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; (unsigned int) i < NUMDEMOD; i++)
                if (!strcasecmp(optarg, dem[i]->name)) {
                    MASK_RESET(i);
                    break;
                }
            if ((unsigned int) i >= NUMDEMOD) {
                fprintf(stderr, "invalid mode \"%s\"\n", optarg);
                errflg++;
            }
            break;
            
        case 'c':
            if (mask_first)
                memset(dem_mask, 0xff, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; (unsigned int) i < NUMDEMOD; i++)
                MASK_RESET(i);
            break;
            
        case 'f':
            if(!pocsag_mode)
            {
                if(!strncmp("numeric",optarg, sizeof("numeric")))
                    pocsag_mode = POCSAG_MODE_NUMERIC;
                else if(!strncmp("alpha",optarg, sizeof("alpha")))
                    pocsag_mode = POCSAG_MODE_ALPHA;
                else if(!strncmp("skyper",optarg, sizeof("skyper")))
                    pocsag_mode = POCSAG_MODE_SKYPER;
            }else fprintf(stderr, "a POCSAG mode has already been selected!\n");
            break;
            
        case 'n':
            dont_flush = true;
            break;

        case 'i':
            pocsag_invert_input = true;
            break;
            
        case 'd':
        {
            int i = 0;
            sscanf(optarg, "%d", &i);
            if(i) cw_dit_length = abs(i);
            break;
        }
            
        case 'g':
        {
            int i = 0;
            sscanf(optarg, "%d", &i);
            if(i) cw_gap_length = abs(i);
            break;
        }
            
        case 'o':
        {
            int i = 0;
            sscanf(optarg, "%d", &i);
            if(i) cw_threshold = abs(i);
            break;
        }
            
        case 'x':
            cw_disable_auto_threshold = true;
            break;
            
        case 'y':
            cw_disable_auto_timing = true;
            break;
        }
    }


    if ( !quietflg )
    { // pay heed to the quietflg
    fprintf(stderr, "multimon-ng  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA\n"
        "             (C) 2012-2014 by Elias Oenal\n"
        "available demodulators:");
    for (i = 0; (unsigned int) i < NUMDEMOD; i++) {
        fprintf(stderr, " %s", dem[i]->name);
    }
    fprintf(stderr, "\n");
    }

    if (errflg) {
        (void)fprintf(stderr, usage_str, argv[0]);
        exit(2);
    }
    if (mask_first)
        memset(dem_mask, 0xff, sizeof(dem_mask));
    
    if (!quietflg)
        fprintf(stdout, "Enabled demodulators:");
    for (i = 0; (unsigned int) i < NUMDEMOD; i++)
        if (MASK_ISSET(i)) {
            if (!quietflg)
                fprintf(stdout, " %s", dem[i]->name);       //Print demod name
            if(dem[i]->float_samples) integer_only = false; //Enable float samples on demand
            memset(dem_st+i, 0, sizeof(dem_st[i]));
            dem_st[i].dem_par = dem[i];
            if (dem[i]->init)
                dem[i]->init(dem_st+i);
            if (sample_rate == -1)
                sample_rate = dem[i]->samplerate;
            else if ( (unsigned int) sample_rate != dem[i]->samplerate) {
                if (!quietflg)
                    fprintf(stdout, "\n");
                fprintf(stderr, "Error: Current sampling rate %d, "
                        " demodulator \"%s\" requires %d\n",
                        sample_rate, dem[i]->name, dem[i]->samplerate);
                exit(3);
            }
            if (dem[i]->overlap > overlap)
                overlap = dem[i]->overlap;
        }
    if (!quietflg)
        fprintf(stdout, "\n");
    
    if (optind < argc && !strcmp(argv[optind], "-"))
    {
        input_type = "raw";
    }
    
    if (!strcmp(input_type, "hw")) {
        if ((argc - optind) >= 1)
            input_sound(sample_rate, overlap, argv[optind]);
        else
            input_sound(sample_rate, overlap, NULL);
        quit();
        exit(0);
    }
    if ((argc - optind) < 1) {
        (void)fprintf(stderr, "no source files specified\n");
        exit(4);
    }
    
    for (i = optind; i < argc; i++)
        input_file(sample_rate, overlap, argv[i], input_type);
    
    quit();
    exit(0);
}
コード例 #2
0
ファイル: unixinput.c プロジェクト: starcodekei/easmon-ng
int main(int argc, char *argv[])
{
    int c;
    int errflg = 0;
    int quietflg = 0;
    int i;
    char **itype;
    int mask_first = 1;
    int sample_rate = -1;
    unsigned int overlap = 0;
    char *input_type = "hw";

    while ((c = getopt(argc, argv, "t:v:qhmrn")) != EOF) {
        switch (c) {
        case 'h':
        case '?':
            errflg++;
            break;
            
        case 'q':
            quietflg++;
            break;
            
        case 'v':
            verbose_level = strtoul(optarg, 0, 0);
            break;

        case 'm':
            mute_sox = 1;
            break;
            
        case 'r':
            repeatable_sox = 1;
            break;
            
        case 't':
            for (itype = (char **)allowed_types; *itype; itype++)
                if (!strcmp(*itype, optarg)) {
                    input_type = *itype;
                    goto intypefound;
                }
            fprintf(stderr, "invalid input type \"%s\"\n"
                    "allowed types: ", optarg);
            for (itype = (char **)allowed_types; *itype; itype++)
                fprintf(stderr, "%s ", *itype);
            fprintf(stderr, "\n");
            errflg++;
intypefound:
            break;
            
        case 'n':
            dont_flush = true;
            break;

        }
    }


    if ( !quietflg )
    { // pay heed to the quietflg
    fprintf(stderr, "easmon-ng  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA\n"
        "             (C) 2012-2014 by Elias Oenal\n"
        "             (C) 2014 by Steven Salerno K5SQL\n");
    }

    if (errflg) {
        (void)fprintf(stderr, usage_str, argv[0]);
        exit(2);
    }
    if (mask_first)
        memset(dem_mask, 0xff, sizeof(dem_mask));
    
    for (i = 0; (unsigned int) i < NUMDEMOD; i++)
        if (MASK_ISSET(i)) {
            if(dem[i]->float_samples) integer_only = false; //Enable float samples on demand
            memset(dem_st+i, 0, sizeof(dem_st[i]));
            dem_st[i].dem_par = dem[i];
            if (dem[i]->init)
                dem[i]->init(dem_st+i);
            if (sample_rate == -1)
                sample_rate = dem[i]->samplerate;
            else if ( (unsigned int) sample_rate != dem[i]->samplerate) {
                if (!quietflg)
                    fprintf(stdout, "\n");
                fprintf(stderr, "Error: Current sampling rate %d, "
                        " demodulator \"%s\" requires %d\n",
                        sample_rate, dem[i]->name, dem[i]->samplerate);
                exit(3);
            }
            if (dem[i]->overlap > overlap)
                overlap = dem[i]->overlap;
        }
    if (!quietflg)
        fprintf(stdout, "\n");
    
    if (optind < argc && !strcmp(argv[optind], "-"))
    {
        input_type = "raw";
    }
    
    if (!strcmp(input_type, "hw")) {
        if ((argc - optind) >= 1)
            input_sound(sample_rate, overlap, argv[optind]);
        else
            input_sound(sample_rate, overlap, NULL);
        quit();
        exit(0);
    }
    if ((argc - optind) < 1) {
        (void)fprintf(stderr, "no source files specified\n");
        exit(4);
    }
    
    for (i = optind; i < argc; i++)
        input_file(sample_rate, overlap, argv[i], input_type);
    
    quit();
    exit(0);
}
コード例 #3
0
ファイル: multimon.c プロジェクト: pinkavaj/multimon-lib
int main(int argc, char *argv[])
{
	int c;
	int errflg = 0;
	int i;
	char **itype;
	int mask_first = 1;
	int sample_rate = -1;
	unsigned int overlap = 0;
	char *input_type = "hw";

	fprintf(stdout, "multimod  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA\n"
		"available demodulators:");
	for (i = 0; i < NUMDEMOD; i++) 
		fprintf(stdout, " %s", dem[i]->name);
	fprintf(stdout, "\n");
	while ((c = getopt(argc, argv, "t:a:s:v:")) != EOF) {
		switch (c) {
		case '?':
			errflg++;
			break;

		case 'v':
			multimon_debug_level = strtoul(optarg, 0, 0);
			break;

		case 't':
			for (itype = (char **)allowed_types; *itype; itype++) 
				if (!strcmp(*itype, optarg)) {
					input_type = *itype;
					goto intypefound;
				}
			fprintf(stderr, "invalid input type \"%s\"\n"
				"allowed types: ", optarg);
			for (itype = (char **)allowed_types; *itype; itype++) 
				fprintf(stderr, "%s ", *itype);
			fprintf(stderr, "\n");
			errflg++;
		intypefound:
			break;
		
		case 'a':
			if (mask_first)
				memset(dem_mask, 0, sizeof(dem_mask));
			mask_first = 0;
			for (i = 0; i < NUMDEMOD; i++)
				if (!strcasecmp(optarg, dem[i]->name)) {
					MASK_SET(i);
					break;
				}
			if (i >= NUMDEMOD) {
				fprintf(stderr, "invalid mode \"%s\"\n", optarg);
				errflg++;
			}
			break;

		case 's':
			if (mask_first)
				memset(dem_mask, 0xff, sizeof(dem_mask));
			mask_first = 0;
			for (i = 0; i < NUMDEMOD; i++)
				if (!strcasecmp(optarg, dem[i]->name)) {
					MASK_RESET(i);
					break;
				}
			if (i >= NUMDEMOD) {
				fprintf(stderr, "invalid mode \"%s\"\n", optarg);
				errflg++;
			}
			break;
			
		}
	}
	if (errflg) {
		(void)fprintf(stderr, usage_str);
		exit(2);
	}
	if (mask_first)
		memset(dem_mask, 0xff, sizeof(dem_mask));

	fprintf(stdout, "Enabled demodulators:");
	for (i = 0; i < NUMDEMOD; i++) 
		if (MASK_ISSET(i)) {
			fprintf(stdout, " %s", dem[i]->name);
			memset(dem_st+i, 0, sizeof(dem_st[i]));
			dem_st[i].dem_par = dem[i];
			if (dem[i]->init)
				dem[i]->init(dem_st+i, print_data, NULL);
			if (sample_rate == -1)
				sample_rate = dem[i]->samplerate;
			else if (sample_rate != dem[i]->samplerate) {
				fprintf(stdout, "\n");
				fprintf(stderr, "Error: Current sampling rate %d, "
					" demodulator \"%s\" requires %d\n",
					sample_rate, dem[i]->name, dem[i]->samplerate);
				exit(3);
			}
			if (dem[i]->overlap > overlap)
				overlap = dem[i]->overlap;
		}
	fprintf(stdout, "\n");

	if (!strcmp(input_type, "hw")) {
		if ((argc - optind) >= 1)
			input_sound(sample_rate, overlap, argv[optind]);
		else 
			input_sound(sample_rate, overlap, NULL);
		exit(0);
	}
	if ((argc - optind) < 1) {
		(void)fprintf(stderr, "no source files specified\n");
		exit(4);
	}
	for (i = optind; i < argc; i++)
		input_file(sample_rate, overlap, argv[i], input_type);
	exit(0);
}
コード例 #4
0
ファイル: unixinput.c プロジェクト: arekinath/multimonNG
int main(int argc, char *argv[])
{
    int c;
    int errflg = 0;
    int quietflg = 0;
    int i;
    char **itype;
    int mask_first = 1;
    int sample_rate = -1;
    unsigned int overlap = 0;
    char *input_type = "hw";

    fprintf(stderr, "multimonNG  (C) 1996/1997 by Tom Sailer HB9JNX/AE4WA\n"
            "            (C) 2012 by Elias Oenal\n"
            "available demodulators:");
    for (i = 0; i < NUMDEMOD; i++)
        fprintf(stderr, " %s", dem[i]->name);
    fprintf(stderr, "\n");
    while ((c = getopt(argc, argv, "t:a:s:v:f:cqh")) != EOF) {
        switch (c) {
        case 'h':
        case '?':
            errflg++;
            break;

        case 'q':
            quietflg++;
            break;

        case 'v':
            verbose_level = strtoul(optarg, 0, 0);
            break;

        case 't':
            for (itype = (char **)allowed_types; *itype; itype++)
                if (!strcmp(*itype, optarg)) {
                    input_type = *itype;
                    goto intypefound;
                }
            fprintf(stderr, "invalid input type \"%s\"\n"
                    "allowed types: ", optarg);
            for (itype = (char **)allowed_types; *itype; itype++)
                fprintf(stderr, "%s ", *itype);
            fprintf(stderr, "\n");
            errflg++;
intypefound:
            break;

        case 'a':
            if (mask_first)
                memset(dem_mask, 0, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; i < NUMDEMOD; i++)
                if (!strcasecmp(optarg, dem[i]->name)) {
                    MASK_SET(i);
                    break;
                }
            if (i >= NUMDEMOD) {
                fprintf(stderr, "invalid mode \"%s\"\n", optarg);
                errflg++;
            }
            break;

        case 's':
            if (mask_first)
                memset(dem_mask, 0xff, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; i < NUMDEMOD; i++)
                if (!strcasecmp(optarg, dem[i]->name)) {
                    MASK_RESET(i);
                    break;
                }
            if (i >= NUMDEMOD) {
                fprintf(stderr, "invalid mode \"%s\"\n", optarg);
                errflg++;
            }
            break;

        case 'c':
            if (mask_first)
                memset(dem_mask, 0xff, sizeof(dem_mask));
            mask_first = 0;
            for (i = 0; i < NUMDEMOD; i++)
                MASK_RESET(i);
            break;

        case 'f':
            if(!pocsag_mode)
            {
                if(!strncmp("numeric",optarg, sizeof("numeric")))
                    pocsag_mode = POCSAG_MODE_NUMERIC;
                else if(!strncmp("alpha",optarg, sizeof("alpha")))
                    pocsag_mode = POCSAG_MODE_ALPHA;
                else if(!strncmp("skyper",optarg, sizeof("skyper")))
                    pocsag_mode = POCSAG_MODE_SKYPER;
            }else fprintf(stderr, "a POCSAG mode has already been selected!\n");
            break;
        }
    }
    if (errflg) {
        (void)fprintf(stderr, usage_str, argv[0]);
        exit(2);
    }
    if (mask_first)
        memset(dem_mask, 0xff, sizeof(dem_mask));

    if (!quietflg)
        fprintf(stdout, "Enabled demodulators:");
    for (i = 0; i < NUMDEMOD; i++)
        if (MASK_ISSET(i)) {
            if (!quietflg)
                fprintf(stdout, " %s", dem[i]->name);
            memset(dem_st+i, 0, sizeof(dem_st[i]));
            dem_st[i].dem_par = dem[i];
            if (dem[i]->init)
                dem[i]->init(dem_st+i);
            if (sample_rate == -1)
                sample_rate = dem[i]->samplerate;
            else if (sample_rate != dem[i]->samplerate) {
                if (!quietflg)
                    fprintf(stdout, "\n");
                fprintf(stderr, "Error: Current sampling rate %d, "
                        " demodulator \"%s\" requires %d\n",
                        sample_rate, dem[i]->name, dem[i]->samplerate);
                exit(3);
            }
            if (dem[i]->overlap > overlap)
                overlap = dem[i]->overlap;
        }
    if (!quietflg)
        fprintf(stdout, "\n");

    if (optind < argc && !strcmp(argv[optind], "-"))
    {
       input_type = "raw";
    }

    if (!strcmp(input_type, "hw")) {
        if ((argc - optind) >= 1)
            input_sound(sample_rate, overlap, argv[optind]);
        else
            input_sound(sample_rate, overlap, NULL);
        quit();
        exit(0);
    }
    if ((argc - optind) < 1) {
        (void)fprintf(stderr, "no source files specified\n");
        exit(4);
    }

    for (i = optind; i < argc; i++)
        input_file(sample_rate, overlap, argv[i], input_type);

    quit();
    exit(0);
}