mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
Micro XRCE-DDS expects the application to supply open/close/write/read callbacks for the wire transport. Add a single dispatcher that registers the selected backend via rmw_uros_set_custom_transport(), plus two backends: transport/microros_transport_udp.c BSD-socket UDP backend. Opens an AF_INET/SOCK_DGRAM socket, resolves CONFIG_MICROROS_AGENT_IP/PORT, connect()s it, and uses send/recv. The socket fd is stashed in uxrCustomTransport->args so no module-level state is needed. transport/microros_transport_serial.c termios serial backend. Opens CONFIG_MICROROS_SERIAL_DEVICE with O_RDWR|O_NOCTTY|O_CLOEXEC, switches to raw 8N1 at CONFIG_MICROROS_SERIAL_BAUD, and uses poll/read/write. Fd is again stashed in uxrCustomTransport->args. Both backends are mutually exclusive at compile time via Kconfig; the dispatcher selects which set of callbacks to register. Wired into both the legacy Make build (CSRCS in system/microros/Makefile) and the CMake build (separate microros_transport static library with the transport directory only exposed to its INTERFACE). Signed-off-by: Arjav Patel <arjav1528@gmail.com>
50 lines
1.7 KiB
C
50 lines
1.7 KiB
C
/****************************************************************************
|
|
* apps/include/system/microros_transport.h
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#ifndef __APPS_INCLUDE_SYSTEM_MICROROS_TRANSPORT_H
|
|
#define __APPS_INCLUDE_SYSTEM_MICROROS_TRANSPORT_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
/****************************************************************************
|
|
* Public Function Prototypes
|
|
****************************************************************************/
|
|
|
|
/* microros_transport_init
|
|
*
|
|
* Register the NuttX-native transport (UDP or Serial, selected by Kconfig)
|
|
* with the rmw_microxrcedds layer. Must be called once before
|
|
* rclc_support_init().
|
|
*
|
|
* Returns 0 on success, negated errno on failure.
|
|
*/
|
|
|
|
int microros_transport_init(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __APPS_INCLUDE_SYSTEM_MICROROS_TRANSPORT_H */
|