Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,3 @@ target/

# history
.history

# we don't have dsdl in this repo any more
dsdl/
6 changes: 6 additions & 0 deletions dronecan/dsdl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,12 @@ def ensure_unique_dtid(t, filename):
value = all_default_dtid[key]
first = pretty_filename(value[0])
second = pretty_filename(filename)

# Allow overrides for vendor specific data types in the range [20000, 21000)
if 20000 <= t.default_dtid < 21000:
logger.warning('Overriding previously defined data type: [%s] [%s]', first, second)
return

if t.get_dsdl_signature() != value[1].get_dsdl_signature():
error('Redefinition of data type ID: [%s] [%s]', first, second)
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uint8 field0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uint16 field0
20 changes: 15 additions & 5 deletions test/dsdl/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,25 @@ def test_duplicate_in_search_dir(self):

def test_redefinition_in_search_dir(self):
'''
Validate the parser does not allow redefinitions in the search dir
Validate that vendor-specific type IDs in [20000, 21000) are allowed to be
overridden in the search dir.
'''
ns0_dir = '{}/fake_dsdl/ns0_base/ns0'.format(os.path.dirname(__file__))
ns0_dir_with_redefinition = '{}/fake_dsdl/ns0_redefined/ns0'.format(os.path.dirname(__file__))
try:

parse_namespaces([ns0_dir], [ns0_dir_with_redefinition])

def test_non_vendor_redefinition_in_search_dir(self):
'''
Validate the parser does not allow redefinitions with differing signatures for
non-vendor type IDs (outside the [20000, 21000) vendor-override range).
'''
ns0_dir = '{}/fake_dsdl/ns0_nonvendor_base/ns0'.format(os.path.dirname(__file__))
ns0_dir_with_redefinition = '{}/fake_dsdl/ns0_nonvendor_redefined/ns0'.format(os.path.dirname(__file__))

with self.assertRaises(DsdlException) as context:
parse_namespaces([ns0_dir], [ns0_dir_with_redefinition])
self.assertTrue(False) # parse_namespaces should raise an exception, shouldn't get here
except DsdlException as e:
self.assertTrue(e.args[0].startswith("Redefinition of data type ID"))
self.assertTrue(context.exception.args[0].startswith("Redefinition of data type ID"))


if __name__ == '__main__':
Expand Down