Dongle programming interface

I’ve been receiving a number of questions about the programming interface for the FCD.

Although the quadrature I/Q stream is over a standard USB stereo soundcard interface, in order to change the centre frequency there is an additional programming interface that uses the USB HID standard interface. Here’s an example to set the centre frequency of the dongle give the frequency in kHz:

static unsigned char HIDSetFreq(HANDLE hWrite,HANDLE hRead,int nFreq)
{
 DWORD dwBytesWritten=0;
 DWORD dwBytesRead=0;
 unsigned char au8BufOut[65]; // endpoint size + 1
 unsigned char au8BufIn[65]; // endpoint size + 1

 au8BufOut[0]=0; // First byte is report ID. Ignored by HID Class
   // firmware as only config'd for one report
 au8BufOut[1]=100; // Command to Set Frequency on dongle
 au8BufOut[2]=(unsigned char)nFreq;
 au8BufOut[3]=(unsigned char)(nFreq>>8);
 au8BufOut[4]=(unsigned char)(nFreq>>16);
 WriteFile(hWrite,au8BufOut,65,&dwBytesWritten,0);
 ReadFile(hRead,au8BufIn,65,&dwBytesRead,0);
 return au8BufIn[2]; // au8BufIn[2]==1 if success.
}

The HID command output to the dongle is 64 bytes, as is the HID response input back into the host. You also need to prepend the buffers with one byte each for the HID report ID that’s not actually used, so 65 bytes total each.

In the output command buffer, after the unused HID report byte, the FCD command byte follows. The “SetFreq” command is 100. Following this is the 24 bit little endian integer frequency specified in kHz.

In response, the 65 bytes buffer includes a copy of the command (100 in this case) at index 1 and a boolean success/fail 1/0 response at index 2.

So far so good. But you need to open up input and output HID handles first to use this function! This is rather more fiddly, certainly in the Windows world. I have some example code here that demonstrates this: http://www.g6lvb.com/Fungle/FCHid002.zip

Howard

This entry was posted in Uncategorized. Bookmark the permalink.

17 Responses to Dongle programming interface

  1. Mike says:

    Looks great.
    For Mac OSX there is PyHID, which is a C++ library and also a Python class for the HID manager.

  2. Ken Nelson says:

    Will the funcube work the HF band also. .

  3. Dennis says:

    I’m having trouble finding how to set the FCD centre frequency.
    It states in the Spectravue Configuration Guide:
    “It is suggested that the program FCHid be running.
    Enter a frequency of 100MHz and click on the “Defaults” button.
    FCHid content should appear as shown below. (FCD F/W 18c)”
    I have no idea what this means or where to find this program. Surely it should be a simple task to enter this frequency.
    Any suggestions?
    Kind regards,
    Den

    • admin says:

      Hello Den.

      Assuing that you have the FCHid program up and running, all you need to do is enter the frequency in kHz and press the Set Frequency button. So, for 100MHz you’d enter 100000 and press the Set Frequency button. That’s all there is to it.

      The Defaults button is used to set some gain and filter settings if you are on the early 18b firmware. It does not set the frequency. Later firmware versions (including 18c) have the appropriate default settings set so there should be no need to use the Defaults button unless you want to go back to some sensible values after soe tinkering.

      Howard

  4. Rob says:

    Firmware and FCHid can be found here Dennis.
    https://www.funcubedongle.com/?page_id=313
    Rob