alarm_pool_add_alarm_at() returns 0 #614
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#614
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I believe there is some confusion about whether or not alarm_id 0 is valid. I tried this and it fails...
Perhaps the Timer documentation and alarm_pool_add_repeating_timer_us() return calculation is incorrect?
I assume you mean the
return out->alarm_id > 0;inadd_repeating_time_ms?yes that looks like a bug; should be
>= 0Looking closer, i imagine this can only happen if your repeating timer callback cancels the repeat immediately?
Well, that's the confusion. Is alarm_id_t = 0 the first valid alarm_id... and -1 is the error. or is 0 also an error?
0 is not a valid alarm_id
0 is a valid return from alarm_pool_add_repeating_timer_us() if there is no alarm remaining once the function returns - if fire_if_past is true then the callback will have been called but alarm_pool_add_repeating_timer_us() can return 0 still if the callback itself cancelled the timer
i have update the docs - about to post a PR
https://raspberrypi.github.io/pico-sdk-doxygen/group__alarm.html
and several api say something like...
really... i think there's a lot of inconsistency in the api return values maybe this is a hold over from the python world rather than taking a shot at if from the *nix world. . they should all return traditional error codes. with 0 = success. rather than mixing and matching ids and success = true booleans.
I suppose that means alarm_id = 0 is a special case that means "calledback because missed, but not repeated" ?
from https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf
look at the linked PR for the new state of the world and see if that makes sense. I'd still like to know if your callback cancels the repeating timer in_your_ example
merged into develop