@@ -80,6 +80,7 @@ void sleep_ms(int milliseconds)
8080#define POWER_ON 1
8181#define POWER_CYCLE 2
8282#define POWER_TOGGLE 3
83+ #define POWER_FLASH 4
8384
8485#define MAX_HUB_CHAIN 8 /* Per USB 3.0 spec max hub chain is 7 */
8586
@@ -269,13 +270,13 @@ static int print_usage(void)
269270 "Without options, show status for all smart hubs.\n"
270271 "\n"
271272 "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"
273274 "--ports, -p - ports to operate on [all hub ports].\n"
274275 "--location, -l - limit hub by location [all smart hubs].\n"
275276 "--level -L - limit hub by location level (e.g. a-b.c is level 3).\n"
276277 "--vendor, -n - limit hub by vendor id [%s] (partial ok).\n"
277278 "--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"
279280 "--repeat, -r - repeat power off count [%d] (some devices need it to turn off).\n"
280281 "--exact, -e - exact location (no USB3 duality handling).\n"
281282 "--force, -f - force operation even on unsupported hubs.\n"
@@ -1112,6 +1113,9 @@ int main(int argc, char *argv[])
11121113 if (!strcasecmp (optarg , "toggle" ) || !strcasecmp (optarg , "3" )) {
11131114 opt_action = POWER_TOGGLE ;
11141115 }
1116+ if (!strcasecmp (optarg , "flash" ) || !strcasecmp (optarg , "4" )) {
1117+ opt_action = POWER_FLASH ;
1118+ }
11151119 break ;
11161120 case 'd' :
11171121 opt_delay = atof (optarg );
@@ -1227,6 +1231,9 @@ int main(int argc, char *argv[])
12271231 /* will operate on these ports */
12281232 int ports = ((1 << hubs [i ].nports ) - 1 ) & opt_ports ;
12291233 int should_be_on = k ;
1234+ if (opt_action == POWER_FLASH ) {
1235+ k = !k ;
1236+ }
12301237
12311238 int port ;
12321239 for (port = 1 ; port <= hubs [i ].nports ; port ++ ) {
@@ -1266,7 +1273,7 @@ int main(int argc, char *argv[])
12661273 }
12671274 libusb_close (devh );
12681275 }
1269- if (k == 0 && opt_action == POWER_CYCLE )
1276+ if (k == 0 && ( opt_action == POWER_CYCLE || opt_action == POWER_FLASH ) )
12701277 sleep_ms ((int )(opt_delay * 1000 ));
12711278 }
12721279 rc = 0 ;
0 commit comments