Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions examples/xrcedds/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ##############################################################################
# apps/examples/xrcedds/CMakeLists.txt
#
# 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.
#
# ##############################################################################

if(CONFIG_EXAMPLES_XRCEDDS_PUB)
nuttx_add_application(
NAME
${CONFIG_EXAMPLES_XRCEDDS_PUB_PROGNAME}
SRCS
xrcedds_pub_main.c
hello_world.c
STACKSIZE
${CONFIG_EXAMPLES_XRCEDDS_PUB_STACKSIZE}
PRIORITY
${CONFIG_EXAMPLES_XRCEDDS_PUB_PRIORITY}
MODULE
${CONFIG_EXAMPLES_XRCEDDS_PUB}
DEPENDS
xrcedds)
endif()
5 changes: 5 additions & 0 deletions examples/xrcedds/HelloWorld.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct HelloWorld
{
unsigned long index;
string message;
};
29 changes: 29 additions & 0 deletions examples/xrcedds/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

menuconfig EXAMPLES_XRCEDDS_PUB
tristate "XRCEDDS publisher demo"
default n
depends on SYSTEM_XRCEDDS && NET_UDP && NET_IPv4
---help---
Build the PublishHelloWorldClient command. It connects to a
Micro XRCE-DDS Agent through the built-in UDP transport and
publishes HelloWorld samples.

if EXAMPLES_XRCEDDS_PUB

config EXAMPLES_XRCEDDS_PUB_PROGNAME
string "Publisher command name"
default "PublishHelloWorldClient"

config EXAMPLES_XRCEDDS_PUB_PRIORITY
int "Publisher task priority"
default 100

config EXAMPLES_XRCEDDS_PUB_STACKSIZE
int "Publisher task stack size"
default 4096

endif
25 changes: 25 additions & 0 deletions examples/xrcedds/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
############################################################################
# apps/examples/xrcedds/Make.defs
#
# 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.
#
############################################################################

ifneq ($(CONFIG_EXAMPLES_XRCEDDS_PUB),)
CONFIGURED_APPS += $(APPDIR)/examples/xrcedds
endif
33 changes: 33 additions & 0 deletions examples/xrcedds/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
############################################################################
# apps/examples/xrcedds/Makefile
#
# 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.
#
############################################################################

include $(APPDIR)/Make.defs

PROGNAME = $(CONFIG_EXAMPLES_XRCEDDS_PUB_PROGNAME)
PRIORITY = $(CONFIG_EXAMPLES_XRCEDDS_PUB_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_XRCEDDS_PUB_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_XRCEDDS_PUB)

MAINSRC = xrcedds_pub_main.c
CSRCS += hello_world.c

include $(APPDIR)/Application.mk
66 changes: 66 additions & 0 deletions examples/xrcedds/hello_world.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/****************************************************************************
* apps/examples/xrcedds/hello_world.c
*
* Implements the HelloWorld type described by HelloWorld.idl.
*
* 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.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <string.h>

#include <ucdr/microcdr.h>

#include "hello_world.h"

/****************************************************************************
* Public Functions
****************************************************************************/

bool hello_world_serialize_topic(struct ucdrBuffer *writer,
const struct hello_world_s *topic)
{
ucdr_serialize_uint32_t(writer, topic->index);
ucdr_serialize_string(writer, topic->message);

return !writer->error;
}

bool hello_world_deserialize_topic(struct ucdrBuffer *reader,
struct hello_world_s *topic)
{
ucdr_deserialize_uint32_t(reader, &topic->index);
ucdr_deserialize_string(reader, topic->message, 255);

return !reader->error;
}

uint32_t hello_world_topic_size(const struct hello_world_s *topic,
uint32_t size)
{
uint32_t previous_size = size;

size += ucdr_alignment(size, 4) + 4;
size += ucdr_alignment(size, 4) + 4 + strlen(topic->message) + 1;

return size - previous_size;
}
58 changes: 58 additions & 0 deletions examples/xrcedds/hello_world.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/****************************************************************************
* apps/examples/xrcedds/hello_world.h
*
* Declares the HelloWorld type described by HelloWorld.idl.
*
* 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_EXAMPLES_XRCEDDS_HELLO_WORLD_H
#define __APPS_EXAMPLES_XRCEDDS_HELLO_WORLD_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <stdbool.h>
#include <stdint.h>

/****************************************************************************
* Public Types
****************************************************************************/

struct hello_world_s
{
uint32_t index;
char message[255];
};

struct ucdrBuffer;

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

bool hello_world_serialize_topic(struct ucdrBuffer *writer,
const struct hello_world_s *topic);
bool hello_world_deserialize_topic(struct ucdrBuffer *reader,
struct hello_world_s *topic);
uint32_t hello_world_topic_size(const struct hello_world_s *topic,
uint32_t size);

#endif /* __APPS_EXAMPLES_XRCEDDS_HELLO_WORLD_H */
Loading
Loading