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

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

View file

@ -4,8 +4,9 @@ import sys
import serial import serial
ser = serial.Serial(sys.argv[1], 57600) ser = serial.Serial(sys.argv[1], 57600)
s.open() ser.close()
s.close() ser.open()
s.setBaudrate(1200) ser.close()
ser.setBaudrate(1200)
ser.open() ser.open()
ser.close() 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