Skip to content

Commit 7bbafe5

Browse files
committed
Print not aborting on write failure
See arduino/Arduino#3614
1 parent 86fa94f commit 7bbafe5

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
* Print not aborting on write() failure. Thanks @stickbreaker
3+
24
SAMD CORE 1.6.1 2015.07.21
35

46
* Added missing ATN pin definition

bootloaders/zero/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
IDE_PATH="../../../../.."
2-
ARM_GCC_PATH=$(IDE_PATH)/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin
1+
ARM_GCC_PATH=/home/megabug/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin
32
CC=$(ARM_GCC_PATH)/arm-none-eabi-gcc
3+
OBJCOPY=$(ARM_GCC_PATH)/arm-none-eabi-objcopy
44
CFLAGS=-mthumb -mcpu=cortex-m0plus -Wall -c -g -Os -w -std=gnu99 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
55
LDFLAGS=-mthumb -mcpu=cortex-m0plus -Wall -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols
66
BLD_EXTA_FLAGS=-D__SAMD21G18A__
77
BUILD_PATH=build
8-
INCLUDES=-I$(IDE_PATH)/hardware/tools/CMSIS/CMSIS/Include/ -I$(IDE_PATH)/hardware/tools/CMSIS/Device/ATMEL/ -I./drivers/ -I./utils/ -I./utils/preprocessor/ -I./utils/interrupt
8+
INCLUDES=-I/home/megabug/.arduino15/packages/arduino/tools/CMSIS/4.0.0-atmel/CMSIS/Include/ -I/home/megabug/.arduino15/packages/arduino/tools/CMSIS/4.0.0-atmel/Device/ATMEL/ -I./drivers/ -I./utils/ -I./utils/preprocessor/ -I./utils/interrupt
99
SOURCES=main.c sam_ba_monitor.c startup_samd21.c usart_sam_ba.c drivers/cdc_enumerate.c drivers/uart_driver.c utils/interrupt/interrupt_sam_nvic.c
1010
OBJECTS=$(addprefix $(BUILD_PATH)/, $(SOURCES:.c=.o))
1111

12-
NAME=samd21_sam_ba
12+
NAME=samd21_sam_ba_genuino
1313
EXECUTABLE=$(NAME).bin
1414

1515
SLASH=/
@@ -19,11 +19,11 @@ all: $(SOURCES) $(EXECUTABLE)
1919

2020
$(EXECUTABLE): $(OBJECTS)
2121
$(CC) -L$(BUILD_PATH) $(LDFLAGS) -Os -Wl,--gc-sections -save-temps -Tsamd21j18a_flash.ld -Wl,-Map,$(BUILD_PATH)/$(NAME).map --specs=nano.specs --specs=nosys.specs -o $(BUILD_PATH)/$(NAME).elf $(OBJECTS) -Wl,--start-group -lm -Wl,--end-group
22-
$(ARM_GCC_PATH)/arm-none-eabi-objcopy -O binary $(BUILD_PATH)/$(NAME).elf $@
22+
$(OBJCOPY) -O binary $(BUILD_PATH)/$(NAME).elf $@
2323

2424
$(BUILD_PATH)/%.o: %.c
2525
-@mkdir -p $(@D)
2626
$(CC) $(CFLAGS) $(BLD_EXTA_FLAGS) $(INCLUDES) $< -o $@
2727

2828
clean:
29-
del $(EXECUTABLE) $(subst /,\,$(OBJECTS)) $(subst /,\,$(BUILD_PATH)/$(NAME).*)
29+
rm $(EXECUTABLE) $(subst /,\,$(OBJECTS)) $(subst /,\,$(BUILD_PATH)/$(NAME).*)

cores/arduino/Print.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ size_t Print::write(const uint8_t *buffer, size_t size)
3131
{
3232
size_t n = 0;
3333
while (size--) {
34-
n += write(*buffer++);
34+
if (write(*buffer++)) n++;
35+
else break;
3536
}
3637
return n;
3738
}
@@ -112,9 +113,7 @@ size_t Print::print(const Printable& x)
112113

113114
size_t Print::println(void)
114115
{
115-
size_t n = print('\r');
116-
n += print('\n');
117-
return n;
116+
return write("\r\n");
118117
}
119118

120119
size_t Print::println(const String &s)

0 commit comments

Comments
 (0)