Controlling Griffin's RocketFM under Linux (rocket.c)

I'm using modified version of Michael Rolig’s shark.c (original mirror)application to control my RocketFM from Linux and I released the new tool rocket.c. Hidapi version: rocket_hidapi.c Owners of Griffin's RocketFM now can control this little FM  transmitter under Linux.

Avaliable options:

  • Changing frequency from 88.1 to 107.9 Mhz (but You can use range from 70 to 120 Mhz).
  • Changing transmitting mode (mono/stereo).

So how to get RocketFM working under Ubuntu/Debian?

  1. Plug the RocketFM in the USB port, you’ll get this in dmesg:

    usb 1-6: new full speed USB device using ohci_hcd and address 2
    usbcore: registered new interface driver hiddev
    input: Griffin Technology, Inc. RocketFM as /dev/input/input6
    input,hidraw0: USB HID v1.00 Device [Griffin Technology, Inc. RocketFM] on usb-0000:00:02.0-6
    usbcore: registered new interface driver usbhid
    /build/buildd/linux-2.6.24/drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
    usbcore: registered new interface driver snd-usb-audio

  2. Install libhid-dev from repository's:
    # apt-get install libhid-dev
  3. Download rocket.c
    # wget http://tipok.org.ua/downloads/hardware/griffin/rocket.c
  4. Compile rocket.c using
    # gcc -g -o rocket -lhid rocket.c
  5. Copy rocket to /usr/local/bin
    # cp rocket /usr/local/bin
  6. Check that executable is working:
    # /usr/local/bin/rocket
  7. Turn on your favorite player (xmms, mpd, amarok or gnomad) and let it play to usbaudio device.
  8. Change your station frequency:
    # /usr/local/bin/rocket -freq 102.7
    Or if you want to stream mono sound:
    # /usr/local/bin/rocket -freq 102.7 -m

Inside Device:

  1. UAC3556B (usb audio processor)
  2. 24LC128 (firmware & config for usb chip)
  3. BH1415 (FM TX chip)

TODO:

  1. The hardware design allows us to switch on/off blue light, but I have not been able to realize it, I think that problem is in firmware.

 

The HID libraries have

The HID libraries have changed in the years since this was posted. I updated rocket.c to the current -lhidapi-libusb library that seems to be current on Ubuntu (as of July 2016). If anyone has an old Rocket FM like me, you're welcome to the updated code. I put it at https://dl.dropboxusercontent.com/u/542958/rocket.c .

The HID libraries have

The HID libraries have changed in the years since this was posted. I updated rocket.c to the current -lhidapi-libusb library that seems to be current on Ubuntu (as of July 2016). If anyone has an old Rocket FM like me, you're welcome to the updated code. I put it at https://dl.dropboxusercontent.com/u/542958/rocket.c .

I'll try posting the file below:

/*
* Bill Foote, http://jovial.com
*
* Control a Griffin RocketFM transmitter.
* Adapted from the rocket.c I found at http://tipok.org.ua/node/9
*
*
* compile with:
gcc -g -o rocket rocket.c -lhidapi-libusb
chmod 111 rocket
chown root rocket
chmod u+s rocket
*/

#include
#include
#include

#include

#define ROCKET_VENDID 0x077d /* Griffin's Vendor ID */
#define ROCKET_DEVID 0x0503 /* The RocketFM's Device ID */
#define SEND_PACKET_LENGTH 6 /* size of an instruction packet: rocketfm=6 */

#define DEBUG 1 /* Set true for copious debugging output */

void usage(int argc, const char** argv) {
printf("\n");
printf("%s -freq [-m]\n\tchange state of RocketFM\n\n",
argv[0]);
printf(" commands:\n"
" -freq : set TX frequency, e.g. '-freq 91.5'\n"
" -m : mono (default is stereo)\n");
printf("\n");
printf("%s -enumerate : see USB devices\n", argv[0]);
printf("\n");
exit(1);
}

void enumerate() {
int res;
unsigned char buf[65];
#define MAX_STR 255
wchar_t wstr[MAX_STR];
hid_device *handle;
int i;

// Enumerate and print the HID devices on the system
struct hid_device_info *devs, *cur_dev;

devs = hid_enumerate(0x0, 0x0);
cur_dev = devs;
while (cur_dev) {
printf("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls",
cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number);
printf("\n");
printf(" Manufacturer: %ls\n", cur_dev->manufacturer_string);
printf(" Product: %ls\n", cur_dev->product_string);
printf("\n");
cur_dev = cur_dev->next;
}
hid_free_enumeration(devs);
}

