diff --git a/README.md b/README.md index 83f4b7c..9f44651 100644 --- a/README.md +++ b/README.md @@ -71,13 +71,16 @@ The following are the list of changes that I have made or merged in this fork. H ### 0.9.2 06.vi.2012 - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) -- Modified 'make size' behaviour: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) - +- Modified "make size" behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) ### 0.9.3 13.vi.2012 -- Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) +- Auto detect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) - Categorize libs into user and system (https://github.com/rpavlik/) - Dump size at the end of the build (https://github.com/rpavlik/) - Lots and lots of improvements (https://github.com/rpavlik/) - Changed bytes option for the head shell command, so that it works in Mac as well +- Auto detect Serial Baud rate from sketch if possible + +## Know Issues +- Because of the way the makefile is structured, the configuration parameters gets printed twice. diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index c362c96..4f312fa 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -102,6 +102,7 @@ # - Dump size at the end of the build (https://github.com/rpavlik/) # - Lots and lots of improvements (https://github.com/rpavlik/) # - Changed bytes option for the head shell command, so that it works in Mac as well +# - Auto detect Serial Baud rate from sketch if possible # ######################################################################## # @@ -238,7 +239,8 @@ # bindkey ^C kill # # If you want to change the baudrate, just set MONITOR_BAUDRATE. If you -# don't set it, it defaults to 9600 baud. +# don't set it, it tries to read from the sketch. If it couldn't read +# from the sketch, then it defaults to 9600 baud. # ######################################################################## # @@ -421,7 +423,19 @@ endif # for more information (search for 'character special device'). # ifndef MONITOR_BAUDRATE - MONITOR_BAUDRATE = 9600 + #This works only in linux. TODO: Port it to MAC OS also + SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $$(ls -1 *.ino) | sed -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) + MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) + + ifeq ($(MONITOR_BAUDRATE),) + $(warning The monitor speed wasnt properly set. Set to 9600 by default) + $(shell sleep 1) + MONITOR_BAUDRATE = 9600 + else + $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) + endif +else + $(call show_config_variable,MONITOR_BAUDRATE, [SPECIFIED]) endif ifndef MONITOR_CMD