Last active
January 4, 2023 03:44
-
-
Save nall/6a9f260455e3996647d89bfbd7915a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# vim: ft=sh sw=4 ts=4 et | |
# Overview | |
# -------- | |
# This script queries connected USB devices looking for the Elecraft K4's "Dual RS232" device. | |
# If such a device is found and the serial devices exist, they are listed as K4 candidates. If | |
# no devices are found, an error is printed. | |
# | |
# Instructions | |
# ------------ | |
# 1. Download this file to your Mac (put it in the Downloads folder) | |
# 2. Open Terminal.app | |
# 3. sh $HOME/Downloads/find_elecraft_usb_devices.sh | |
BASE_ADDR=`ioreg -p IOUSB | grep 'Dual RS232' | sed -e 's/.*Dual RS232@//' | awk '{print $1}'` | |
found=0 | |
for device_id in $BASE_ADDR $(expr $BASE_ADDR + 1) | |
do | |
candidate="/dev/cu.usbserial-$device_id" | |
if [ -e $candidate ]; then | |
echo "Potential K4 USB device: $candidate" | |
let found=$found+1 | |
fi | |
done | |
if [ "$found" -eq 0 ]; then | |
echo "ERROR: Unable to find any potential K4 USB devices. Is the K4 connected?" | |
exit 1 | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment