HACKING.md 1.8 KB

Sniffing the USB protocol

When adding support for a new mouse, or when debugging issues, it can be usefull to capture the original protocol with Razer official configuration software.

Requirements

No matter the method, the basic requirements are:

  • a Windows machine with Razer Synapse installed (note: you'll need to register)
  • another mouse: to reduce protocol chatter by avoiding moving the mouse spied on

Using USBPcap or Wireshark

You can sniff the USB protocol on Windows using USBPcap. Take a look at the illustrated tour for more information. Altenatively you can use Wireshark.

Using a guest VirtualBox VM and usbmon or QEMU and usbmon.

  1. install Windows: you can get an evaluation copy (usable for 90 days) of Windows 7 Enterprise (note: you'll need to register)

  2. find your mouse USB bus and device numbers:

> lsusb | grep '\<ID 1532:'
Bus 005 Device 010: ID 1532:0040 Razer USA, Ltd
> bus=5 dev=10
  1. configure VM access to the host USB: see the relevant USB support section in the VirtualBox manual

  2. load the usbmon module:

> sudo modprobe usbmon
  1. monitor the bus, filtering for device specific messages:
> sudo cat /sys/kernel/debug/usb/usbmon/${bus}u | awk "{ if (\$4 ~ /:0*${bus}:0*${dev}:[0-9]+$/) print \$0 }"

See the usbmon documentation for the details of the output format.

Alternatively to VirtualBox VM, you may use QEMU.