Ticket #2799: guid.diff
File guid.diff, 2.4 KB (added by , 17 years ago) |
---|
-
/mythtv/contrib/channel_changers/
old new 25 25 #include <stdio.h> 26 26 #include <errno.h> 27 27 #include <stdlib.h> 28 #include <limits.h> //for LLONG_MAX 29 #include <getopt.h> 28 30 #include <unistd.h> // for usleep 29 31 30 32 // Motorola DCT-6200 IDs … … 74 76 STARTING_NODE); 75 77 fprintf(stderr, "-p PORT port/adapter to use (default:%i)\n", 76 78 STARTING_PORT); 79 fprintf(stderr, "-g GUID GUID to use, -n switch, if present, will be ignored.\n"); 77 80 exit(1); 78 81 } 79 82 … … 84 87 int i; 85 88 int verbose = 0; 86 89 int single_packet = 0; 90 int bGUID=0; 91 octlet_t cli_GUID=0LL; 92 octlet_t node_GUID=0LL; 87 93 quadlet_t cmd[2]; 88 94 int chn = 550; 89 95 … … 97 103 usage(); 98 104 99 105 opterr = 0; 100 while ((c = getopt(argc, argv, "vs n:p:")) != -1)106 while ((c = getopt(argc, argv, "vsg:n:p:")) != -1) 101 107 { 102 108 switch (c) { 103 109 case 'v': … … 109 115 case 'n': 110 116 starting_node = atoi(optarg); 111 117 break; 118 case 'g': 119 bGUID=1; 120 starting_node=0; 121 cli_GUID = (octlet_t)strtoll(optarg, (char **)NULL, 16); 122 break; 112 123 case 'p': 113 124 starting_port = atoi(optarg); 114 125 break; … … 151 162 printf("starting with node: %d\n", starting_node); 152 163 153 164 int nc = raw1394_get_nodecount(handle); 165 if (bGUID!=0) { 166 if (cli_GUID==0LL || cli_GUID==LLONG_MAX || cli_GUID==LLONG_MIN) { 167 fprintf(stderr, "error parsing GUID command line parameter\n"); 168 exit(1); 169 } 170 } 154 171 for (i=starting_node; i < nc; ++i) { 172 if (bGUID!=0) { 173 node_GUID=rom1394_get_guid(handle, i); 174 #ifdef DEBUG 175 printf("node=%d, node_GUID=%LX, cli_GUID=%LX\n", i, node_GUID, cli_GUID); 176 #endif 177 if (cli_GUID!=node_GUID) { 178 continue; 179 } 180 } 181 155 182 if (rom1394_get_directory(handle, i, &dir) < 0) { 156 183 fprintf(stderr,"error reading config rom directory for node %d\n", i); 157 184 raw1394_destroy_handle(handle); … … 239 266 240 267 avc1394_transaction_block(handle, device, cmd, 3, RETRY_COUNT_FAST); 241 268 } 269 270 /* 271 * Compile: 272 * -std=gnu99 flag required for LLONG_MAX and LLONG_MIN inclusion 273 * gcc -std=gnu99 -o 6200chguid 6200chguid.c -lavc1394 -lrom1394 -lraw1394 274 * 275 */