bug fixes: jazzy: serial transport#163
Open
kristkis wants to merge 9 commits intomicro-ROS:kiltedfrom
Open
Conversation
* updates project to work with zephyr v4.0.x * updating workflows for zephyr v4.0.x * adds cmake prefix path, changes to ci image * adds manual trigger to ci workflows * updates CI workflows for all active ROS2 distros * Get uart device with Zephyr 4's Devicetree-centric approach Signed-off-by: Antón Casas <antoncasas@eprosima.com> * Tested in v4.1.0 using manual installation on Ubuntu:24.04 base Docker image Signed-off-by: Antón Casas <antoncasas@eprosima.com> * Add v4.1.0 to CI and nightly Signed-off-by: Antón Casas <antoncasas@eprosima.com> * State SDK used in CI. Restore Z0rdon's info about docker image used. Signed-off-by: Antón Casas <antoncasas@eprosima.com> --------- Signed-off-by: Antón Casas <antoncasas@eprosima.com> Co-authored-by: Antón Casas <antoncasas@eprosima.com>
Signed-off-by: Antón Casas <antoncasas@eprosima.com>
(cherry picked from commit b81263f) Co-authored-by: Antón Casas <antoncasas@eprosima.com>
* Free space in docker * Build script as step * Nightly --------- Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com> Co-authored-by: EugenioCollado <121509066+EugenioCollado@users.noreply.github.com>
- Replace <unistd.h> with <stddef.h>/<stdint.h>/<stdbool.h> in the
header and remove <zephyr/posix/unistd.h> from the source. On
Zephyr 4.1+ with SDK 0.17.0 the toolchain's unistd.h collides
with Zephyr's posix/sys/sysconf.h, causing a build error
("expected identifier before numeric constant" on _SC_ADVISORY_INFO).
- Replace usleep() with k_usleep() — the POSIX sleep was the only
reason for including unistd.h. k_usleep is Zephyr-native and
does not require CONFIG_POSIX_API.
- Make the UART device configurable via a DT alias (microros-serial).
Applications that need a different UART define the alias in their
board overlay. Falls back to DT_NODELABEL(usart1) when the alias
is absent, preserving backward compatibility.
- Fix ring_buf_init() passing uart_out_buffer as storage for the
input ring buffer instead of uart_in_buffer. Worked by accident
(out_ringbuf was never used) but was incorrect.
- Remove unused uart_out_buffer and out_ringbuf (dead code).
- Use device_is_ready() instead of a null pointer check in
transport_open(). DEVICE_DT_GET never returns NULL in modern
Zephyr; device_is_ready() is the correct readiness check.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Kristina Kisiuk kisyuk.kristina@gmail.com
Signed-off-by: kristkis <kisyuk.kristina@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix serial transport build failure on Zephyr 4.1+ and make the UART device configurable without patching module source files.
<unistd.h>/<zephyr/posix/unistd.h>cause_SC_ADVISORY_INFOenum/macro collision on Zephyr 4.1 with SDK 0.17.0. Replaced with standard C headers +k_usleep().microros-serialin the application's board overlay. Falls back tousart1when the alias is absent (no breaking change).ring_buf_init()was using the wrong buffer,device_is_ready()replaces a null-pointer check that can't trigger in modern Zephyr, dead code removed.Motivation
Anyone using the serial transport on Zephyr 4.1+ with the Zephyr SDK 0.17.0 ARM toolchain hits a hard build error:
This is caused by
<unistd.h>pulling in the toolchain's POSIX sysconf macros, which collide with Zephyr's own POSIX enum of the same names. The only symbols actually needed from<unistd.h>weresize_t,bool, andusleep()— the first two come from standard C headers, andusleep()is replaced byk_usleep().Additionally,
UART_NODEwas hardcoded toDT_NODELABEL(usart1), forcing anyone with a different UART (e.g.lpuart1on STM32G4) to patch this file locally. The DT alias approach lets applications select the UART in their overlay:Discussion point: DT alias vs Kconfig for UART selection
This PR uses a DT alias (
microros-serial) for UART selection because it follows Zephyr idiom (similar tozephyr,console) and works cleanly with the devicetree preprocessor. A Kconfig string approach was considered but Kconfig strings expand as quoted C strings, which are incompatible withDT_NODELABEL()token pasting.Open to feedback on whether a different mechanism (e.g. DT chosen node, or a Kconfig that selects between a fixed set of UART labels) would be preferred by the maintainers.
Changes
microros_transports.h<unistd.h>→<stddef.h>/<stdint.h>/<stdbool.h>microros_transports.c<zephyr/posix/unistd.h>,usleep()→k_usleep()microros_transports.cDT_ALIAS(microros_serial), fallback tousart1microros_transports.cring_buf_init()using wrong buffer (uart_out_buffer→uart_in_buffer)microros_transports.cuart_out_bufferandout_ringbufmicroros_transports.cdevice_is_ready()instead of null check intransport_open()Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com