zephyrproject-rtos / gsoc-2022-arduino-core

Arduino Core Zephyr Module (GSoC 2022 Project)
Apache License 2.0
44 stars 11 forks source link

start writing Serial wrapper #30

Closed DhruvaG2000 closed 2 years ago

DhruvaG2000 commented 2 years ago

Need help with println

Signed-off-by: Dhruva Gole goledhruva@gmail.com

DhruvaG2000 commented 2 years ago

~will try something like #define Serial.println(f_, ...) printf((f_), ##__VA_ARGS__) reference: https://stackoverflow.com/a/20639864~

Above will not work since we need Serial dot print.... dot in #defines doesnt work as we would want in this case.

Also, found a more elegant solution by using the ZephyrSerial class itself

DhruvaG2000 commented 2 years ago

@szczys Thanks alot for the cleaner implementations, ~however I am unable to build, am I missing something? Error:~

[163/173] Linking CXX executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/zephyr_pre0.map
: && ccache /home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-g++   zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -Wl,-T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/posix/liblib__posix.a  zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  zephyr/boards/arm/arduino_nano_33_ble/libboards__arm__arduino_nano_33_ble.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/thumb/v7e-m/nofp"  -L/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -no-pie  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn && cd /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr && /usr/bin/cmake -E echo
/home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(zephyrSerial.cpp.obj): in function `arduino::ZephyrSerial::println()':
/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/cores/arduino/zephyrSerial.cpp:36: undefined reference to `putchar'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build
[ble: exit 1][ble: elapsed 6.014s (CPU 379.8%)] west build -p -b arduino_nano_33_ble samples/hello_arduino   -DZEPHYR_EXTRA_MODULES=/home/dhruva/zephyrproject/modules/lib/gso

~

Fixed in https://github.com/zephyrproject-rtos/gsoc-2022-arduino-core/pull/30/commits/010bc0af4089811c70bb44c40a9a0987c91b5e97

szczys commented 2 years ago

I made a comment on your latest commit. Once you address that issue, this PR LGTM!

DhruvaG2000 commented 2 years ago

Do you want to get this PR merged and add the others in a future PR?

I will work over it this weekend, till then I think we can merge this. Will create a new PR if the requirement for the remaining arises.