NEED TO LOCK IN ID OF ESP32 SO ITS ALWAYS THE SAME PORT


#Get ID
udevadm info -a -n /dev/ttyACM0 | grep serial

EXAMPLE RESPONSE
(radxa) littlesophia@radxa-cubie-a7z:~/serial_audio_catcher$ udevadm info -a -n /dev/ttyACM0 | grep serial ATTRS{product}=="USB JTAG/serial debug unit" ATTRS{serial}=="B4:3A:45:AD:CA:90" ATTRS{serial}=="xhci-hcd.41.auto"

CREATE rules file and add listing
sudo nano /etc/udev/rules.d/99-esp32.rules

add this line
SUBSYSTEM=="tty", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", ATTRS{serial}=="B4:3A:45:AD:CA:90", SYMLINK+="ttyESP32_A"

Now device should be locked at port "/dev/ttyESP32_A"


UNTESTED SHELL SCRIPT TO ACCOMPLISH ABOVE

#!/bin/bash
# Detect ESP32 ACM device and create a persistent udev rule

RULE_FILE="/etc/udev/rules.d/99-esp32.rules"

# Find the first ACM device with Espressif vendor ID
DEV=$(ls /dev/ttyACM* | head -n1)

if [ -z "$DEV" ]; then
  echo "No /dev/ttyACM device found."
  exit 1
fi

# Extract attributes
VENDOR=$(udevadm info -a -n $DEV | grep '{idVendor}' -m1 | awk -F'"' '{print $2}')
PRODUCT=$(udevadm info -a -n $DEV | grep '{idProduct}' -m1 | awk -F'"' '{print $2}')
SERIAL=$(udevadm info -a -n $DEV | grep 'ATTRS{serial}' -m1 | awk -F'"' '{print $2}')

if [ -z "$VENDOR" ] || [ -z "$PRODUCT" ] || [ -z "$SERIAL" ]; then
  echo "Could not extract vendor/product/serial."
  exit 1
fi

echo "Detected ESP32 ACM device:"
echo "  Vendor: $VENDOR"
echo "  Product: $PRODUCT"
echo "  Serial: $SERIAL"

# Write rule
sudo tee $RULE_FILE > /dev/null <<EOF
SUBSYSTEM=="tty", ATTRS{idVendor}=="$VENDOR", ATTRS{idProduct}=="$PRODUCT", ATTRS{serial}=="$SERIAL", SYMLINK+="ttyESP32"
EOF

echo "Rule written to $RULE_FILE"

# Reload udev
sudo udevadm control --reload-rules
sudo udevadm trigger

echo "Now unplug/replug your ESP32. It should appear as /dev/ttyESP32"







parec -d esp32.monitor --file-format=wav --rate=16000 --channels=2 test.wav
parec -d esp32.monitor --file-format=wav > test.wav

