Can I plug/unplug a USB device without a physical change in windows 10? - windows-10

A method to Connect / Disconnect a USB device "softly".
Hey, Assume I have a USB device connected to my PC, I want to enable/disable the port it is connected via computer so that I don't have to unplug/plug my device each time.
P.S : Device is a Microcontroller Board ( powered by USB port ) , so I don't want it to be active all the time. I want to deactivate it when appyling changes to code etc. and then activate that port so I can load my code into it again.
Is there a method to do so ?
Thanks in advance.

Device is a Microcontroller Board ( powered by USB port )
Most USB enabled µC types can "unplug" themself.
The idea is to put the USB data pins (usually called D+ and D-) into "output low" state for about one second at startup. This forces USB to be recognized as "disconnected".
After that is done, re-configure the pins to for their USB function and initialze the USB as usual.
Note that this method is not possible on old style boards that still use USB2UART chips instead of hardware USB inside the µC itself.

Related

Can a USB 3 Host machine be programmed as a USB 3 Peripheral (or a HID keyboard)?

What I want to do:
An AI program on a host machine, reading inputs from a camera sensing the screen of the target machine and outputting controls to the target machine via USB connection--programming the host machine's USB host as a USB peripheral connected to the target machine.
What I want to do step by step: (is it possible to implement the steps below?)
Have a host machine A and a target machine B.
Connect A and B with a USB 3.0 Type-A male-male cable.
The USB connection shows up as an HID keyboard device on B.
Write code to simulate key presses on A that sends to B.
(Eg. calling press('F') on a program running on A would type F to B's input)
It shouldn't require any program installed on B.
What I already searched:
USB 3.0 Host to host connection is possible:
https://superuser.com/questions/795053/how-do-i-connect-two-computers-using-usb-3-0
USB 2.0 Host to host connection is impossible:
https://superuser.com/questions/99274/how-to-connect-two-computers-with-usb
Similar questions asked without the assumption that USB 3.0 Host to Host connection is possible:
https://superuser.com/questions/1128365/simulate-usb-keyboard-from-machine
Setting up a computer to act as an HID device connected to another computer via ps/2,usb or another wired connection
https://superuser.com/questions/507921/computer-to-act-as-keyboard?rq=1
Suggestions in ascending order of feasibility:
USB Gadgets
You are using linux, so the default way would be to create/configure/load a gadget driver. Have a look at this tutorial, though for a raspberry, should work on your PC too. However, I could not find any information regarding the use of USB3 - the tutorial assumes your host is using one of it's OTG ports, which your PC most likely does not have. So whether this works with your USB3.1 Type-A-to-Type-A connection you'll need to test.
USBIP
The idea of sharing USB devices (not just keyboards) is not really new. With USBIP you can "export" any local USB device to the network, and your client will need the client-side USBIP driver to access the keyboard.
Dont bother with USB at all, just use Ethernet
I'd simply write two userland scripts/programs that send/receive+execute the keystrokes. Very easy to implement, you're probably familiar with python anyway.
If you absolutely cant have software installed on the client-PC and your Type-C-to-Type-C connection doesnt support USB Gadgets, there's another way. It basically involves the use of two USB-to-serial adapters (~15$) and a serial cable. While this wont be enumerated as a keyboard, but rather as serial port, it's the lowest-effort solution to transfer data without additional software on the client. Both computers will just do file I/O. If your computers still have COM-ports, you can even omit the serial converters!

Create new ethernet usb network interface on Linux

I'm trying to create a usb based ethernet device on my computer, basically I want to tell my computer (linux based) that one of its usb ports is actually an ethernet port. I have done extensive research and while it's supposed to be possible, I can't find any examples of code / commands to run.
According to wikipedia:
The USB-eth module in Linux makes the computer running it a variation of an Ethernet device that uses USB as the physical medium. It creates a Linux network interface, which can be assigned an IP address and otherwise treated the same as a true Ethernet interface. Any applications that work over real Ethernet interfaces will work over a USB-eth interface without modification, because they can't tell that they aren't using real Ethernet hardware.
So in theory, this should be possible, I just need some help or a gentle nudge in the right direction to get this thing rolling. What I'm NOT trying to do is plug a usb to ethernet dongle/adapter into my computer, I have several of those lying around and that doesn't help me out at all.
this is ethernet-over-usb
https://en.wikipedia.org/wiki/Ethernet_over_USB
without external hardware you can try the CDCether kernel module and ethtool ( then you can only connect to a usb device that operates in usb device mode )
( https://developer.ridgerun.com/wiki/index.php/How_to_use_USB_device_networking , http://tldp.org/HOWTO/Motorola-Surfboard-Modem/usb.html, http://www.linux-usb.org/usbnet/ )
else you need a physical adapter for this. the adapter translates between the protocols and the different hardware interfaces.
in usb protocol can only be one host in a network, therefore you need at least a host-to-host cable ( http://www.linux-usb.org/usbnet/ ) if you want to connect two usb host devices, i.e. two pcs
required kernel module ( driver ) when using a physical adapter is either usbnet ( with its minidrivers ) or usb-eth

Using CC2640 As USB Bluetooth Dongle

I salvaged a CC2640 out of Bluetooth keyboard. I desoldered it in a attempt to reuse it. Can it be transformed to a USB Dongle adapter in any way? I'm doing this for knowledge, not for the outcome (It may be easier or cheaper to buy one, still want to do it)
you have to reprogram the flash (http://www.ti.com/lit/an/spraal3/spraal3.pdf). for this you can use SmartRF Flash Programmer and you need access to the pins of debug port (JTAG) or serial port (UART) and possibly there is a lock (fuse set). the OEMs often set locks to ensure that nobody reads out the code with what they programmed their devices ... if you get access to the flash of the CC2640 you can reuse it. as the CC2640 has no USB port you can only make an USB dongle of it with an external chip i.e. a FTDI chip (connect the serial port of the FTDI with the serial port of the CC2640...)

Can a bluetooth usb dongle be detected when only powered on?

I bought one of those tiny bluetooth USB dongles that you can plug on a PC and make bluetooth communications. I am wondering if I just plug this dongle to a USB power source, like the USB charger that comes with iPad, can the bluetooth dongle power up, and be discovered as a bluetooth device? This sounds reasonable, since the bluetooth dongle should be able to broadcast itself, at least using some low-level protocol, i.e. showing its Mac address.
However, I tried to do the following:
1.Plug the bluetooth dongle on my iPad's usb charger
2.Search bluetooth devices on my laptop
and I could not find it. Is it because the bluetooth dongle needs the PC to initialize it, so that it can be discovered? Or I am not doing it right?
Thanks
It depend on the dongle
Typical PC dongles depends on the host (pc) to initialize and start any bluetooth activity - including scanning etc
It is practically possible to make dongles that can start becoming discoverable without waiting for host initialization. This has to be a custom build

How to send keystrokes from one computer to another by USB?

Is there a way to use one computer to send keystrokes to another by usb ?
What i'm looking to do is to capture the usb signal used by a keyboard (with USBTrace for example) and use it with PC-1 to send it to PC-2.
So that PC-2 reconize it as a regular keyboard input.
Some leads to do this would be very appreciated.
What you essentially need is a USB port on PC-1 that will act as a USB device for PC-2.
That is not possible for the vast majority of PC systems because USB is an asymmetric bus, with a host/device (or master/slave, if you wish) architecture. USB controllers (and their ports) on most PCs can only work in host mode and cannot simulate a device.
That is the reason that you cannot network computers through USB without a special cable with specialised electronics.
The only exception is if you somehow have a PC that supports the USB On-The-Go standard that allows for a USB port to act in both host and device mode. USB-OTG devices do exist, but they are usually embedded devices (smartphones etc). I don't know if there is a way to add a USB-OTG port to a commodity PC.
EDIT:
If you do not need a keyboard before the OS on PC-2 boots, you might be able to use a pair of USB Bluetooth dongles - one on each PC. You'd have to use specialised software on PC-1, but it is definitely possible - I've already seen a possible implementation on Linux, and I am reasonably certain that there must be one for Windows. You will also need Bluetooth HID drivers on PC-2, if they are not already installed.
On a different note, have you considered a purely software/network solution such as TightVNC?
There is a solution:
https://github.com/Flowm/etherkey
This uses a network connection from your computer to the raspi which is connected to a teensy (usb developer board) to send the key strokes.
This solution is not an out-of-the-box product. The required skill is similar to programming some other devices like arduino. But it's a complete and working setup.
The cheapest options are commercial microcontrollers (eg arduino platform, pic, etc) or ready built usb keyboard controllers (eg i-pac, arcade controllers,etc)
SEARCH THIS PROGRAM:
TWedge: Keyboard Wedge Software (RS232, Serial, TCP, Bluetooth)
then, MAKE YOUR OWN CONNECTION CABLE WITH:
(usb <-> rs232) + (NULL MODEM) + (rs232 <-> usb)
Connect 2 computer, write your own program to send signal to your (usb <-> rs232) unit, then you can control another computer under the help of TWedge.
The above mentionned https://github.com/Flowm/etherkey is one way. The keyboard is emulated from an rPi, but the principle can be used from PC to PC (or Mac to Whatever). The core answer to your question is to use an OTG-capable chip, and then you control this chip via a USB-serial adapter.
https://euer.krebsco.de/a-software-kvm-switch.html
uses a very similar method, using an Arduino instead of the Teensy.
The generic answer is: you need an OTG capable, or slave capable device: Arduino, Teensy, Pi 0 (either from Rapberry or Orange brands, both work; only the ZERO models are OTG capable), or, an rPi-A with heavy customisation (since it does not include USB hub, it can theoretically be converted into a slave; never found any public tutorial to do it), or any smartphone (Samsung, Nokia, HTC, Oukitel ... most smartphones are OTG capable). If you go for a Pi or a phone, then, you want to dig around USB Gadget. Cheaper solutions (Arduino/Teensy) need custom firmware.

Resources