Script to Switch On/Off USB Power

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
robfobx
DD-WRT Novice


Joined: 15 Nov 2020
Posts: 5

PostPosted: Tue Nov 17, 2020 18:46    Post subject: Script to Switch On/Off USB Power Reply with quote
Is there a command line way to enable/disable "Core USB Support" (instead of doing this in the Services' USB menu through the web interface)?

I'd like to switch on and off a USB connected device (which only needs 5V power, not data) with a script runnning on the router. The router is Netgear R6400.
Sponsor
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Wed Nov 18, 2020 6:47    Post subject: Reply with quote
I would experiment with commands below (but not while the router's doing anything important in case it messes things up):

nvram set usb_enable="1"

or

nvram set usb_enable="0"

Rerun init process to apply changes

kill -1 1
robfobx
DD-WRT Novice


Joined: 15 Nov 2020
Posts: 5

PostPosted: Wed Nov 18, 2020 18:51    Post subject: Reply with quote
Thanks for teaching me about init. I can now switch on the USB with:
    nvram set usb_enable=1
    /sbin/init
But, that multiplies my init, hotplug2, start_service_f, and "sh .rc_startup" processes (and multiplies processes called within my startup script). By the way, even "kill -9 1" fails to kill init.

Then, after two toggles of the USB this way, the router crashed, rebooted itself, and worse yet, all nvram was gone (but at least DD-WRT firmware was still present). So, this is not looking good...anybody have a cleaner way or see a mistake I'm making?
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum