Skip to content

Instantly share code, notes, and snippets.

@galister
Last active October 1, 2025 14:50
Show Gist options
  • Select an option

  • Save galister/2fbd23cfaff8ba4839efa13184e4e197 to your computer and use it in GitHub Desktop.

Select an option

Save galister/2fbd23cfaff8ba4839efa13184e4e197 to your computer and use it in GitHub Desktop.
Watchman Dongle USB-over-IP setup
#!/usr/bin/env bash
# hostname/ip of your dongle host
DONGLE_HOST=pi
sudo modprobe vhci-hcd
if [ "$1" == "detach" ]; then
for i in {0..8}; do
sudo usbip detach --port $i
done
else
for i in {0..8}; do
sudo usbip detach --port $i
done
# you can add this for convenience if you have your SSH key installed
# ssh root@$DONGLE_HOST /root/usbip-bind rebind
sudo usbip list -p -r $DONGLE_HOST | grep -Po '[0-9]-[0-9.]+$' | xargs -I % sudo usbip attach -r $DONGLE_HOST -b %
fi
#!/usr/bin/env python3
import sys
import re
import subprocess
# 2101 - single vive dongle
# 2102 - tundra SWx dongle
# TODO: aftermarket dongles, plug in to main pc and check with lsusb -vt
wanted_products = [ "28de:2101", "28de:2102" ]
device_re = re.compile(r'^busid=([0-9-.]+)#usbid=([0-9a-fA-F:]+)#$')
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] == "rebind":
verbs = [ "unbind", "bind" ]
else:
verbs = [ sys.argv[1] ]
else:
verbs = [ "bind" ]
outp = subprocess.check_output(["usbip", "list", "-pl"]).decode().splitlines()
i = 0
while i < len(outp):
line = outp[i]
i += 1
m = device_re.search(line)
if m:
product = m.group(2)
if product not in wanted_products:
print("Not wanted: "+product)
continue
addr = m.group(1)
for verb in verbs:
try:
args = ["usbip", verb, "-b", addr]
print(" ".join(args))
subprocess.check_call(args)
except:
pass
else:
print("No match: "+line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment