Exemplo n.º 1
0
void print_status()
{
    int stat;
    char version[20];

    stat = fcdGetMode();

    if (stat == FCD_MODE_NONE)
    {
        printf("No FCD Detected.\n");
        return;
    }
    else if (stat == FCD_MODE_BL)
    {
        printf("FCD present in bootloader mode.\n");
        return;
    }
    else	
    {
        printf("FCD present in application mode.\n");
        stat = fcdGetFwVerStr(version);
        printf("FCD firmware version: %s.\n", version);
        unsigned char b[8];
        stat = fcdAppGetParam(FCD_CMD_APP_GET_FREQ_HZ,b,8);
        printf("FCD frequency: %.6f MHz.\n", (*(int *)b)/1e6);
        stat = fcdAppGetParam(FCD_CMD_APP_GET_LNA_GAIN,b,1);
#ifdef FCDPP
        printf("FCD LNA gain: %s.\n", b[0] == 1 ? "enabled" : "disabled");
#else
		printf("FCD LNA gain: %g dB.\n", lnagainvalues[b[0]]);
#endif
        return;
    }
}
Exemplo n.º 2
0
void print_status()
{
	int stat;
	char version[20];

	stat = fcdGetMode();

	if (stat == FCD_MODE_NONE)
	{
		printf("No FCD Detected.\n");
		return;
	}
	else if (stat == FCD_MODE_BL)
	{
		printf("FCD present in bootloader mode.\n");
		return;
	}
	else	
	{
		printf("FCD present in application mode.\n");
		stat = fcdGetFwVerStr(version);
		printf("FCD firmware version: %s.\n", version);
		return;
	}
}
Exemplo n.º 3
0
void print_list(void)
{
    // based on code from fcd.c
    struct hid_device_info *phdi=NULL;
    //hid_device *phd=NULL;
    //char *pszPath=NULL;

    // look for all FCDs
    phdi=hid_enumerate(_usVID,_usPID);
    if (phdi==NULL)
    {
        puts("No FCD found.\n");
        return;
    }

    puts("  nr   USB path       firmware   frequency         LNA gain   audio device");
    //      0    0004:0006:02   18.09      1234.567890 MHz   +20 dB     card2

    // iterate over all FCDs found
    int idx=0;
    while (phdi) {
        whichdongle=idx;
        printf("  %-3i  %-12s  ",idx, phdi->path);
        int stat = fcdGetMode();
        if (stat == FCD_MODE_NONE) printf("No FCD Detected.\n");
        else if (stat == FCD_MODE_BL) printf("In bootloader mode.\n");
        else {
            uint8_t lnagain;
            uint8_t freq[4];
            char version[20];

            // read version, frequency, gain
            fcdGetFwVerStr(version);
            fcdAppGetParam(FCD_CMD_APP_GET_FREQ_HZ,freq,4);
            fcdAppGetParam(FCD_CMD_APP_GET_LNA_GAIN,&lnagain,1);

            // try to find the corresponding audio device, by comparing the USB path to USB paths found under /proc/asound
            char audiopath[16]="(not found)";
            int usb1=-1,usb2=-1;
            sscanf(phdi->path,"%i:%i",&usb1,&usb2);

            int i;
            for (i=0;i<16;i++) {
                char s[32];        
                sprintf(s,"/proc/asound/card%i/usbbus",i);
                FILE *f;
                f=fopen(s,"r");
                if (f) {
                    fgets(s,32,f);
                    int u1=0,u2=0;
                    sscanf(s,"%i/%i",&u1,&u2);
                    fclose(f);
                    if (u1==usb1 && u2==usb2) { sprintf(audiopath,"card%i",i); break; }
                }
            }

            // print our findings
#ifdef FCDPP
            printf(" %-8s   %11.6f MHz   %s    %s\n", version, (*(int *)freq)/1e6, lnagain ? "enabled" : "disabled", audiopath);
#else
            printf(" %-8s   %11.6f MHz   %4g dB     %s\n", version, (*(int *)freq)/1e6, lnagainvalues[lnagain], audiopath);
#endif
        }
        idx++;
        phdi = phdi->next;
    }
    hid_free_enumeration(phdi);
}