#include "Hello.h"
#include "HelloPublisher.h"
#define MAX_CONSECUTIVE_WRITE_ERROR 10
int RTI_SNPRINTF (
char *buffer,
size_t count,
const char *format, ...)
{
va_list ap;
va_start(ap, format);
#ifdef RTI_WIN32
length = _vsnprintf_s(buffer, count, count, format, ap);
#else
length = vsnprintf(buffer, count, format, ap);
#endif
va_end(ap);
}
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;
}
} else {
i = 0;
}
if (verbose && (count % 10000) == 0) {
printf("Sent %d samples...\n", count);
fflush(stdout);
}
if (sampleCount != 0 && (count >= sampleCount)) {
fprintf(stderr, "\nSent %d samples.\n", count);
break;
}
if (count < 20) {
fprintf(stderr,
"\nSending %d out of 20 samples before speeding up...\n",
count);
} else if (count == 20) {
fprintf(stderr, "Speeding up now!!\n");
}
}
exitFn:
if (instance != NULL) {
instance = NULL;
}
return return_value;
}