From 3898b34d35467d0b8b19c25d5688e29856adfa2d Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Mon, 30 Sep 2024 10:42:12 -0700 Subject: [PATCH] Added a script to capture device information for PnP support --- .gitignore | 1 + overlay/opt/emcomm-tools/bin/et-device-info | 55 +++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .gitignore create mode 100755 overlay/opt/emcomm-tools/bin/et-device-info diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/overlay/opt/emcomm-tools/bin/et-device-info b/overlay/opt/emcomm-tools/bin/et-device-info new file mode 100755 index 0000000..e09010f --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-device-info @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 30 September 2024 +# Purpose : Capture device information to aid in plug-and-play development. + +echo +read -p "1. Enter a short name for the radio with no spaces (i.e. ic-7100): " input + +RADIO=$(echo $input | sed 's/[ ]*//g') +DATE_NOW=$(date +%Y%m%d-%H%M%S) +OUT_DIR_BASE="${RADIO}-${DATE_NOW}" +[ ! -e $OUT_DIR_BASE ] && mkdir $OUT_DIR_BASE + +echo +read -p "2. Unplug the USB radio/interface from your computer. Press [enter] when done." + +# Capture devices by ID with radio unplugged +find /dev | grep by-id > "${OUT_DIR_BASE}/dev-by-id.before" + + +echo +read -p "3. Connect the USB radio/interface to your computer. Press [enter] when done." input + +# Capture devices by ID with radio plugged in +find /dev | grep by-id > "${OUT_DIR_BASE}/dev-by-id.after" + +diff "${OUT_DIR_BASE}/dev-by-id.before" "${OUT_DIR_BASE}/dev-by-id.after" > "${OUT_DIR_BASE}/dev-by-id.diff" +echo -e "\n4. Found the following new devices:\n" +cat "${OUT_DIR_BASE}/dev-by-id.diff" | grep ">" | sed 's/> //g' | sort | while read device +do + # skip directories + if [ ! -d $device ]; then + # Grab the short device name" + SHORT_DEV_NAME=$(udevadm info $device | grep DEVNAME | cut -d"=" -f2) + SHORT_DEV_FILE=$(echo $SHORT_DEV_NAME | sed 's|/|-|g') + echo -e "${SHORT_DEV_NAME} = $device\n" + + OUT_FILE="${OUT_DIR_BASE}/udevadm-info${SHORT_DEV_FILE}" + udevadm info $SHORT_DEV_NAME > ${OUT_FILE} + udevadm info --attribute-walk --name $SHORT_DEV_NAME >> ${OUT_FILE} + + sleep 1 + fi +done + +echo -e "\n4. Created a directory called '${OUT_DIR_BASE}' to capture the device info for ${RADIO}" +find ${OUT_DIR_BASE} + +TARBALL="$OUT_DIR_BASE.tar.gz" +echo -e "\n5. Packaging up device information" +tar -czf ${TARBALL} ${OUT_DIR_BASE} + +echo "There should be a file called '${TARBALL}' in this directory. Please send it to Gaston." +echo "Thank you for the support!"