From owner-freebsd-questions@FreeBSD.ORG Mon Jul 19 00:04:33 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5935D1065678 for ; Mon, 19 Jul 2010 00:04:33 +0000 (UTC) (envelope-from editor@d3photography.com) Received: from qmta12.emeryville.ca.mail.comcast.net (qmta12.emeryville.ca.mail.comcast.net [76.96.27.227]) by mx1.freebsd.org (Postfix) with ESMTP id 433D78FC14 for ; Mon, 19 Jul 2010 00:04:33 +0000 (UTC) Received: from omta10.emeryville.ca.mail.comcast.net ([76.96.30.28]) by qmta12.emeryville.ca.mail.comcast.net with comcast id jbmo1e0050cQ2SLACbrPtE; Sun, 18 Jul 2010 23:51:23 +0000 Received: from [10.0.1.9] ([76.113.183.74]) by omta10.emeryville.ca.mail.comcast.net with comcast id jbrL1e0081cjQTw8WbrM8n; Sun, 18 Jul 2010 23:51:22 +0000 From: Ryan Coleman Date: Sun, 18 Jul 2010 18:51:20 -0500 Message-Id: To: freebsd-questions@freebsd.org Mime-Version: 1.0 (Apple Message framework v1081) X-Mailer: Apple Mail (2.1081) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Radio Shark 2 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2010 00:04:33 -0000 Does anyone have an experience getting the Radio Shark 2 set up? I'm = hoping to use it for radio streaming in my apartment.=20 I've found shark2.c on the net and gcc is failing to compile it; I'm a = PHP developer with a lot of admin time on FreeBSD (8-RELEASE, AMD64 = build presently) but can't get my head around that piece. root@server /usr/local/include]# gcc -g -o shark2 -lhid shark2.c In file included from shark2.c:21: /usr/include/hid.h:6:23: error: hidparser.h: No such file or directory In file included from shark2.c:21: /usr/include/hid.h:69: error: expected specifier-qualifier-list before = 'HIDData' shark2.c: In function 'main': shark2.c:98: warning: incompatible implicit declaration of built-in = function 'exit' shark2.c:102: warning: incompatible implicit declaration of built-in = function 'exit' [[Basically it's not finding hidparser.h - I get that - but it isn't = checking paths to look for it or I just can't seem to set any new search = paths -R]] ::::::: contents of shark2.c ::::::: /* This souce code written my Michael Rolig (email: = michael_rolig@alumni.macalester.edu) * This can be considered to be in the public domain */ /* Modified for Radio Shark2 2007-05-11 * This souce code written my Hisaaki Shibata (email: shibata@luky.org) * This can be considered to be in the public domain */ #define DEBUG false /* Set true for copious debugging output = */ #define SHARK_VENDID 0x077d /* Griffin's Vendor ID */ #define SHARK_DEVID 0x627a /* The radioSHARK's Device ID */ #define READ_EP 0x5 /* libhid read command? */ #define WRITE_EP 0x5 /* libhid write command? */ #define SEND_PACKET_LENGTH 7 /* size of an instruction packet: = shark2=3D7 */ #include #include #include #include void usage(int argc, const char** argv) { printf("%s \n\tchange state of radioSHARK\n\n", = argv[0]); printf("commands:\n" " -fm : set FM frequency, e.g. '-fm = 91.5'\n" " -am : set AM frequency, e.g. '-am = 730'\n" " -blue : turn on blue LED (0-127) '-blue = 127'\n" " -red <0/1> : turn on/off red LED '-red 1'\n"); } int main(int argc, const char** argv) { /* Declare variables used later */ hid_return ret; HIDInterface* hid; HIDInterfaceMatcher matcher =3D { SHARK_VENDID, SHARK_DEVID, = NULL, NULL, 0 }; /* Build the instruction packet to send to the shark */ unsigned char PACKET[SEND_PACKET_LENGTH] =3D { 0x00, 0x00, 0x00, = 0x00, 0x00, 0x00, 0x00 }; unsigned short encodedFreq; float freq; unsigned int intensity; if (argc =3D=3D 3) { if (strcmp(argv[1], "-fm") =3D=3D 0) { /* Tune to an FM frequency */ PACKET[0] =3D 0x81; encodedFreq =3D 0; freq =3D atof(argv[2]); encodedFreq =3D ((freq * 10 * 2) - 3 ); PACKET[1] =3D (encodedFreq >> 8) & 0xFF; PACKET[2] =3D encodedFreq & 0xFF; PACKET[3] =3D 0x33; PACKET[4] =3D 0x04; PACKET[5] =3D 0x00; PACKET[6] =3D 0x28; if (DEBUG) { printf("band =3D fm\n"); printf("freq =3D %.1f\n", freq); printf("encoded freq =3D 0x%x\n", = (unsigned int)encodedFreq); } } else if (strcmp(argv[1], "-am") =3D=3D 0) { /* Tune to an AM frequency */ PACKET[0] =3D 0x81; encodedFreq =3D 0; freq =3D (float)atoi(argv[2]); encodedFreq =3D ((unsigned short)freq * 4 ) + = 16300; PACKET[1] =3D (encodedFreq >> 8) & 0xFF; PACKET[2] =3D encodedFreq & 0xFF; PACKET[3] =3D 0xF3; PACKET[4] =3D 0x36; PACKET[5] =3D 0x00; PACKET[6] =3D 0x24; if (DEBUG) { printf("band =3D am\n"); printf("freq =3D %d\n", (unsigned = int)freq); printf("encoded freq =3D 0x%x\n", = (unsigned int)encodedFreq); } } else if (strcmp(argv[1], "-blue") =3D=3D 0) { /* Adjust the blue LED */ intensity =3D atoi(argv[2]); PACKET[0] =3D 0x83; PACKET[1] =3D (char)intensity; } else if (strcmp(argv[1], "-bblue") =3D=3D 0) { /* Adjust the blue LED's pulsing rate */ intensity =3D atoi(argv[2]); PACKET[0] =3D 0xA1; PACKET[1] =3D (char)intensity; } else if (strcmp(argv[1], "-red") =3D=3D 0) { /* Toggle the red LED */ intensity =3D atoi(argv[2]); if (intensity) PACKET[0] =3D 0x84; else PACKET[0] =3D 0x84; PACKET[1] =3D (char)intensity; } else { /* Bad command - display the program's usage = instructions */ usage(argc, argv); exit(1); } } else { usage(argc, argv); exit(1); } /* Turn libhid debugging on if requested. See include/debug.h = for possible values. */ if (DEBUG) { hid_set_debug(HID_DEBUG_ALL); hid_set_debug_stream(stderr); hid_set_usb_debug(0); /* passed = directly to libusb */ } /* Initialize the hid library */ ret =3D hid_init(); if (ret !=3D HID_RET_SUCCESS) { fprintf(stderr, "hid_init failed with return code %d\n", = ret); return 1; } /* Initialize the hid object */ hid =3D hid_new_HIDInterface(); if (hid =3D=3D 0) { fprintf(stderr, "hid_new_HIDInterface() failed, out of = memory?\n"); return 1; } /* Open the shark */ ret =3D hid_force_open(hid, 2, &matcher, 3); if (ret !=3D HID_RET_SUCCESS) { fprintf(stderr, "hid_force_open failed with return code = %d\n", ret); return 1; } /* Send the instruction packet constructed above to the Shark */ ret =3D hid_interrupt_write(hid, WRITE_EP, (char*)PACKET, = SEND_PACKET_LENGTH, 10000); if (ret !=3D HID_RET_SUCCESS) fprintf(stderr, = "hid_interrupt_write failed with return code %d\n", ret); /* Close the shark */ ret =3D hid_close(hid); if (ret !=3D HID_RET_SUCCESS) { fprintf(stderr, "hid_close failed with return code %d\n", = ret); return 1; } /* Delete the hid object */ hid_delete_HIDInterface(&hid); /* Clean up the hid library */ ret =3D hid_cleanup(); if (ret !=3D HID_RET_SUCCESS) { fprintf(stderr, "hid_cleanup failed with return code = %d\n", ret); return 1; } return 0; }