79 points · by zdw · 3y ago · 59 comments
- Most USB hub chips can be strapped/hard wired configured, or controllable by i2c already directly. Funnily enough this chip isn't, but is extremely cheap (less than 24 cents!).
- The "port enable" feature on this design only controls VBUS (power pin of each connector), not the hub itself, so on a self-powered device it may not actually disconnect the device if it doesn't need VBUS to operate.
[1]: https://www.lcsc.com/product-detail/USB-ICs_CoreChips-SL2-1A...
I do a lot of firmware development and am constantly having to unplug/replug devices during the process .. for this reason I have an I-Tec 16-port Charging Hub, which has individual switches for each port - and this works fine, as long as I get the druthers to launch out of my chair and turn things off and on again... however being able to do all of this remotely, with software, would mean I could a) automate the hell out of a lot of things that requires monkey-tapping, and b) put the whole mess in a closet where it belongs, away from my coffee cup.
So I'm quite eager to see this project proceed - especially if there is a way the port capacities can be expanded (16-port would be ideal) .. so please consider officially reporting any issues in the design that you see!
It works on a pretty limited set of hubs, because most cheap out on including the switches.
https://github.com/mvp/uhubctl
Of the USB 3 options on the list, several were EOL or impossible to find, and when I ordered one each of the remainder, there was only one I could get working, and it wasn't reliable about being able to reset a device that had frozen to the point where Linux no longer had sysfs entries for it.
We ended up instead using a hub with an internal jumper to disable bus power, and then putting the self power line through a separately-controllable relay.
I wrote simple scripts to switch my monitor inputs with keyboard shortcuts (even simpler with Lunar, amazing new Mac app — https://lunar.fyi), which saved me from having to press annoying input-source buttons.
But I couldn't for the life of me find a simple, suitable software controllable KVM switch. That still requires the hardware button to be controlled, so frustrating.
https://www.aliexpress.com/item/1005005149590635.html
is probably what you need. It has a USB port linked to a USB serial internally that you send strings to switch. It was designed to be used with the Pi KVM/BLIKVM KVM over IP solution but works for other things as well.
I had a KVM switch with a wired button (place KVM out of the way, put small button on your desk). The button was connected via a 3.5mm "audio" jack. I never measured the interface, but I bet it just connected two rings of the jack.
Using a switch like that, you can build your own control for it without opening the KVM. Either with an ESP for wifi control (MQTT would be my choice) or a smaller board for USB/serial control (Cortex-M dev board). Short the proper rings via an optocoupler controlled by the MCU and it will behave as if you pressed the button.
Dell monitors all support DDC, I'm not sure if KVM switching can be controlled over DDC but it's likely.
Somewhat unrelated, but some of the Dell monitors also have USB-C support, where a single USB-C cable connects to your laptop and: charges it (Power Delivery from the monitor), hooks up the display (DP alt mode), and connects to the USB hub on the monitor. So if you use a wireless kb/mouse with receivers plugged into the monitor, you'll have literally just 2 cables on your desk - a power cable for your monitor, and a USB-C cable between the monitor and laptop.
- the laptop to the side is awkwardly positioned for zoom chat, so you probably want a webcam as well
- audio is a problem. If you use bluetooth and swap lots of things over then you keep needing to re-pair which is a pain. The model I have (Dell UltraSharp 27 USB-C Hub Monitor - U2722DE) has an audio jack but this is for connecting to soundbars not headphones, and the soundbars Dell offered that are compatible with that monitor don't support headphones. So, I ended up using a USB headset. You can use bluetooth with a usb soundcard dongle to avoid swapping, but bidirectional sound is an issue with that so you'll want to use the mic on the webcam (if you got one like that)
My keyboard/trackball are wired to the monitor, there doesn't seem to be much point to having wireless to attach something that's only a foot away anyway.
Either way, it's one connection to the laptop, but 4-5 other things need to connect to the monitor too. Still pretty good and not too much clutter tho
They do. Here's my shell function that helps me switch between DisplayPort-1 + USB uplink cable to the host AND USB-C cable with DisplayPort Alt Mode+Charging+uplink to display's USB hub.
# x0f: DisplayPort-1
# x1b: USB-C
DDC_SOURCES=("x0f" "x1b")
switchkvm() {
local vcp_input_src="x60"
local current next src
current=$(ddcutil -t getvcp ${vcp_input_src} | awk '{ print $4 }')
for src in "${DDC_SOURCES[@]}"; do
if [[ ${src} != "${current}" ]]; then
next=${src}
fi
done
if [[ -z ${next} ]]; then
echo "No eligible alternate input in \$DDC_SOURCES" >&2
echo "\$DDC_SOURCES=(${DDC_SOURCES[*]}); current=${current}"
return 1
fi
ddcutil setvcp "${vcp_input_src}" "${next}"
}I have a desktop Linux PC but I often need to switch to my MacBook. If I plug the MacBook in, all my peripherals automatically switch to it. If I unplug, everything switch he's back to the Linux PC.
You can definitely use DDC to switch inputs, and the KVM is linked to the selected input. On MacOS I use Better Display which lets me switch inputs from a menu bar app. On linux there is ddcui (which is more like a proof of concept than a polished app, but it works). It's rare that I need to use this though since the auto-switching is usually all I need.
Dough (formerly Eve) Spectrum monitors have this feature. They are also great all-round monitors.
Like sibling comment, I have a 4-port USB switch with a remote that connects via micro-usb, it was quite easy to hack a custom remote that I keep next to my keyboard.
Not opensource hardware, but available immediately for order and ESPHome/Tasmota can be used as a firmwre.
So many issues with USB during development can be resolved if you can just get the device reset during the dev process. Being able to hard-reset a device during compile/debug phases is going to save me huge amounts of time and effort ...
A DIY hub that uses a chip with PPPS support can be found here for example: https://oshwlab.com/iamseer/ch335-hub
It was very expensive but works reliable. You can use API to control it.
Although it would be more convenient to integrate it directly on board.