1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
#include <libnjb.h>
#include <getopt.h>
int main (int argc, char **argv)
{
njb_t njbs[NJB_MAX_DEVICES];
njb_t *njb;
njbid_t *njbid = NULL;
int i, n, opt, debug;
extern char *optarg;
debug= 0;
while ( (opt= getopt(argc, argv, "D:")) != -1 ) {
switch (opt) {
case 'D':
debug= atoi(optarg);
break;
default:
fprintf(stderr, "usage: handshake [ -D debuglvl ]\n");
return 1;
}
}
if ( debug ) NJB_Set_Debug(debug);
if ( NJB_Discover(njbs, 0, &n) == -1 ) {
njb_error_dump(stderr);
}
if ( n == 0 ) {
fprintf(stderr, "No NJB devices found\n");
return 1;
}
printf("Found %u devices.\n", n);
for (i = 0; i < n; i++) {
njb_keyval_t *key;
njb = &njbs[i];
printf("Device %u: ", i+1);
switch (njb->device_type)
{
case NJB_DEVICE_NJB1:
printf("\n Jukebox type: Nomad Jukebox 1\n");
break;
case NJB_DEVICE_NJB2:
printf("\n Jukebox type: Nomad Jukebox 2\n");
break;
case NJB_DEVICE_NJB3:
printf("\n Jukebox type: Nomad Jukebox 3\n");
break;
case NJB_DEVICE_NJBZEN:
printf("\n Jukebox type: Nomad Jukebox Zen\n");
break;
case NJB_DEVICE_NJBZEN2:
printf("\n Jukebox type: Nomad Jukebox Zen USB 2.0\n");
break;
case NJB_DEVICE_NJBZENNX:
printf("\n Jukebox type: Nomad Jukebox Zen NX\n");
break;
case NJB_DEVICE_NJBZENXTRA:
printf("\n Jukebox type: Nomad Jukebox Zen Xtra\n");
break;
case NJB_DEVICE_DELLDJ:
printf("\n Jukebox type: Dell Digital Jukebox\n");
break;
case NJB_DEVICE_NJBZENTOUCH:
printf("\n Jukebox type: Creative Jukebox Zen Touch\n");
break;
default:
printf("\n Unknown jukebox type.\n");
}
njb= &njbs[i];
if ( NJB_Open(njb) == -1 ) {
njb_error_dump(stderr);
return 1;
}
if ((njbid = NJB_Ping(njb)) == NULL) {
njb_error_dump(stderr);
return 1;
}
printf(" Jukebox SDMI ID: %s\n", njb->idstring);
if (njb->device_type == NJB_DEVICE_NJB1) {
printf(" Firmware: %u.%u\n", njbid->fwMajor,
njbid->fwMinor);
}
else {
printf(" Firmware: %u.%u.%u\n", njbid->fwMajor,
njbid->fwMinor, njbid->fwRel);
printf(" Hardware: %u.%u.%u\n", njbid->hwMajor,
njbid->hwMinor, njbid->hwRel);
}
printf(" Product name: %s\n", njbid->productName);
/* This doesn't exist (apparently) on NJB3 */
if (njb->device_type == NJB_DEVICE_NJB1) {
printf(" Power connected: %s\n", njbid->power ? "yes":"no");
}
key = NJB_Get_Keys(njb);
while (key != NULL) {
printf(" Device key: %s = %08X, %08X\n", key->key, key->value1, key->value2);
key = key->next;
}
free(njbid);
NJB_Close(njb);
}
return 0;
}
|