Commit 8b4ec403 authored by Alejandro Lopez Gestoso's avatar Alejandro Lopez Gestoso
Browse files

Moved ftdi scripts to comm package

parent 1882c024
#!/bin/sh
echo "--- unbind_ftdi_udev.sh ---"
# VENDOR=${1:-0403}
# PRODUCT=${2:-6001}
# SERIAL=${3:-A600eB1Y}
# FILE=${4:-99-ftdi.rules}
VENDOR="0403"
PRODUCT="6001"
SERIAL="A600eB1Y"
FILE="99-ftdi-unbind-by-serial.rules"
# SERIAL DABO: A600eB1Y
# SERIAL TIBI: A600eByq
# SERIAL TEO: A900WSG1
usage() {
echo "Usage: $0 [-v <vendor>] [-p <product>] [-s <serial>] [-f <file> ]"
echo " -v specify vendor id. Default 0403"
echo " -p specify product id. Default 6001"
echo " -s specify serial number. Default A600eB1Y"
echo " -f specify udev file. Default 99-ftdi-unbind-by-serial.rules"
exit 1
}
while getopts ":hv:p:s:f:" arg; do
case $arg in
v) VENDOR=$OPTARG;;
p) PRODUCT=$OPTARG;;
s) SERIAL=$OPTARG;;
f) FILE=$OPTARG;;
h) usage;;
*) usage;;
esac
done
shift $((OPTIND-1))
FILE=/etc/udev/rules.d/$FILE
FILE=/etc/udev/rules.d/$FILE
echo " Add udev rule so VENDOR:PRODUCT:SERIAL=${VENDOR}:${PRODUCT}:${SERIAL} devices do not load ftdi_sio driver."
echo " Adding new lines to udev rule file: ${FILE}"
LINE0="#The following 2 lines make VENDOR:PRODUCT:SERIAL=${VENDOR}:${PRODUCT}:${SERIAL} devices not load ftdi_sio driver"
LINE1="ATTRS{idVendor}==\"${VENDOR}\", ATTRS{idProduct}==\"${PRODUCT}\", ATTRS{serial}==\"${SERIAL}\", MODE:=\"0666\""
LINE2="ATTRS{idVendor}==\"${VENDOR}\", ATTRS{idProduct}==\"${PRODUCT}\", ATTRS{serial}==\"${SERIAL}\", RUN+=\"/bin/sh -c 'echo \$kernel > /sys/bus/usb/drivers/ftdi_sio/unbind'\""
sudo touch $FILE
grep -qF -- "$LINE0" "$FILE" || echo "$LINE0" | sudo tee -a "$FILE" > /dev/null
grep -qF -- "$LINE1" "$FILE" || echo "$LINE1" | sudo tee -a "$FILE" > /dev/null
grep -qF -- "$LINE2" "$FILE" || echo "$LINE2" | sudo tee -a "$FILE" > /dev/null
sudo service udev restart
echo " Need to unplug-plug devices for changes to take effect"
\ No newline at end of file
#!/bin/sh
# SERIAL=${3:-A600eB1Y}
# FILE=${4:-99-ftdi.rules}
SERIAL="A600eB1Y"
FILE="99-ftdi.rules"
# SERIAL DABO: A600eB1Y
# SERIAL TIBI: A600eByq
# SERIAL TEO: A900WSG1
usage() {
echo "Usage: $0 [-v <vendor>] [-p <product>] [-s <serial>] [-f <file> ]"
echo " -s specify serial number. Default A600eB1Y"
echo " -f specify udev file. Default 99-ftdi.rules"
exit 1
}
while getopts ":hv:p:s:f:" arg; do
case $arg in
s) SERIAL=$OPTARG;;
f) FILE=$OPTARG;;
h) usage;;
*) usage;;
esac
done
shift $((OPTIND-1))
FILE=/etc/udev/rules.d/$FILE
echo "Undo addition of udev rule so VENDOR:PRODUCT:SERIAL=${VENDOR}:${PRODUCT}:${SERIAL} devices do not load ftdi_sio driver."
echo "Removing all lines containing SERIAL=${SERIAL} from file: ${FILE}"
LINE0=${SERIAL}
sudo sed -i "/${LINE0}/d" $FILE
sed -i -E "/idVendor.*$VENDOR.*idProduct.*$PRODUCT.*serial.*$SERIAL.*MODE.*0666\"/d" $FILE
sed -i -E "/idVendor.*$VENDOR.*idProduct.*$PRODUCT.*serial.*$SERIAL.*RUN.*ftdi_sio\/unbind/d" $FILE
sudo service udev restart
echo "Need to unplug-plug devices for changes to take effect"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment