Automatically read the BAUDRATE from sketch. Works only in linux for now

This commit is contained in:
Sudar 2012-07-15 13:25:45 +05:30
parent 4dc7457265
commit eed8c52ffd
2 changed files with 22 additions and 5 deletions

View file

@ -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.

View file

@ -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