Last active
November 25, 2018 18:52
-
-
Save themadsens/2923f43f7845923e53a818e410a98bdf to your computer and use it in GitHub Desktop.
Create udev rule file from avrdude.conf
This file contains 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 | |
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