refactor device reset code

pull/264/head
Jesse Vincent 7 years ago committed by Gergely Nagy
parent 5d9420c4f5
commit eb9164ddaa

@ -237,7 +237,13 @@ clean () {
rm -rf "${OUTPUT_PATH}"
}
reset_device () {
reset_device() {
find_device_port
check_device_port
reset_device_cmd
}
check_device_port () {
if [ -z $DEVICE_PORT ]; then
echo "Couldn't autodetect the keyboard's serial port."
echo "If you see this message and your keyboard is connected to your computer,"
@ -246,10 +252,9 @@ reset_device () {
echo "Please report this issue at https://github.com/keyboardio/Kaleidoscope";
exit 0;
fi
${RESET_DEVICE}
}
usage () {
cat <<EOF
Usage: $0 SKETCH commands...

@ -10,8 +10,10 @@ LIBRARY="${LIBRARY:-${SKETCH}}"
######## Keyboard hardware definitions
########
# These should be pulled from Arduino boards.txt
VID="${VID:-1209}"
BOOTLOADER_PID="${BOOTLOADER_PID:-2300}"
SKETCH_PID="${SKEYCH_PID:-2301}"
BOARD="${BOARD:-model01}"
MCU="${MCU:-atmega32u4}"
if [ "${BOARD}" = "virtual" ]; then
@ -31,24 +33,43 @@ fi
uname_S=$(uname -s 2>/dev/null || echo not)
DEVICE_PORT="$(ls /dev/ttyACM* 2>/dev/null || echo '')"
RESET_DEVICE="stty -F ${DEVICE_PORT} 1200 hupcl"
find_device_port() {
DIR=$(dirname "$(readlink -f "$0")")
DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev"
DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})"
}
reset_device_cmd() {
stty -F ${DEVICE_PORT} 1200 hupcl
}
MD5="md5sum"
find_bootloader_ports() {
DEVICE_PORT_BOOTLOADER="$(ls /dev/ttyACM* 2>/dev/null || echo '')"
DIR=$(dirname "$(readlink -f "$0")")
DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev"
DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${VID} ${BOOTLOADER_PID})"
}
if [ "${uname_S}" = "Darwin" ]; then
find_device_port() {
DEVICE_PORT="$(ls /dev/cu.usbmodemkbio* 2> /dev/null || echo '')"
DEVICE_PORT="${DEVICE_PORT:-$(ls /dev/cu.usbmodemCkbio* 2> /dev/null || echo '')}"
DEVICE_PORT="${DEVICE_PORT:-$(ls /dev/cu.usbmodemHID* 2> /dev/null || echo '')}"
DEVICE_PORT="${DEVICE_PORT:-$(ls /dev/cu.usbmodemCHID* 2> /dev/null || echo '')}"
DEVICE_PORT="${DEVICE_PORT:-$(ls /dev/cu.usbmodem14* 2> /dev/null || echo '')}"
RESET_DEVICE="/bin/stty -f ${DEVICE_PORT} 1200"
}
reset_device_cmd() {
/bin/stty -f ${DEVICE_PORT} 1200
}
ARDUINO_PATH="${ARDUINO_PATH:-/Applications/Arduino.app/Contents/Java/}"

Loading…
Cancel
Save