diff LoadFile/load.dfu @ 281:71882cd1c362

Check for needed programs Check for dfu-util and screen before using them. Also aborts if teensy_loader_cli compilation fails. Uses the type builtin to determine if a command exists. See here: https://gist.github.com/sdelmas/7377271
author Rowan Decker <Smasher816@gmail.com>
date Thu, 12 Feb 2015 19:42:01 -0800
parents 2a3468f5d8be
children c86eb7d0a693
line wrap: on
line diff
--- a/LoadFile/load.dfu	Thu Feb 12 19:37:19 2015 -0800
+++ b/LoadFile/load.dfu	Thu Feb 12 19:42:01 2015 -0800
@@ -54,13 +54,23 @@
 
 # Load via dfu-util
 # Used for McHCK based uCs
-dfu-util -D @TARGET_BIN@
-EXIT_STATUS=$?
+if type dfu-util &>/dev/null; then
+	dfu-util -D @TARGET_BIN@
+	EXIT_STATUS=$?
+else
+	echo "dfu-util is required to reprogram the device"
+	exit 3
+fi
 
 # Load Screen Session if specified
 if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then
-	sleep 0.1
-	screen $AUTO_SCREEN_SESSION
+	if type screen &>/dev/null; then
+		sleep 0.1
+		screen $AUTO_SCREEN_SESSION
+	else
+		echo "screen is not installed"
+		exit 3
+	fi
 fi
 
 exit $EXIT_STATUS