#include "Hello.h"
#include "HelloPublisher.h"
#define MAX_CONSECUTIVE_WRITE_ERROR 10
char *instance = NULL;
if (verbose) {
printf("Creating the data writer...\n");
}
participant,
topic,
NULL,
if (data_writer == NULL) {
fprintf(stderr, "! Unable to create DDS data writer\n");
goto exitFn;
}
if (hello_writer == NULL) {
fprintf(stderr, "! Unable to narrow data writer into "
"DDS_String writer\n");
goto exitFn;
}
if (instance == NULL) {
fprintf(stderr, "! Unable to create an instance of the data\n");
fprintf(stderr, "! This problem most likely is caused by "
"out of memory\n");
goto exitFn;
}
for (i = 0; i < data_size-1; ++i) {
instance[i] = (i < 11) ? ' ' : ('A' + (i % 26));
}
instance[i] = '\0';
printf("Sending data...\n");
i = 0;
for (count = 0;; ++count ) {
RTI_SNPRINTF(instance, 10, "%9d", count);
instance[9] = ' ';
hello_writer,
instance,
fprintf(stderr, "! Write error %d\n", rc);
if (++i > MAX_CONSECUTIVE_WRITE_ERROR) {
fprintf(stderr, "! Reached maximum number of failure, "
"stopping writer...\n");
goto exitFn;
}
}
i = 0;
if (verbose && (count % 10000) == 0) {
printf("Sent %d samples...\n", count);
}
if (sampleCount != 0 && (count >= sampleCount)) {
fprintf(stderr, "\nSent %d samples.\n", count);
break;
}
#ifdef RTI_WIN32
if (count < 20) {
Sleep(250);
} else if (count == 20) {
fprintf(stderr, "Speeding up now!!!!!!!!!!!\n");
} else {
}
#endif
}
exitFn:
if (instance != NULL) {
instance = NULL;
}
return return_value;
}