fix uxrce_dds_client: apparently we cannot use the upper 4 bits for ID's

This commit is contained in:
Beat Küng
2023-08-08 10:59:34 +02:00
parent 64c21ad428
commit 02a6640000
2 changed files with 10 additions and 14 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ static void on_topic_update(uxrSession *session, uxrObjectId object_id, uint16_t
switch (object_id.id) {
@[ for idx, sub in enumerate(subscriptions)]@
case @(idx)+1000: {
case @(idx)+ (65535U / 32U) + 1: {
@(sub['simple_base_type'])_s data;
if (ucdr_deserialize_@(sub['simple_base_type'])(*ub, data, time_offset_us)) {
+9 -13
View File
@@ -10,17 +10,13 @@
uxrObjectId topic_id_from_orb(ORB_ID orb_id, uint8_t instance = 0)
{
// Note that the uxrObjectId.id is a uint16_t so we need to cap the ID.
// orb_id_size_t is currently uint16_t (MAX = 65535) and a max # of instances as either 4 or 10.
// We want to use half of the available id's for writers and half for readers,
// so this works as long as orb_id < 3276.
// Unfortunately, limits does not appear to be available. So hard-coding for uint16_t.
if (orb_id != ORB_ID::INVALID &&
//(orb_id_size_t) orb_id < (std::numeric_limits<orb_id_size_t> / (2*ORB_MULTI_MAX_INSTANCES) )
(orb_id_size_t) orb_id < (65535U / (2U * (uint16_t)ORB_MULTI_MAX_INSTANCES))
) {
uint16_t id = static_cast<orb_id_size_t>(orb_id) + (instance * ORB_TOPICS_COUNT);
uxrObjectId topic_id = uxr_object_id(id, UXR_TOPIC_ID);
// Note that the uxrObjectId.id is a uint16_t so we need to cap the ID,
// and urx does not allow us to use the upper 4 bits.
const unsigned max_id = 65535U / 32U;
const unsigned id = static_cast<unsigned>(orb_id) + (instance * ORB_TOPICS_COUNT);
if (orb_id != ORB_ID::INVALID && id < max_id) {
uxrObjectId topic_id = uxr_object_id(static_cast<uint16_t>(id), UXR_TOPIC_ID);
return topic_id;
}
@@ -103,8 +99,8 @@ static bool create_data_reader(uxrSession *session, uxrStreamId reliable_out_str
}
// Use the second half of the available ID space.
// Add 1 so that we get a nice hex starting number: 0x8000 instead of 0x7fff.
uint16_t id = index + (65535U / 2U) + 1;
// Add 1 so that we get a nice hex starting number: 0x800 instead of 0x7ff.
uint16_t id = index + (65535U / 32U) + 1;
uxrObjectId topic_id = uxr_object_id(id, UXR_TOPIC_ID);
uint16_t topic_req = uxr_buffer_create_topic_bin(session, reliable_out_stream_id, topic_id, participant_id, topic_name,