Rearrange and fixup abstraction layer
- Replace os_result by dds_retcode_t and move DDS return code defines down. Eliminates the need to convert between different return code types. - Move dds_time_t down and remove os_time. Eliminates the need to convert between different time representations and reduces code duplication. - Remove use of Microsoft source-code annotation language (SAL). SAL annotations are Microsoft specific and not very well documented. This makes it very difficult for contributers to write. - Rearrange the abstraction layer to be feature-based. The previous layout falsely assumed that the operating system dictates which implementation is best suited. For general purpose operating systems this is mostly true, but embedded targets require a slightly different approach and may not even offer all features. The new layout makes it possible to mix-and-match feature implementations and allows for features to not be implemented at all. - Replace the os prefix by ddsrt to avoid name collisions. - Remove various portions of unused and unwanted code. - Export thread names on all supported platforms. - Return native thread identifier on POSIX compatible platforms. - Add timed wait for condition variables that takes an absolute time. - Remove system abstraction for errno. The os_getErrno and os_setErrno were incorrect. Functions that might fail now simply return a DDS return code instead. - Remove thread-specific memory abstraction. os_threadMemGet and accompanying functions were a mess and their use has been eliminated by other changes in this commit. - Replace attribute (re)defines by ddsrt_ prefixed equivalents to avoid name collisions and problems with faulty __nonnull__ attributes. Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
parent
318968f40f
commit
cd6742ee12
439 changed files with 22117 additions and 28782 deletions
|
@ -1,61 +1,66 @@
|
|||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "HelloWorldData.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
dds_entity_t participant;
|
||||
dds_entity_t topic;
|
||||
dds_entity_t writer;
|
||||
dds_return_t ret;
|
||||
HelloWorldData_Msg msg;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
dds_entity_t participant;
|
||||
dds_entity_t topic;
|
||||
dds_entity_t writer;
|
||||
dds_return_t rc;
|
||||
HelloWorldData_Msg msg;
|
||||
uint32_t status = 0;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
/* Create a Participant. */
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
DDS_ERR_CHECK (participant, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
|
||||
/* Create a Participant. */
|
||||
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
|
||||
if (participant < 0)
|
||||
DDS_FATAL("dds_create_participant: %s\n", dds_strretcode(-participant));
|
||||
|
||||
/* Create a Topic. */
|
||||
topic = dds_create_topic (participant, &HelloWorldData_Msg_desc,
|
||||
"HelloWorldData_Msg", NULL, NULL);
|
||||
DDS_ERR_CHECK (topic, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
|
||||
/* Create a Topic. */
|
||||
topic = dds_create_topic (
|
||||
participant, &HelloWorldData_Msg_desc, "HelloWorldData_Msg", NULL, NULL);
|
||||
if (topic < 0)
|
||||
DDS_FATAL("dds_create_topic: %s\n", dds_strretcode(-topic));
|
||||
|
||||
/* Create a Writer. */
|
||||
writer = dds_create_writer (participant, topic, NULL, NULL);
|
||||
/* Create a Writer. */
|
||||
writer = dds_create_writer (participant, topic, NULL, NULL);
|
||||
if (writer < 0)
|
||||
DDS_FATAL("dds_create_write: %s\n", dds_strretcode(-writer));
|
||||
|
||||
printf("=== [Publisher] Waiting for a reader to be discovered ...\n");
|
||||
printf("=== [Publisher] Waiting for a reader to be discovered ...\n");
|
||||
|
||||
ret = dds_set_status_mask(writer, DDS_PUBLICATION_MATCHED_STATUS);
|
||||
DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
|
||||
rc = dds_set_status_mask(writer, DDS_PUBLICATION_MATCHED_STATUS);
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
DDS_FATAL("dds_set_status_mask: %s\n", dds_strretcode(-rc));
|
||||
|
||||
while(true)
|
||||
{
|
||||
uint32_t status;
|
||||
ret = dds_get_status_changes (writer, &status);
|
||||
DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
|
||||
while(!(status & DDS_PUBLICATION_MATCHED_STATUS))
|
||||
{
|
||||
rc = dds_get_status_changes (writer, &status);
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
DDS_FATAL("dds_get_status_changes: %s\n", dds_strretcode(-rc));
|
||||
|
||||
if (status == DDS_PUBLICATION_MATCHED_STATUS) {
|
||||
break;
|
||||
}
|
||||
/* Polling sleep. */
|
||||
dds_sleepfor (DDS_MSECS (20));
|
||||
}
|
||||
/* Polling sleep. */
|
||||
dds_sleepfor (DDS_MSECS (20));
|
||||
}
|
||||
|
||||
/* Create a message to write. */
|
||||
msg.userID = 1;
|
||||
msg.message = "Hello World";
|
||||
/* Create a message to write. */
|
||||
msg.userID = 1;
|
||||
msg.message = "Hello World";
|
||||
|
||||
printf ("=== [Publisher] Writing : ");
|
||||
printf ("Message (%d, %s)\n", msg.userID, msg.message);
|
||||
printf ("=== [Publisher] Writing : ");
|
||||
printf ("Message (%d, %s)\n", msg.userID, msg.message);
|
||||
|
||||
ret = dds_write (writer, &msg);
|
||||
DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
|
||||
rc = dds_write (writer, &msg);
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
DDS_FATAL("dds_write: %s\n", dds_strretcode(-rc));
|
||||
|
||||
/* Deleting the participant will delete all its children recursively as well. */
|
||||
ret = dds_delete (participant);
|
||||
DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
|
||||
/* Deleting the participant will delete all its children recursively as well. */
|
||||
rc = dds_delete (participant);
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
DDS_FATAL("dds_delete: %s\n", dds_strretcode(-rc));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue