Skip to content

Instantly share code, notes, and snippets.

@themadsens
Last active November 25, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themadsens/2923f43f7845923e53a818e410a98bdf to your computer and use it in GitHub Desktop.
Save themadsens/2923f43f7845923e53a818e410a98bdf to your computer and use it in GitHub Desktop.
Create udev rule file from avrdude.conf
#!/bin/bash
for candidate in /usr/local/Cellar/avrdude/*/etc/avrdude.conf /etc/avrdude.conf /usr/local/etc/avrdude.conf ;do
if [[ -f $candidate ]] ;then
AVRCONF=$candidate
fi
done
[[ -f $AVRCONF ]] || exit
gawk '
/^ +usbvid +=/ {
match($3, /0x([[:xdigit:]]+);/, m)
usbvid=m[1]
}
/^ +id +=/ {
match($3, /"([[:alnum:]_-]+)"/, m)
id=m[1]
}
/^ +usbpid +=/ && usbvid && id {
match($3, /0x([[:xdigit:]]+);/, m)
printf("#AVR: %s\nSUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%s\", ATTRS{idProduct}==\"%s\", GROUP=\"dialout\"\n",
id, usbvid, m[1])
}
/^programmer *$/ {
usbvid = 0
id = 0
}
' $AVRCONF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment