diff --git a/Makefile b/Makefile index 835f768..4fe4e70 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ main.hex: $(TARGET) flash: -sudo chmod 777 $(COM) - -./reset_mcu.sh + -./reset_mcu.sh $(COM) -stcgal -P stc89 -p $(COM) main.hex #led.bin:led.hex diff --git a/reset_mcu.sh b/reset_mcu.sh index 9ea07fa..8c9580a 100755 --- a/reset_mcu.sh +++ b/reset_mcu.sh @@ -16,9 +16,13 @@ # --- ---- --- ----------- # 0.0.01 2024-07-14 Feng Bohan initial version #=========================================================================== -stty -F /dev/ttyUSB0 speed 9600 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke +if [ "$#" -ne 1 ]; then + echo "错误:此脚本需要且仅需要一个参数, 作为COM口号" + exit 1 # 使用非零状态码退出表示异常 +fi +stty -F $1 speed 9600 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke -echo -e "RESET!" > /dev/ttyUSB0 +echo -e "RESET!" > $1 #说明: