Power cycle a USB port without rebooting using devcon (or other methods) - usb

There have been similar questions asked here but the solutions all resolved by hardware-specific means. I currently have a Nortek HUSBZB-1 Z-wave/ZigBee adapter plugged into a usb port, but it keeps shutting itself off or disconnecting, requiring a manual unplug, which for a smart-home setup is just... not good.
So far my thought is to cycle the power to the USB port every time it disconnects but even with DevCon it seems to require a whole system reboot, which also defeats the purpose.
Any thoughts as to how to resolve this issue?

Related

Devcon Disable Port vs Digital Relay

I have a device connected to a USB and it periodically sends data to my PC. During the time it is not sending data, the USB cable needs to be removed, else, the device won't work (a fail-safe feature, if the USB cable is connected and attached to pc, the device is in communication mode, if the USB cable is disconnected from pc, it is in stand-alone operation mode).
I was thinking to use the Devcon so I font has to use another hardware, I'll just disable the USB port during an operation mode, then enable it during communication mode. However, the periodic transfer of data can be set to every 5,10,15,30 minutes depending on the settings.
My question is, will it be okay to disable/enable the USB port periodically? Say every 5 minutes? Won't it cause any problem in the long run? Or would it be more efficient for me to use external hardware, a switch to connect/disconnect the USB? Appreciate any advice or thoughts.
If devcon works for you, I don't see why it would cause any problems in the long run. There is no inherent reason why the hardware should get damaged when you run some commands in your software to disable a USB port.
Using external hardware to accomplish the same thing would not be more efficient because you'd have to pay for the hardware and maintain it.

Is it possible to forward host USB devices to EDK2's NT32 emulation platform?

I'm a bit new in UEFI driver development.
I have an UEFI application-bootloader that checks all USB tokens that are currently present in system. It works ok on hardware and Vmware VM, but I would like to test in NT32 emulator from EDK2 to be able to use source-level debugging.
Vmware has required feature for forwarding any removable device from host to VM. I try to do the same for NT32.
Have anyone worked on this issue before? Is it possible to forward USB token? Or maybe this token can be emulated somehow?
Continuous searching haven't gave me much information.
I suspect that it can be done with some tricky settings in package file Nt32Pkg/Nt32Pkg.dsc.
Possibly gEfiNt32PkgTokenSpaceGuid.PcdWinNtPhysicalDisk or gEfiNt32PkgTokenSpaceGuid.PcdWinNtVirtualDisk parameters can be useful, but I'm not sure.
Thanks everyone in advance for your efforts.

How to to run program when USB is inserted?

Hi I have one program that I need to run on my server but the problem is that my server don't have any monitor, keyabord and mouse attach to it so I can confirn when windows 7 ask me to run program so is posible to just plug USB Mass Storage device in a computer and computer would execute this without any qestions?
Perhaps you could look into using autorun or some variant thereof (e.g. a program that would monitor the USB bus for devices, and automatically run some program when it detects that an appropriate storage device has been connect).
Bear in mind that, depending on the physical setup, this could be used as an attack vector.
As Celeriko said, you should try to find a way into connecting to your server remotely. Whether that be through SSH or a tool such as PUTTY (basically SSH right? I'm not sure off top of my head).
Having a usb automatically execute something would be a security risk and I believe it is restricted for that reason.
Best of luck trying to connect remotely into your server, it shouldn't be too difficult.

Is there any way to programmatically tell a USB modem to reset?

I have a USB modem on a server which occasionally needs to be turned off/on again to receive SIM updates and I can't reboot the server as we rely on it to serve various web pages.
Is there any way to do this programmatically? An AT command? Power down the USB port?
I don't always have access to the server so unplugging it and plugging it back in isn't an option unfortunately.
We're coding in C++/CLI if that makes a difference.
It would be great if someone knew of a generic solution to this, but for the Option Globetrotter 452 I'm using, the manufacturer reports that issuing an AT_ORESET command will instruct the device to reboot ...just in case anyone else wants to do this.

Best way to simulate a WAN network

Simplified, I have an application where data is intended to flow over the internet between two servers. Ideally, I'd like to test at what point the software ceases to function. At what lowerbound limit (bandwidth, latency, dropped packets) do things stop working to test the reliability of the software.
What I thought I would do was the following:
Setup up 3 machines (VMware instances)
Install the 2 applications on two of the servers.
Setup up the 3rd server to sit between the two machines by doing some sort of magic with Routing and Remote Access on Windows 2003
Install either Traffic Shaper XP or NetLimiter to limit the bandwidth
Run something like TMnetSim Network Simulator to simulate a bad connection.
Does this sound like a good idea or are there easier/better ways of doing this? I'm not that comfortable on Linux and my team mates are even less so.
WANem does exactly this. We have used it both in a virtual machine on the desktop and on a dedicated old pc and it worked great. It can simulate all sorts of broken connectivity.
FreeBSDs ipfw has provisions to simulate links with a given bandwith, latency or error rate. You could use that FreeBSD machine as your machine "in the middle" in your above setup.
You probably can also run at least one of the endpoints on the same machine if you want to reduce the amount of servers involved.
Someone actually packaged up the settings and whatnot necessary for the FreeBSD solution to this problem and they call it DUMMYNET.
It simulates/enforces queue and bandwidth limitations, delays, packet losses, and multipath effects. It also implements a variant of Weighted Fair Queueing called WF2Q+. It can be used on user's workstations, or on FreeBSD machines acting as routers or bridges.
It can simulate exactly what you want, and its free and will boot onto commodity hardware. They even have a canned install of it that is small enough to put on a floppy disk (!) that you can download at that link.
Maybe it is time to learn a bit about Linux because adding a 50ms delay on every outgoing packet can be done in typing just one line:
tc qdisc add dev eth0 root netem delay 50ms
For more see the Linux Traffic Control HOWTO
We had a similar requirement some ten years ago - I'll see if I can recall how we managed it.
If I remember, we wrote a socket proxy program which was controlled by inetd on a UNIX box. This socket would accept connections from a client and open equivalent sessions through to the server. It would then loop, passing messages in both directions.
The way we achieved WAN characteristics was to introduce random delays (with upper and lower limits) in both the connection establishment and the passing of data once the link was up.
It also had the feature to drop the link occasionally as WAN links were less reliable for us than local traffic.
I recall we had to make it threaded to stop the delays from affecting reverse traffic on the link.
There is a very good (and free) Microsoft solution for that, we use it for quite some time and it works great, it can very easily simulate every thing(packet loss, low bandwidth, disconnection, latency....)
This is the best solution i found for a windows environment
More information and a download link can be found here: MARCO blog post
this product has gone some evolution and it is now integrated into visual studio as part of the automation testing, but i found the use of the standalone(that is quite hard to find, so keep a local copy) to work much better. keep in mind that you need at least two computers(or VMs) since you need to pass through a network adapter in order for the application to work its magic.