@@ -80,6 +80,7 @@ void sleep_ms(int milliseconds)
80
80
#define POWER_ON 1
81
81
#define POWER_CYCLE 2
82
82
#define POWER_TOGGLE 3
83
+ #define POWER_FLASH 4
83
84
84
85
#define MAX_HUB_CHAIN 8 /* Per USB 3.0 spec max hub chain is 7 */
85
86
@@ -269,13 +270,13 @@ static int print_usage(void)
269
270
"Without options, show status for all smart hubs.\n"
270
271
"\n"
271
272
"Options [defaults in brackets]:\n"
272
- "--action, -a - action to off/on/cycle/toggle (0/1/2/3) for affected ports.\n"
273
+ "--action, -a - action to off/on/cycle/toggle/flash (0/1/2/3/4 ) for affected ports.\n"
273
274
"--ports, -p - ports to operate on [all hub ports].\n"
274
275
"--location, -l - limit hub by location [all smart hubs].\n"
275
276
"--level -L - limit hub by location level (e.g. a-b.c is level 3).\n"
276
277
"--vendor, -n - limit hub by vendor id [%s] (partial ok).\n"
277
278
"--search, -s - limit hub by attached device description.\n"
278
- "--delay, -d - delay for cycle action [%g sec].\n"
279
+ "--delay, -d - delay for cycle/flash action [%g sec].\n"
279
280
"--repeat, -r - repeat power off count [%d] (some devices need it to turn off).\n"
280
281
"--exact, -e - exact location (no USB3 duality handling).\n"
281
282
"--force, -f - force operation even on unsupported hubs.\n"
@@ -1112,6 +1113,9 @@ int main(int argc, char *argv[])
1112
1113
if (!strcasecmp (optarg , "toggle" ) || !strcasecmp (optarg , "3" )) {
1113
1114
opt_action = POWER_TOGGLE ;
1114
1115
}
1116
+ if (!strcasecmp (optarg , "flash" ) || !strcasecmp (optarg , "4" )) {
1117
+ opt_action = POWER_FLASH ;
1118
+ }
1115
1119
break ;
1116
1120
case 'd' :
1117
1121
opt_delay = atof (optarg );
@@ -1227,6 +1231,9 @@ int main(int argc, char *argv[])
1227
1231
/* will operate on these ports */
1228
1232
int ports = ((1 << hubs [i ].nports ) - 1 ) & opt_ports ;
1229
1233
int should_be_on = k ;
1234
+ if (opt_action == POWER_FLASH ) {
1235
+ k = !k ;
1236
+ }
1230
1237
1231
1238
int port ;
1232
1239
for (port = 1 ; port <= hubs [i ].nports ; port ++ ) {
@@ -1266,7 +1273,7 @@ int main(int argc, char *argv[])
1266
1273
}
1267
1274
libusb_close (devh );
1268
1275
}
1269
- if (k == 0 && opt_action == POWER_CYCLE )
1276
+ if (k == 0 && ( opt_action == POWER_CYCLE || opt_action == POWER_FLASH ) )
1270
1277
sleep_ms ((int )(opt_delay * 1000 ));
1271
1278
}
1272
1279
rc = 0 ;
0 commit comments