diff --git a/simgear/io/SGDataDistributionService.cxx b/simgear/io/SGDataDistributionService.cxx index 90d20a4b..85b6ce7d 100644 --- a/simgear/io/SGDataDistributionService.cxx +++ b/simgear/io/SGDataDistributionService.cxx @@ -149,13 +149,16 @@ SG_DDS_Topic::read(char *buf, int length) dds_sample_info_t info[1]; result = dds_take(entry, (void**)&buf, info, 1, 1); - if(result < 0 || !info[0].valid_data) + if(result < 0) { errno = -result; result = 0; SG_LOG(SG_IO, SG_ALERT, "dds_take: " << dds_strretcode(errno)); } + else if (result > 0 && !info[0].valid_data) { + SG_LOG(SG_IO, SG_ALERT, "dds_take: invalid data"); + } return result*length; } @@ -292,7 +295,7 @@ SG_DDS::wait(float dt) dds_attach_t results[num]; if (dt > 0.0) - timeout = dt*1e9f * DDS_NSECS_IN_SEC; + timeout = dt * DDS_NSECS_IN_SEC; int status = dds_waitset_wait(waitset, results, num, timeout); if (status < 0) { diff --git a/simgear/io/SGDataDistributionService.hxx b/simgear/io/SGDataDistributionService.hxx index 244c8cb0..d915a04e 100644 --- a/simgear/io/SGDataDistributionService.hxx +++ b/simgear/io/SGDataDistributionService.hxx @@ -105,6 +105,9 @@ public: bool add(SG_DDS_Topic *topic, const SGProtocolDir d); bool close(); + const std::vector& get_readers() { return readers; } + const std::vector& get_writers() { return writers; } + bool wait(float dt = 0.0f); };