42
42
static void usage()
44
fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev>\n", progname);
45
fprintf(stderr, "\tOptions: {-n|-r kind}\n");
44
fprintf(stderr, "Usage: %s [options] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev> [operation...]\n", progname);
45
fprintf(stderr, "\tOptions:\n");
46
fprintf(stderr, "\t\t[-v] # Increase verbosity\n");
47
fprintf(stderr, "\t\t[-d mask] # Debug mask (0xFF for everything)\n");
48
fprintf(stderr, "\tOperations:\n");
46
49
fprintf(stderr, "\t\t[-n] # Renumerate device\n");
47
50
fprintf(stderr, "\t\t[-r kind] # Reset: kind = {half|full}\n");
48
51
fprintf(stderr, "\t\t[-p port] # TwinStar: USB port number [0, 1]\n");
49
52
fprintf(stderr, "\t\t[-w (0|1)] # TwinStar: Watchdog off or on guard\n");
50
fprintf(stderr, "\t\t[-v] # Increase verbosity\n");
51
fprintf(stderr, "\t\t[-d mask] # Debug mask (0xFF for everything)\n");
53
fprintf(stderr, "\t\t[-Q] # Query device properties\n");
82
84
struct capabilities capabilities;
83
85
struct extrainfo extrainfo;
85
show_astribank_info(astribank);
86
87
ret = mpp_caps_get(astribank, &eeprom_table, &capabilities, NULL);
200
207
if((astribank = mpp_init(devpath)) == NULL) {
201
208
ERR("Failed initializing MPP\n");
202
209
#ifdef SUPPORT_OLD_RESET
203
INFO("opt_reset = %s\n", opt_reset);
210
DBG("opt_reset = %s\n", opt_reset);
205
INFO("Trying old reset method\n");
212
DBG("Trying old reset method\n");
206
213
if ((ret = old_reset(devpath)) != 0) {
207
214
ERR("Old reset method failed as well: %d\n", ret);
214
show_hardware(astribank);
222
* First process reset options. We want to be able
223
* to reset minimal USB firmwares even if they don't
224
* implement the full MPP protocol (e.g: EEPROM_BURN)
229
if((full_reset = reset_kind(opt_reset)) < 0) {
230
ERR("Bad reset kind '%s'\n", opt_reset);
233
DBG("Reseting (%s)\n", opt_reset);
216
234
if((ret = mpp_reset(astribank, full_reset)) < 0) {
217
235
ERR("%s Reseting astribank failed: %d\n",
218
236
(full_reset) ? "Full" : "Half", ret);
240
show_astribank_info(astribank);
242
show_hardware(astribank);
220
243
} else if(opt_renumerate) {
221
245
if((ret = mpp_renumerate(astribank)) < 0) {
222
246
ERR("Renumerating astribank failed: %d\n", ret);
224
248
} else if(opt_watchdog) {
225
249
int watchdogstate = strtoul(opt_watchdog, NULL, 0);
227
INFO("TWINSTAR: Setting watchdog %s-guard\n",
251
DBG("TWINSTAR: Setting watchdog %s-guard\n",
228
252
(watchdogstate) ? "on" : "off");
229
253
if((ret = mpp_tws_setwatchdog(astribank, watchdogstate)) < 0) {
230
254
ERR("Failed to set watchdog to %d\n", watchdogstate);
233
257
} else if(opt_port) {
234
258
int new_portnum = strtoul(opt_port, NULL, 0);
259
int tws_portnum = mpp_tws_portnum(astribank);
235
260
char *msg = (new_portnum == tws_portnum)
236
261
? " Same same, never mind..."
239
INFO("TWINSTAR: Setting portnum to %d.%s\n", new_portnum, msg);
264
DBG("TWINSTAR: Setting portnum to %d.%s\n", new_portnum, msg);
240
265
if((ret = mpp_tws_setportnum(astribank, new_portnum)) < 0) {
241
266
ERR("Failed to set USB portnum to %d\n", new_portnum);
245
271
mpp_exit(astribank);