#! /bin/bash
# Copyright (c) 2019 Dan Clemmensen, licensed to you under GPL v3.
# 
# find the correct USB serial port device and run tshark on its usbmon,
# to capture the interactions into cap.pcap.
# this script take one parameter: the device id (as 4 hex digits).
# for example one Prolific device has an ID of 067b
# We use this apporach because the bus and device numbers can
# change when you plug and unplug the USB connector.
#
# must run as root
# 
devstr=$(lsusb -d $1: | tr -d ":")
words=( $devstr )
bus=${words[1]#0}
dev=${words[3]#0}
bus=$(($bus - 0))
echo " Starting capture on USB$bus, device $dev"
tshark - i usbmon$bus -w cap.pcap

