Skip to content

Commit c55788a

Browse files
committed
Merge branch 'master' of https://github.com/openlightingproject/ola into plugfest
2 parents 1f452d5 + 4690c7e commit c55788a

File tree

2 files changed

+68
-8
lines changed

2 files changed

+68
-8
lines changed

common/rdm/ResponderPersonality.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ Personality::Personality(uint16_t footprint, const string &description,
4747
: m_footprint(footprint),
4848
m_description(description),
4949
m_slot_data(slot_data) {
50+
if (m_slot_data.SlotCount() > m_footprint) {
51+
OLA_WARN << "Provided slot count of " << m_slot_data.SlotCount()
52+
<< " for personality \"" << description
53+
<< "\" is greater than it's footprint of " << m_footprint;
54+
}
5055
}
5156

5257
/**
@@ -90,8 +95,13 @@ uint8_t PersonalityManager::PersonalityCount() const {
9095
}
9196

9297
bool PersonalityManager::SetActivePersonality(uint8_t personality) {
93-
if (personality == 0 || personality > m_personalities->PersonalityCount())
98+
if (personality == 0 || personality > m_personalities->PersonalityCount()) {
99+
OLA_WARN << "Tried to set to invalid personality "
100+
<< static_cast<int>(personality) << ", only 1 to "
101+
<< static_cast<int>(m_personalities->PersonalityCount())
102+
<< " are valid";
94103
return false;
104+
}
95105
m_active_personality = personality;
96106
return true;
97107
}

tools/rdm/TestDefinitions.py

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,7 @@ class GetSlotInfo(OptionalParameterTestFixture):
25172517
"""Get SLOT_INFO."""
25182518
CATEGORY = TestCategory.DMX_SETUP
25192519
PID = 'SLOT_INFO'
2520+
REQUIRES = ['dmx_footprint']
25202521
PROVIDES = ['defined_slots', 'undefined_definition_slots',
25212522
'undefined_type_sec_slots']
25222523

@@ -2531,12 +2532,31 @@ def VerifyResult(self, response, fields):
25312532
self.SetProperty('undefined_type_sec_slots', [])
25322533
return
25332534

2534-
slots = [d['slot_offset'] for d in fields['slots']]
2535-
self.SetProperty('defined_slots', set(slots))
2535+
slots = {}
2536+
# check for duplicates
2537+
for d in fields['slots']:
2538+
if d['slot_offset'] in slots:
2539+
self.AddWarning('SLOT_INFO contained slot %d more than once' %
2540+
(d['slot_offset']))
2541+
else:
2542+
slots[d['slot_offset']] = d
2543+
2544+
self.SetProperty('defined_slots', set(slots.keys()))
25362545
undefined_definition_slots = []
25372546
undefined_type_sec_slots = []
25382547

2548+
# do more thorough checking of each (non-duplicate) slot
25392549
for slot in fields['slots']:
2550+
if slot['slot_offset'] > TestMixins.MAX_DMX_ADDRESS:
2551+
self.AddWarning(
2552+
"SLOT_INFO slot %d has an offset more than %d"
2553+
% (slot['slot_offset'], TestMixins.MAX_DMX_ADDRESS))
2554+
# footprint is 1 based, offset is 0 based
2555+
if slot['slot_offset'] >= self.Property('dmx_footprint'):
2556+
self.AddWarning(
2557+
"SLOT_INFO slot %d has an offset greater than or equal to the "
2558+
"personality's defined footprint (%d)"
2559+
% (slot['slot_offset'], self.Property('dmx_footprint')))
25402560
if slot['slot_type'] not in RDMConstants.SLOT_TYPE_TO_NAME:
25412561
self.AddWarning('Unknown slot type %d for slot %d' %
25422562
(slot['slot_type'], slot['slot_offset']))
@@ -2554,10 +2574,26 @@ def VerifyResult(self, response, fields):
25542574
undefined_definition_slots.append(slot['slot_offset'])
25552575
else:
25562576
# slot_label_id must reference a defined slot
2577+
# we've already validated the offset of the parent slot, so we don't
2578+
# need to check it again here
25572579
if slot['slot_label_id'] not in slots:
25582580
self.AddWarning(
25592581
'Slot %d is of type secondary and references an unknown slot %d'
25602582
% (slot['slot_offset'], slot['slot_label_id']))
2583+
else:
2584+
# the defined slot must be a primary slot
2585+
# slot exists, so find it
2586+
primary_slot = slots.get(slot['slot_label_id'], None)
2587+
# check the type of the parent slot
2588+
if primary_slot is None:
2589+
self.SetBroken('Failed to find primary slot for %d (%d)'
2590+
% (slot['slot_offset'], slot['slot_label_id']))
2591+
elif (primary_slot['slot_type'] !=
2592+
RDMConstants.SLOT_TYPES['ST_PRIMARY']):
2593+
self.AddWarning(
2594+
"Slot %d is of type secondary and references slot %d which "
2595+
"isn't a primary slot"
2596+
% (slot['slot_offset'], slot['slot_label_id']))
25612597
if slot['slot_type'] == RDMConstants.SLOT_TYPES['ST_SEC_UNDEFINED']:
25622598
undefined_type_sec_slots.append(slot['slot_offset'])
25632599

@@ -2737,7 +2773,7 @@ class GetDefaultSlotValues(OptionalParameterTestFixture):
27372773
"""Get DEFAULT_SLOT_VALUE."""
27382774
CATEGORY = TestCategory.DMX_SETUP
27392775
PID = 'DEFAULT_SLOT_VALUE'
2740-
REQUIRES = ['defined_slots']
2776+
REQUIRES = ['dmx_footprint', 'defined_slots']
27412777

27422778
def Test(self):
27432779
self.AddIfGetSupported(self.AckGetResult())
@@ -2751,17 +2787,31 @@ def VerifyResult(self, response, fields):
27512787
default_slots = set()
27522788

27532789
for slot in fields['slot_values']:
2790+
if slot['slot_offset'] > TestMixins.MAX_DMX_ADDRESS:
2791+
self.AddWarning(
2792+
"DEFAULT_SLOT_VALUE slot %d has an offset more than %d"
2793+
% (slot['slot_offset'], TestMixins.MAX_DMX_ADDRESS))
2794+
# footprint is 1 based, offset is 0 based
2795+
if slot['slot_offset'] >= self.Property('dmx_footprint'):
2796+
self.AddWarning(
2797+
"SLOT_INFO slot %d has an offset greater than or equal to the "
2798+
"personality's defined footprint (%d)"
2799+
% (slot['slot_offset'], self.Property('dmx_footprint')))
2800+
if slot['slot_offset'] in default_slots:
2801+
self.AddWarning(
2802+
"DEFAULT_SLOT_VALUE contained slot %d more than once" %
2803+
slot['slot_offset'])
27542804
if slot['slot_offset'] not in defined_slots:
27552805
self.AddWarning(
2756-
"DEFAULT_SLOT_VALUE contained slot %d, which wasn't in SLOT_INFO" %
2757-
slot['slot_offset'])
2806+
"DEFAULT_SLOT_VALUE contained slot %d, which wasn't in SLOT_INFO" %
2807+
slot['slot_offset'])
27582808
default_slots.add(slot['slot_offset'])
27592809

27602810
for slot_offset in defined_slots:
27612811
if slot_offset not in default_slots:
27622812
self.AddAdvisory(
2763-
"SLOT_INFO contained slot %d, which wasn't in DEFAULT_SLOT_VALUE" %
2764-
slot_offset)
2813+
"SLOT_INFO contained slot %d, which wasn't in DEFAULT_SLOT_VALUE" %
2814+
slot_offset)
27652815

27662816

27672817
class GetDefaultSlotValueWithData(TestMixins.GetWithDataMixin,

0 commit comments

Comments
 (0)