diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index b1b3ce5d..8742be93 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -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 </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/}"