refactoring

This commit is contained in:
Masataro Asai 2013-05-29 01:03:49 +09:00
parent 0b2877cfed
commit 53b0593ac7
3 changed files with 38 additions and 14 deletions

View file

@ -531,10 +531,22 @@ endif
# Reset
#
ifndef RESET_CMD
ifeq ($(BOARD_TAG),leonardo)
RESET_CMD = $(ARDMK_PATH)/ard-reset-leonardo $(ARD_RESET_OPTS)
else
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS)
ifeq ($(BOARD_TAG),leonardo)
RESET_CMD = $(ARDMK_PATH)/ard-reset-leonardo \
$(ARD_RESET_OPTS) $(call get_arduino_port)
else
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino \
$(ARD_RESET_OPTS) $(call get_arduino_port)
endif
endif
ifndef WAIT_CONNECTION_CMD
ifeq ($(BOARD_TAG),leonardo)
WAIT_CONNECTION_CMD = \
$(ARDMK_PATH)/wait-connection-leonardo $(call get_arduino_port)
else
WAIT_CONNECTION_CMD =
endif
endif
########################################################################
@ -964,13 +976,9 @@ raw_eeprom: reset $(TARGET_EEP) $(TARGET_HEX)
# the last part is for leonardo.
# wait until leonardo reboots and establish a new connection.
reset:
$(ECHO) "Resetting Arduino..."
$(RESET_CMD) $(call get_arduino_port)
while [ ! -e $(ARD_PORT) ] ;\
do \
echo "Waiting for arduino at $(ARD_PORT)";\
sleep 0.3 ;\
done
$(call arduino_output,Resetting Arduino...)
$(RESET_CMD)
$(WAIT_CONNECTION_CMD)
# stty on MacOS likes -F, but on Debian it likes -f redirecting
# stdin/out appears to work but generates a spurious error on MacOS at

View file

@ -4,8 +4,9 @@ import sys
import serial
ser = serial.Serial(sys.argv[1], 57600)
s.open()
s.close()
s.setBaudrate(1200)
ser.close()
ser.open()
ser.close()
ser.setBaudrate(1200)
ser.open()
ser.close()

15
bin/wait-connection-leonardo Executable file
View file

@ -0,0 +1,15 @@
#! /bin/bash
while [ ! -e $1 ]
do
echo Waiting connection at $1
sleep 0.2
done
sleep 1
# necessary for me...
# /dev/ttyACM0 used to disappear after the reset
# but no longer now. How can I tell whether the
# connection is ready?
echo Connection Established