Ejemplo n.º 1
0
/* service routines for expression reading */
getnum(int (*rdf)(void))
{
	char *cp;
	int base, d;
	BOOL fpnum;
	char num[MAXLIN];

	base = 0;
	fpnum = FALSE;
	if (lastc == '#') {
		base = 16;
		(*rdf)();
	}
	if (convdig(lastc) >= MAXBASE)
		return (0);
	if (lastc == '0')
		switch ((*rdf)()) {
		case 'x':
		case 'X':
			base = 16;
			(*rdf)();
			break;

		case 't':
		case 'T':
			base = 10;
			(*rdf)();
			break;

		case 'o':
		case 'O':
			base = 8;
			(*rdf)();
			break;
		default:
			if (base == 0)
				base = 8;
			break;
		}
	if (base == 0)
		base = 10;
	expv = 0;
	for (cp = num, *cp = lastc; ;(*rdf)()) {
		if ((d = convdig(lastc)) < base) {
			expv *= base;
			expv += d;
			*cp++ = lastc;
		}
		else if (lastc == '.') {
			fpnum = TRUE;
			*cp++ = lastc;
		} else {
			reread();
			break;
		}
	}
	if (fpnum)
		expv = fpin(num);
	return (1);
}
Ejemplo n.º 2
0
int ReadWFM(const wxString filename, const char *file_output, std::vector< std::pair<int, int> > &iq_pairs)
{
    if (filename.length() <= 1)
        return 0;
    wxFFile fpin(filename, "rb");
    //FILE *fpout;				// File pointers
    unsigned char inputBuffer[4];
    unsigned char c1, c2, c3, c4;			// To read Agilent Signal Studio file
    double iin, qin;			// IQ inputs
    int iint, qint;					// IQ integer versions
    int cnt = 0;

    if (fpin.IsOpened() == false)
    {
        printf("WFM Converter: Input file can not be opened.");
        return -1;
    }

    while (fpin.Read(inputBuffer, 4) == 4)
    {
        c1 = inputBuffer[0];
        c2 = inputBuffer[1];
        c3 = inputBuffer[2];
        c4 = inputBuffer[3];

        cnt++;

        c1 &= 0xFF;
        c2 &= 0xFF;
        c3 &= 0xFF;
        c4 &= 0xFF;

        if (c1 & 0x80) iin = (double)(-1 * (1 << 15) + ((c1 & 0x7F) << 8) + c2);
        else iin = (double)(((c1 & 0x7F) << 8) + c2);

        if (c3 & 0x80) qin = (double)(-1 * (1 << 15) + ((c3 & 0x7F) << 8) + c4);
        else qin = (double)(((c3 & 0x7F) << 8) + c4);

        iint = (int)(iin);
        qint = (int)(qin);

        iint = iint >> 4;
        qint = qint >> 4;

        iq_pairs.push_back(std::pair<int, int>(iint, qint));
    };
    return 0;
}