Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions dds/src/xtypes/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl EndiannessRead for LittleEndian {
}
}

const PID_SENTINEL: u16 = 1;
const PID_LIST_END: u16 = 0x3F02;

trait EncodingVersion: Sized {
fn align<'a, E: EndiannessRead>(
Expand Down Expand Up @@ -201,8 +201,8 @@ impl EncodingVersion for EncodingVersion1 {
let current_pid: u16 = deserializer.deserialize_primitive_type()?;
let current_pid_without_flags = current_pid & 0b00111111_11111111;
let length: u16 = deserializer.deserialize_primitive_type()?;
if current_pid_without_flags == PID_SENTINEL && length == 0 {
if pid == PID_SENTINEL {
if current_pid_without_flags == PID_LIST_END && length == 0 {
if pid == PID_LIST_END {
return Ok(0);
} else {
return Err(PidNotFound(pid));
Expand Down Expand Up @@ -277,7 +277,7 @@ impl EncodingVersion for EncodingVersion1 {
dynamic_data: &mut DynamicData,
) -> XTypesResult<()> {
deserializer.deserialize_members(dynamic_data)?;
Self::seek_to_pid(deserializer, PID_SENTINEL)?;
Self::seek_to_pid(deserializer, PID_LIST_END)?;
Ok(())
}

Expand Down Expand Up @@ -1736,7 +1736,7 @@ mod tests {
1, 2, 3, 0, // m1 | padding (1 bytres)
0x00, 42, 0, 4, // PID, length
0, 0, 0, 6, // m2
0, 1, 0, 0, // Sentinel
0x3F, 0x02, 0, 0, // Sentinel
]
)
.unwrap(),
Expand All @@ -1751,7 +1751,7 @@ mod tests {
1, 2, 3, 0, // m1 | padding (2 bytres)
42, 0x00, 4, 0, // PID, length
6, 0, 0, 0, // m2
1, 0, 0, 0, // Sentinel
0x02, 0x3F, 0, 0, // Sentinel
]
)
.unwrap(),
Expand Down Expand Up @@ -1910,7 +1910,7 @@ mod tests {
7, 0, 0, 0, // key | padding
0x00, 0x050, 0, 4, // PID | length
0, 0, 0, 8, // participant_key
0, 1, 0, 0, // Sentinel
0x3F, 0x02, 0, 0, // Sentinel
],
)
.unwrap(),
Expand Down
32 changes: 16 additions & 16 deletions dds/src/xtypes/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl<'a, E: EndiannessWrite, V: EncodingVersion> XTypesSerializer<'a, E, V> {
}
}

const PID_SENTINEL: u16 = 1;
const PID_LIST_END: u16 = 0x3F02;

struct Ssize<'a, 'b, E, V> {
serializer: &'a mut XTypesSerializer<'b, E, V>,
Expand Down Expand Up @@ -804,7 +804,7 @@ impl EncodingVersion for EncodingVersion1 {
}
// TODO: The alignment is not done in the Xtypes specification (possibly this needs to be deleted)
Self::align(serializer, 4);
serializer.serialize_primitive_type(&PID_SENTINEL);
serializer.serialize_primitive_type(&PID_LIST_END);
serializer.serialize_primitive_type(&0u16);
Ok(())
}
Expand Down Expand Up @@ -859,7 +859,7 @@ impl EncodingVersion for EncodingVersion1 {
serializer.serialize_selected_member_mmember(v)?;
// TODO: The alignment is not done in the Xtypes specification (possibly this needs to be deleted)
Self::align(serializer, 4);
serializer.serialize_primitive_type(&PID_SENTINEL);
serializer.serialize_primitive_type(&PID_LIST_END);
serializer.serialize_primitive_type(&0u16);
Ok(())
}
Expand Down Expand Up @@ -1408,7 +1408,7 @@ mod tests {
0x00, 0x02, 0x00, 0x00, // CDR Header
0x00, 41, 0, 2, // PID, length
1, 2, 0, 0, // version | padding (2 bytres)
0, 1, 0, 0, // Sentinel
0x3F, 0x02, 0, 0, // Sentinel
]
);
assert_eq!(
Expand All @@ -1417,7 +1417,7 @@ mod tests {
0x00, 0x03, 0x00, 0x00, // CDR Header
41, 0x00, 2, 0, // PID, length
1, 2, 0, 0, // version | padding (2 bytres)
1, 0, 0, 0, // Sentinel
0x02, 0x3F, 0, 0, // Sentinel
]
);
}
Expand All @@ -1438,7 +1438,7 @@ mod tests {
0x00, 0x02, 0x00, 0x00, // CDR Header
0x00, 41, 0, 3, // PID, length
1, 2, 3, 0, // member | padding (1 bytres)
0, 1, 0, 0, // Sentinel
0x3F, 0x02, 0, 0, // Sentinel
]
);
assert_eq!(
Expand All @@ -1447,7 +1447,7 @@ mod tests {
0x00, 0x03, 0x00, 0x00, // CDR Header
41, 0x00, 3, 0, // PID, length
1, 2, 3, 0, // member | padding (2 bytres)
1, 0, 0, 0, // Sentinel
0x02, 0x3F, 0, 0, // Sentinel
]
);
assert_eq!(
Expand Down Expand Up @@ -1504,7 +1504,7 @@ mod tests {
0, 0, 0, 1, // kind
3, 4, 5, 6, // address1 and 2
7, 0, 0, 0, // address2 | pading (3 bytes)
0, 1, 0, 0
0x3F, 0x02, 0, 0
]
);
}
Expand Down Expand Up @@ -1766,7 +1766,7 @@ mod tests {
0x08, 0x09, 0, 0, // two_bytes | padding (2 bytes)
0x70, 0x91, 0, 1, // PID + M_FLAG | length
7, 0, 0, 0, // one_byte | padding
0, 1, 0, 0, // Sentinel
0x3F, 0x02, 0, 0, // Sentinel
]
);
assert_eq!(
Expand All @@ -1777,7 +1777,7 @@ mod tests {
0x09, 0x08, 0, 0, // two_bytes | padding (2 bytes)
0x91, 0x70, 1, 0, // PID + M_FLAG | length
7, 0, 0, 0, // one_byte | padding
1, 0, 0, 0, // Sentinel
0x02, 0x3F, 0, 0, // Sentinel
]
);
assert_eq!(
Expand Down Expand Up @@ -1851,10 +1851,10 @@ mod tests {
0, 8, 0, 0, // field_mutable: two_bytes | padding (2 bytes)
0x40, 90, 0, 1, // field_mutable: PID (+ M_FLAG) | length
7, 0, 0, 0, // field_mutable: one_byte | padding (3 bytes)
0, 1, 0, 0, // field_mutable: Sentinel
0x3F, 0x02, 0, 0, // field_mutable: Sentinel
0x00, 98, 0, 2, // field_mutable: PID | length
0, 9, 0, 0, // field_final: primitive | padding (2 bytes)
0, 1, 0, 0, // Sentinel
0x3F, 0x02, 0, 0, // Sentinel
]
);
assert_eq!(
Expand All @@ -1868,10 +1868,10 @@ mod tests {
8, 0, 0, 0, // field_mutable: two_bytes | padding (2 bytes)
90, 0x40, 1, 0, // field_mutable: PID (+ M_FLAG) | length
7, 0, 0, 0, // field_mutable: one_byte | padding (3 bytes)
1, 0, 0, 0, // field_mutable: Sentinel
0x02, 0x3F, 0, 0, // field_mutable: Sentinel
98, 0x00, 2, 0, // field_mutable: PID | length
9, 0, 0, 0, // field_final: primitive | padding (2 bytes)
1, 0, 0, 0, // Sentinel
0x02, 0x3F, 0, 0, // Sentinel
]
);
}
Expand Down Expand Up @@ -2045,7 +2045,7 @@ mod tests {
0, 5, 0, 0, // discriminant (u16) | padding (2 bytes)
0b0000_0000, 1, 0, 4, // SMHEADER1 ID 1 (auto asigned) | length
0, 0, 0, 10, // selected_member u32 (VariantA)
0, 1, 0, 0, // SENTINEL
0x3F, 0x02, 0, 0, // SENTINEL
];
assert_eq!(serialize_cdr1_be(&variant_a).unwrap(), expected);
#[rustfmt::skip]
Expand All @@ -2067,7 +2067,7 @@ mod tests {
0, 6, 0, 0, // discriminant (u16) | padding (2 bytes)
0b0000_0000, 2, 0, 4, // SMHEADER1 ID 2 (auto asigned) | length
0, 0, 0, 10, // selected_member u32 (VariantA)
0, 1, 0, 0, // SENTINEL
0x3F, 0x02, 0, 0, // SENTINEL
];
assert_eq!(serialize_cdr1_be(&variant_b).unwrap(), expected);
#[rustfmt::skip]
Expand Down