From cac650a892ed6b1f49d3d1ef3618eb84aeb8b883 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Fri, 28 Jul 2017 15:46:03 +0900 Subject: [PATCH] Prevent omission of the device response on high-speed cpu. (#1) --- tf2md3_flash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tf2md3_flash b/tf2md3_flash index f9831d0..84ef42d 100755 --- a/tf2md3_flash +++ b/tf2md3_flash @@ -21,13 +21,18 @@ if [ x$3 = "x--erased" ]; then fi wait_ret(){ - while read -t 1 retval; do + while read -t 1.5 retval; do if [[ $retval == '00P' ]]; then return 1; fi if [[ $retval == '01Q' ]]; then return 0; fi if [[ $retval == '0Ee' ]]; then return 0; fi done < $1 return 0 } +wait_echo(){ + sleep $1 + echo $2 > $3 + return 0 +} if [ x$skip_erase = "xno" ]; then @@ -37,7 +42,7 @@ if [ x$skip_erase = "xno" ]; then while read -t 1 ret < $1; do sleep 0; done wait_ret $1 & pid=$! - echo '$FLASHERACEA' > $1 + wait_echo 0.5 '$FLASHERACEA' $1 & wait $pid ret=$? if [[ $ret -ne 1 ]]; then @@ -48,7 +53,7 @@ if [ x$skip_erase = "xno" ]; then fi wait_ret $1 & pid=$! - echo '$FLASHERACEB' > $1 + wait_echo 0.5 '$FLASHERACEB' $1 & wait $pid ret=$? if [[ $ret -ne 1 ]]; then