Commit d0c1f027 authored by Fernando Herrero's avatar Fernando Herrero
Browse files

Add scripts. Add arquitecture to CmakeLists.

parent f3db18ad
......@@ -66,6 +66,14 @@ ELSE(UNIX)
)
ENDIF(UNIX)
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
SET (X86 TRUE)
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
ELSE ()
SET (X86 FALSE)
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
ENDIF()
IF (UNIX)
SET(CPACK_PACKAGE_FILE_NAME "iri-${PACKAGE_NAME}-dev-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
SET(CPACK_PACKAGE_NAME "iri-${PACKAGE_NAME}-dev")
......
......@@ -2,7 +2,21 @@
set -e
case "$1" in
configure)
#echo "I'm a postinst script"
echo "Running postinst script"
# TEST
# echo "pkg name $DPKG_MAINTSCRIPT_PACKAGE"
# echo "pkg files: dpkg -L <pkg_name>"
# dpkg -L $DPKG_MAINTSCRIPT_PACKAGE
# TEST
/usr/share/iri/battery_monitor/scripts/unbind_ftdi_udev.sh -s A600eB1Y
/usr/share/iri/battery_monitor/scripts/unbind_ftdi_udev.sh -s A600eByq
/usr/share/iri/battery_monitor/scripts/unbind_ftdi_udev.sh -s A900WSG1
# SERIAL DABO: A600eB1Y
# SERIAL TIBI: A600eByq
# SERIAL TEO: A900WSG1
/usr/share/iri/battery_monitor/scripts/load_pcspkr.sh
;;
abort-upgrade)
......@@ -14,4 +28,4 @@ case "$1" in
;;
esac
exit 0
exit 0
\ No newline at end of file
......@@ -2,7 +2,7 @@
set -e
case "$1" in
remove)
#echo "I'm a postrm script"
# echo "Running postrm script"
;;
purge)
......
......@@ -2,7 +2,21 @@
set -e
case "$1" in
remove)
#echo "I'm a prerm script"
echo "Running prerm script"
# TEST
# echo "pkg name $DPKG_MAINTSCRIPT_PACKAGE"
# echo "pkg files: dpkg -L <pkg_name>"
# dpkg -L $DPKG_MAINTSCRIPT_PACKAGE
# TEST
/usr/share/iri/battery_monitor/scripts/undo_unbind_ftdi_udev.sh -s A600eB1Y
/usr/share/iri/battery_monitor/scripts/undo_unbind_ftdi_udev.sh -s A600eByq
/usr/share/iri/battery_monitor/scripts/undo_unbind_ftdi_udev.sh -s A900WSG1
# SERIAL DABO: A600eB1Y
# SERIAL TIBI: A600eByq
# SERIAL TEO: A900WSG1
echo "battery_monitor postrm script: You may want to remove pcspkr from /etc/modules. You can do it by running ./scripts/undo_load_pcspkr.sh"
#/usr/share/iri/battery_monitor/scripts/undo_load_pcspkr.sh
;;
upgrade)
......
#!/bin/sh
echo "--- load_pcspkr.sh ---"
echo "Add pcspkr module to /etc/modules so it is loaded on startup"
LINE='pcspkr'
......
#!/bin/sh
VENDOR=${1:-0403}
PRODUCT=${2:-6001}
FILE=${3:-99-ftdi.rules}
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.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.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))
echo "Add udev rule so ${VENDOR}:${PRODUCT} devices do not load ftdi_sio driver"
LINE0="#The following 2 lines make ${VENDOR}:${PRODUCT} devices not load ftdi_sio driver"
LINE1="ATTRS{idVendor}==\"${VENDOR}\", ATTRS{idProduct}==\"${PRODUCT}\", MODE:=\"0666\""
LINE2=$"ATTRS{idVendor}==\"${VENDOR}\", ATTRS{idProduct}==\"${PRODUCT}\", RUN+=\"/bin/sh -c 'echo \$kernel > /sys/bus/usb/drivers/ftdi_sio/unbind'\""
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
echo " Need to unplug-plug devices for changes to take effect"
\ No newline at end of file
#!/bin/sh
echo "Remove pcspkr module from /etc/modules"
LINE="pcspkr"
FILE=/etc/modules
sudo sed -i "/$LINE/d" $FILE
sudo rmmod pcspkr
\ 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
sudo service udev restart
echo "Need to unplug-plug devices for changes to take effect"
\ No newline at end of file
......@@ -28,4 +28,10 @@ INSTALL(TARGETS battery_monitor
ARCHIVE DESTINATION lib/iri/${PROJECT_NAME})
INSTALL(FILES ${headers} DESTINATION include/iri/${PROJECT_NAME})
INSTALL(FILES ../Findbattery_monitor.cmake DESTINATION ${CMAKE_ROOT}/Modules/)
INSTALL(FILES ../scripts/unbind_ftdi_udev.sh
../scripts/load_pcspkr.sh
../scripts/undo_unbind_ftdi_udev.sh
../scripts/undo_load_pcspkr.sh
DESTINATION share/iri/${PROJECT_NAME}/scripts
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
ADD_SUBDIRECTORY(examples)
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