Skip to content

Commit b8d9c60

Browse files
soburiDhruvaG2000
authored andcommitted
zephyrCommon: Add Print::write(uint8_t*, size_t) default implementation
When compile with enabling CONFIG_DEBUG option, the Print::write virtual function failed to link. This implementation is usually not used. Because the override implementation that implements by the subclass will be used. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent fda91b4 commit b8d9c60

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cores/arduino/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ zephyr_include_directories(../../variants)
44

55
if(NOT DEFINED ARDUINO_BUILD_PATH)
66

7+
zephyr_sources(zephyrPrint.cpp)
78
zephyr_sources(zephyrSerial.cpp)
89
zephyr_sources(zephyrCommon.cpp)
910
zephyr_sources(main.cpp)

cores/arduino/zephyrPrint.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2022 TOKITA Hiroshi <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <Arduino.h>
8+
9+
/*
10+
* This is the default implementation.
11+
* It will be overridden by subclassese.
12+
*/
13+
size_t arduino::Print::write(const uint8_t *buffer, size_t size)
14+
{
15+
size_t i;
16+
for (i=0; i<size && write(buffer[i]); i++) {
17+
}
18+
19+
return i;
20+
}

0 commit comments

Comments
 (0)