Skip to content

Commit

Permalink
Merge branch 'eclipse-cyclonedds:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
noxpardalis committed Aug 9, 2023
2 parents 113a556 + 63f702e commit a496626
Show file tree
Hide file tree
Showing 28 changed files with 215 additions and 142 deletions.
1 change: 0 additions & 1 deletion ports/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ set(CDDS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cyclonedds-prefix/include)

ExternalProject_Add(cyclonedds
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../
BUILD_COMMAND ${CMAKE_COMMAND} --build .
CMAKE_ARGS
-DBUILD_SHARED_LIBS=0 -DENABLE_SECURITY=0 -DENABLE_SSL=0 -DENABLE_SOURCE_SPECIFIC_MULTICAST=0 -DENABLE_IPV6=1 -DENABLE_SHM=0 -DWITH_ZEPHYR=1
Expand Down
23 changes: 15 additions & 8 deletions ports/zephyr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
This directory contains some proof-of-concept applications that show how to build and use CycloneDDS on [Zephyr RTOS](https://www.zephyrproject.org) for a NXP X-S32Z27X-DC board.


Getting Started with Zephyr information can be found [here](https://docs.zephyrproject.org/3.3.0/develop/getting_started/index.html)
Getting Started with Zephyr information can be found [here](https://docs.zephyrproject.org/3.4.0/develop/getting_started/index.html)
Documentation for the NXP X-S32Z27X-DC board can be found [here](https://docs.zephyrproject.org/3.4.0/boards/arm/s32z270dc2_r52/doc/index.html)

## Usage
The applications can be treated similarly to other Zephyr sample applications.
The `CMakeLists.txt` is currently set up to build some of the CycloneDDS examples or ddsperf but can be easily modified or extended for other application code.

Documentation for the NXP X-S32Z27X-DC board can be found [here](https://docs.zephyrproject.org/3.3.0/boards/arm/s32z270dc2_r52/doc/index.html)
:warning: While CycloneDDS can be built in-tree, it does not support multiple different builds. Therefore the CycloneDDS source directory needs to be cleaned in order to build for Zephyr and must not contain an in-tree build for eg. the host system. Alternatively, this directory with Zephyr examples can be copied outside the CycloneDDS source directory but that requires updating the `ExternalProject_Add` directive in `CMakeLists.txt` to point to the CycloneDDS source directory.

## Usage:
This directory can used like any generic Zephyr application.
The `CMakeLists.txt` is currently set up to build CycloneDDS examples and ddsperf but can be easily modified or extended for other application code.
:warning: When building outside the Zephyr tree, `ZEPHYR_BASE` variable must be set. See [Application Development](https://docs.zephyrproject.org/3.4.0/develop/application/index.html) for more info.

The copy_examples.sh script can be used (manually) to update the code from CycloneDDS examples and run idlc to generate types.
:warning: A static IPv4/IPv6 address is defined in `prj.conf`. When running between two Zephyr nodes it is suggested to copy `prj.conf` to eg. `prj-host1.conf` and `prj-host2.conf`, updating the address as required and building with `-DCONF=prj-host1.conf` or `-DCONF=prj-host2.conf` respectively, as described in more detail [here](https://docs.zephyrproject.org/3.4.0/samples/net/eth_native_posix/README.html). A different approach is to enable DHCP client support in Zephyr (see [example](https://docs.zephyrproject.org/3.4.0/samples/net/dhcpv4_client/README.html)).

The `copy_examples.sh` script can be used to (manually) update the code from CycloneDDS examples and run `idlc` to generate types.

For example, to build Roundtrip Ping for the `s32z270dc2_rtu0_r52` target:
```
Expand All @@ -25,6 +29,9 @@ $ west build -b qemu_x86 . -- -DOVERLAY_CONFIG=overlay-e1000.conf -DBUILD_ROUNDT
```
Command-line parameters for the example can be modified in `src/rountrip_main.c`


The CycloneDDS configuration in `config.xml` is automatically converted to a char array and available as environment variable to support the default behaviour of retrieving config from CYCLONEDDS_URI.
The CycloneDDS configuration in `config.xml` is automatically converted to a char array and available as environment variable to support the default behaviour of retrieving config from `CYCLONEDDS_URI`.
Alternatively, [dds_create_domain_with_rawconfig](https://cyclonedds.io/docs/cyclonedds/latest/api/domain.html?#c.dds_create_domain_with_rawconfig) can be used without XML configuration data.

## Zephyr versions
At the time of writing, CycloneDDS has been tested on Zephyr [v3.3.0](https://github.com/zephyrproject-rtos/zephyr/releases/tag/v3.3.0) and [v3.4.0](https://github.com/zephyrproject-rtos/zephyr/releases/tag/v3.4.0). However, for the NXP X-S32Z27X-DC board an issue exists in `v3.4.0` that can cause CycloneDDS to crash. This is fixed on the Zephyr main branch, therefore we suggest using [@143429](https://github.com/zephyrproject-rtos/zephyr/commit/14342969150a35f3c26afa513a4725bdec310799).

13 changes: 13 additions & 0 deletions ports/zephyr/boards/s32z270dc2_rtu0_r52.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Define 7M sram ragion to override 1M sram0 (for RTU0 only) */
/{
soc {
sram2: memory@32100000 {
compatible = "mmio-sram";
reg = <0x32100000 DT_SIZE_M(7)>;
};
};

chosen {
zephyr,sram = &sram2;
};
};
27 changes: 0 additions & 27 deletions ports/zephyr/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,6 @@
<!-- Transport>udp6</Transport -->
<MaxMessageSize>1400B</MaxMessageSize>
</General>
<Threads>
<Thread name="recv">
<Scheduling>
<Priority>15</Priority>
</Scheduling>
</Thread>
<Thread name="tev">
<Scheduling>
<Priority>15</Priority>
</Scheduling>
</Thread>
<Thread name="gc">
<Scheduling>
<Priority>15</Priority>
</Scheduling>
</Thread>
<Thread name="dq.builtins">
<Scheduling>
<Priority>15</Priority>
</Scheduling>
</Thread>
<Thread name="dq.user">
<Scheduling>
<Priority>15</Priority>
</Scheduling>
</Thread>
</Threads>
<Sizing>
<ReceiveBufferSize>40KiB</ReceiveBufferSize>
<ReceiveBufferChunkSize>20KiB</ReceiveBufferChunkSize>
Expand Down
4 changes: 2 additions & 2 deletions ports/zephyr/src/ddsperf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ char **environ = (char*[]) {
NULL
};

void main(void)
int main(void)
{
printf("CycloneDDS DDSPerf (%s)\n", CONFIG_BOARD);
#if BUILD_DDSPERF_PING
Expand All @@ -23,5 +23,5 @@ void main(void)
#endif
ddsperf_main(sizeof(args)/sizeof(args[0]), args);
printf("Done\n");
return;
return 0;
}
4 changes: 2 additions & 2 deletions ports/zephyr/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void helloworld_subscriber()
DDS_FATAL("dds_delete (domain): %s\n", dds_strretcode(-rc));
}

void main(void)
int main(void)
{
printf("CycloneDDS Hello World! %s\n", CONFIG_BOARD);
#if BUILD_HELLOWORLD_PUB
Expand All @@ -211,5 +211,5 @@ void main(void)
helloworld_subscriber();
#endif
printf("Done\n");
return;
return 0;
}
4 changes: 2 additions & 2 deletions ports/zephyr/src/roundtrip_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ char **environ = (char*[]) {
NULL
};

void main(void)
int main(void)
{
int ret;
printf("CycloneDDS Roundtrip (%s)\n", CONFIG_BOARD);
Expand All @@ -34,5 +34,5 @@ void main(void)
ret = roundtrip_pong(sizeof(args)/sizeof(args[0]), args);
#endif
printf("Done (ret=%d)\n", ret);
return;
return 0;
}
4 changes: 2 additions & 2 deletions ports/zephyr/src/throughput_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ char **environ = (char*[]) {
NULL
};

void main(void)
int main(void)
{
int ret;
printf("CycloneDDS Throughput (%s)\n", CONFIG_BOARD);
Expand All @@ -26,5 +26,5 @@ void main(void)
ret = throughput_sub(sizeof(args)/sizeof(args[0]), args);
#endif
printf("Done (ret=%d)\n", ret);
return;
return 0;
}
2 changes: 1 addition & 1 deletion src/core/cdr/include/dds/cdr/dds_cdrstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ uint32_t dds_stream_key_flags (struct dds_cdrstream_desc *desc, uint32_t *keysz_
bool dds_stream_extensibility (const uint32_t * __restrict ops, enum dds_cdr_type_extensibility *ext);

/** @component cdr_serializer */
void dds_cdrstream_desc_init (struct dds_cdrstream_desc *desc, const struct dds_cdrstream_allocator * __restrict allocator,
DDS_EXPORT void dds_cdrstream_desc_init (struct dds_cdrstream_desc *desc, const struct dds_cdrstream_allocator * __restrict allocator,
uint32_t size, uint32_t align, uint32_t flagset, const uint32_t *ops, const dds_key_descriptor_t *keys, uint32_t nkeys);

/** @component cdr_serializer */
Expand Down
10 changes: 8 additions & 2 deletions src/core/cdr/src/dds_cdrstream_keys.part.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ static const uint32_t *dds_stream_extract_keyBO_from_data_delimited (dds_istream
{
uint32_t delimited_sz_is = dds_is_get4 (is), delimited_offs_is = is->m_index, insn;

/* At this point we can safely assume that at least one of the members
of this aggregated type is part of the key, so we need to add the dheader */
uint32_t delimited_offs_os = 0;
if (os != NULL)
{
/* At this point we can safely assume that at least one of the members
of this aggregated type is part of the key, so we need to add the dheader */
delimited_offs_os = dds_os_reserve4BO (os, allocator);
}

ops++;
while ((insn = *ops) != DDS_OP_RTS)
Expand All @@ -194,6 +196,10 @@ static const uint32_t *dds_stream_extract_keyBO_from_data_delimited (dds_istream
}
}

/* Skip remainder of serialized data for this appendable type */
if (delimited_sz_is > is->m_index - delimited_offs_is)
is->m_index += delimited_sz_is - (is->m_index - delimited_offs_is);

/* if not in skip mode: add dheader in os */
if (os != NULL)
{
Expand Down
4 changes: 4 additions & 0 deletions src/core/ddsc/include/dds/ddsc/dds_public_dynamic_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
extern "C" {
#endif

#ifdef DDS_HAS_TYPELIB

struct ddsi_typeinfo;

/**
Expand Down Expand Up @@ -624,6 +626,8 @@ DDS_EXPORT dds_return_t dds_dynamic_type_unref (dds_dynamic_type_t *type);
DDS_EXPORT dds_dynamic_type_t dds_dynamic_type_dup (const dds_dynamic_type_t *src);


#endif /* DDS_HAS_TYPELIB */

#if defined (__cplusplus)
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/core/ddsc/tests/TypeBuilderTypes.idl
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,10 @@ module TypeBuilderTypes {
t27_1 f1;
};

/* unbounded string key */
/* bounded and unbounded string key */
struct t28 {
@key string f1;
@key string<3> f2;
};

};
14 changes: 3 additions & 11 deletions src/core/ddsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,6 @@ if(ENABLE_DEADLINE_MISSED)
ddsi_deadline.h
)
endif()
if(ENABLE_TYPELIB)
list(APPEND srcs_ddsi
ddsi_typelib.c
)
list(APPEND hdrs_ddsi
ddsi_typelib.h
)
list(APPEND hdrs_private_ddsi
ddsi__typelib.h
)
endif()
if(ENABLE_TOPIC_DISCOVERY)
list(APPEND srcs_ddsi
ddsi_discovery_topic.c
Expand All @@ -249,19 +238,22 @@ if(ENABLE_TYPELIB)
list(APPEND srcs_ddsi
ddsi_xt_typeinfo.c
ddsi_xt_typemap.c
ddsi_typelib.c
ddsi_typewrap.c
ddsi_typebuilder.c
ddsi_dynamic_type.c
)
list(APPEND hdrs_ddsi
ddsi_xt_typeinfo.h
ddsi_xt_typemap.h
ddsi_typelib.h
ddsi_typewrap.h
ddsi_typebuilder.h
ddsi_dynamic_type.h
)
list(APPEND hdrs_private_ddsi
ddsi__xt_impl.h
ddsi__typelib.h
ddsi__dynamic_type.h
)
endif()
Expand Down
4 changes: 4 additions & 0 deletions src/core/ddsi/include/dds/ddsi/ddsi_dynamic_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
extern "C" {
#endif

#ifdef DDS_HAS_TYPELIB

struct ddsi_dynamic_type_struct_member_param {
uint32_t id;
const char *name;
Expand Down Expand Up @@ -131,6 +133,8 @@ struct ddsi_type * ddsi_dynamic_type_dup (const struct ddsi_type *src);
/** @component dynamic_type_support */
bool ddsi_dynamic_type_is_constructing (const struct ddsi_type *type);

#endif /* DDS_HAS_TYPELIB */

#if defined (__cplusplus)
}
#endif
Expand Down
8 changes: 6 additions & 2 deletions src/core/ddsi/include/dds/ddsi/ddsi_typebuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
extern "C" {
#endif

#ifdef DDS_HAS_TYPELIB

/** @component dynamic_types */
dds_return_t ddsi_topic_descriptor_from_type (struct ddsi_domaingv *gv, dds_topic_descriptor_t *desc, const struct ddsi_type *type);
DDS_EXPORT dds_return_t ddsi_topic_descriptor_from_type (struct ddsi_domaingv *gv, dds_topic_descriptor_t *desc, const struct ddsi_type *type);

/** @component dynamic_types */
void ddsi_topic_descriptor_fini (dds_topic_descriptor_t *desc);
DDS_EXPORT void ddsi_topic_descriptor_fini (dds_topic_descriptor_t *desc);

#endif /* DDS_HAS_TYPELIB */

#if defined (__cplusplus)
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/ddsi/include/dds/ddsi/ddsi_typelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
extern "C" {
#endif

#ifdef DDS_HAS_TYPELIB

struct ddsi_domaingv;
struct ddsi_sertype;
struct ddsi_type;
Expand Down Expand Up @@ -141,6 +143,8 @@ DDS_EXPORT struct ddsi_type * ddsi_type_lookup (struct ddsi_domaingv *gv, const
*/
DDS_EXPORT int ddsi_type_compare (const struct ddsi_type *a, const struct ddsi_type *b);

#endif /* DDS_HAS_TYPELIB */

#if defined (__cplusplus)
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/core/ddsi/src/ddsi_sertype.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,5 @@ DDS_EXPORT extern inline ddsi_typemap_t * ddsi_sertype_typemap (const struct dds
DDS_EXPORT extern inline ddsi_typeinfo_t * ddsi_sertype_typeinfo (const struct ddsi_sertype *tp);
DDS_EXPORT extern inline struct ddsi_sertype * ddsi_sertype_derive_sertype (const struct ddsi_sertype *base_sertype, dds_data_representation_id_t data_representation, dds_type_consistency_enforcement_qospolicy_t tce_qos);

extern inline size_t ddsi_sertype_get_serialized_size(const struct ddsi_sertype *tp, const void *sample);
extern inline bool ddsi_sertype_serialize_into(const struct ddsi_sertype *tp, const void *sample, void *dst_buffer, size_t dst_size);
DDS_EXPORT extern inline size_t ddsi_sertype_get_serialized_size(const struct ddsi_sertype *tp, const void *sample);
DDS_EXPORT extern inline bool ddsi_sertype_serialize_into(const struct ddsi_sertype *tp, const void *sample, void *dst_buffer, size_t dst_size);
Loading

0 comments on commit a496626

Please sign in to comment.