void set(unsigned char send_packet[], size_t send_packet_length) {
int res;
unsigned char buf[65];
#define MAX_STR 255
wchar_t wstr[MAX_STR];
hid_device *handle;
int i;

i = hid_init();
if (i != 0) {
fprintf(stderr, "hid_init failed with return code %d\n", i);
exit(1);
}

// Open the device using the VID, PID,
// and optionally the Serial number.
handle = hid_open(ROCKET_VENDID, ROCKET_DEVID, NULL);

if (!handle) {
printf("\n");
printf("Error: Unable to open rocket device. Null handle.\n");
printf(" Looking for vendor id %04hx, device ID %04hx.\n",
ROCKET_VENDID, ROCKET_DEVID);
printf("\n");
printf("Is suid set?\n\n");
exit(1);
}

// Read the Manufacturer String
res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
printf("Manufacturer String: %ls\n", wstr);

// Read the Product String
res = hid_get_product_string(handle, wstr, MAX_STR);
printf("Product String: %ls\n", wstr);

// Read the Serial Number String
res = hid_get_serial_number_string(handle, wstr, MAX_STR);
printf("Serial Number String: %ls", wstr);
printf("\n");

i = hid_write(handle, send_packet, send_packet_length);
printf("Wrote %d bytes (expecting %d)\n",
(int) i, (int) send_packet_length);

if (i != send_packet_length) {
printf("\n");
printf("Error: Unable to send packet to rocket\n");
printf("\n");
exit(1);
}
}

int main(int argc, const char** argv) {
/* Build the instruction packet to send to the rocket */
unsigned char PACKET[SEND_PACKET_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
unsigned char power = 0x01;
unsigned short encodedFreq;
float freq;
unsigned short stereo;

if (argc == 3 || (argc == 4 && strcmp(argv[3], "-m") == 0)) {
if (strcmp(argv[1], "-freq") == 0) {
/* Setup FM transmitting frequency */
PACKET[0] = 0xC0;
freq = atof(argv[2]);
encodedFreq = freq * 10;

if ( (argc == 4) && strcmp(argv[3], "-m") == 0) {
PACKET[1] = ((encodedFreq >> 8) & 0x07) | 0x40; /* Stereo - OFF */
} else {
PACKET[1] = ((encodedFreq >> 8) & 0x07) | 0x48; /* By default, stereo turned ON */
}

PACKET[2] = encodedFreq & 0xFF;
PACKET[3] = ~(2 * power + 1) & 0x0F;
PACKET[4] = 0x00;
PACKET[5] = 0x00;
if (DEBUG) {
printf("fm freq = %.1f\n", freq);
printf("encoded freq = 0x%x\n", (unsigned int)encodedFreq);
printf("packet = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", PACKET[0], PACKET[1], PACKET[2], PACKET[3], PACKET[4], PACKET[5]);
}
set(PACKET, SEND_PACKET_LENGTH);
} else {
/* Bad command - display the program's usage instructions */
usage(argc, argv);
}
} else if (argc == 2 && strcmp("-enumerate", argv[1]) == 0) {
enumerate();
} else {
usage(argc, argv);
}
exit(0);
}

Thank you very much for that.

Thank you very much for that.

For anyone on Ubuntu 11.04 (not sure about other versions), libhid-dev seems to be missing from the default repos.

I downloaded it from http://forums.linuxmint.com/viewtopic.php?f=109&t=66957&start=0. See the dpkgs in the .tar.gz attached. I also had to install libusb-dev to install those packages.

To get my applications to use the RocketFM device, I also installed Pulse Audio Device Chooser as per this thread http://ubuntuforums.org/showthread.php?t=965860. Works well.

Again, thanks.

Awesome! Just what I have

Awesome! Just what I have been looking for, set this up on my netbook and allows me to DJ at parties to existing radios keeping my system a safe distance from unwanted accidents. Thanks a bunch!

Hi! First of all, thank you!

Hi!

First of all, thank you! I've been looking for a tool like this, and it seems perfect for what I need!

One little problem, though - I'm getting an error

"hid_force_open failed with return code 12"

when I try to change the frequency. Do you have any suggestions on how to fix this?

Try running as root, I got

Try running as root, I got that error the first time I tried the code as a normal user as it didn't have the permissions needed to send raw HID commands.

I set root as owner of the rocket executable and set the sticky bit so it always run with root privileges.

In most cases that meens,

In most cases that meens, your RocketFM is not connected. The application can't find usb hid device with id 077d:0503.

This is awesome! Exactly what

This is awesome! Exactly what I was looking for. Is there anything special I need to do to stop using the RocketFM transmitter? Say I'm using it and I decide I want to use my computer speakers or the line out. Do I just unplug the RocketFM from the USB port? I'm guessing I'd at least need to switch my software music player to a different output device. Thanks!

I have ADS and Elgato device,

I have ADS and Elgato device, very interested in Linux use. Preferibly several devices at one system in parallel. If you desire some OSX info/stuff you can email to me

Good news! Thnx.

Good news! Thnx.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
All comments are PRE-MODERATED! Enter what you see:
Image CAPTCHA
Enter the characters shown in the image.