Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8e43ab7
Improve a bit of documentation
peternewman Nov 25, 2024
4ccaefe
Add the E1.37-5 PIDs
peternewman Nov 25, 2024
33477af
Report which string field is missing its max size
peternewman Nov 25, 2024
a9fa3f7
Correct the manufacturer URL PID value
peternewman Nov 25, 2024
d301235
Set the maximum max size supported by our proto for unconstrained RDM…
peternewman Nov 25, 2024
dd578ed
Add the E1.37-5 enums and some helpers
peternewman Nov 25, 2024
c9eb7d9
Add the E1.37-5 URL PIDs to the dummy responder
peternewman Nov 25, 2024
438a29c
Collect some of the new E1.37-5 URLs in the model collector
peternewman Nov 26, 2024
00ee4de
Add some initial E1.37-5 tests and a new GetURLMixin
peternewman Dec 1, 2024
ff7b6f4
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Feb 3, 2025
538ae61
Updated manufacturer names
peternewman Feb 3, 2025
31cd695
Add (or re-add) the manufacturer names stuff to handle all manufactur…
peternewman Feb 3, 2025
b95e9f2
Add and test a StrNLength function
peternewman Mar 2, 2025
76e069b
Ensure the basic GET and SET tests have a description too
peternewman Mar 2, 2025
eb86898
Fix a minor typo
peternewman Mar 2, 2025
4764f3f
Improve the documentation
peternewman Mar 2, 2025
f66052e
Fix a minor typo
peternewman Mar 3, 2025
f8ca58d
Comment out the test description when the rest of the test is commented
peternewman Mar 3, 2025
c27e5fa
Add ExtractString helper, ResponderTagSet and associated E1.37-5 help…
peternewman Mar 3, 2025
2d982b0
Add some of the simpler E1.37-5 tests
peternewman Mar 3, 2025
1bc0002
Fix the AllSubDevicesGetCheckTag syntax
peternewman Mar 3, 2025
21a6e1d
Ensure we don't reply to GET LIST_TAGS with extra data
peternewman Mar 3, 2025
064fb4c
Fix some flake8 and isort errors
peternewman Mar 3, 2025
8511be8
Add the TEST_DATA PID and some responder tests for it
peternewman Mar 8, 2025
cc39728
Add the missing header functions
peternewman Mar 8, 2025
0cc7149
Fix some Python 3 bugs with the RDM tests. Closes #1993 and #1969
peternewman Mar 9, 2025
22dbe7b
Fix a flake8 error
peternewman Mar 9, 2025
6e404bd
Add some GET tests for TEST_DATA
peternewman Mar 9, 2025
1f452d5
Add the missing ranges so labels are usable and add a test to catch i…
peternewman Mar 9, 2025
c55788a
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 9, 2025
63b4eca
Fix the supported params test
peternewman Mar 9, 2025
92b0cd4
Fix some comments
peternewman Mar 9, 2025
7943d7a
Fix a flake8 error
peternewman Mar 9, 2025
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
47 changes: 46 additions & 1 deletion common/rdm/DummyResponder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ const ResponderOps<DummyResponder>::ParamHandler
{ PID_DNS_NAME_SERVER,
&DummyResponder::GetDNSNameServer,
NULL},
{ PID_MANUFACTURER_URL,
&DummyResponder::GetManufacturerURL,
NULL},
{ PID_PRODUCT_URL,
&DummyResponder::GetProductURL,
NULL},
{ PID_FIRMWARE_URL,
&DummyResponder::GetFirmwareURL,
NULL},
{ PID_TEST_DATA,
&DummyResponder::GetTestData,
&DummyResponder::SetTestData},
{ OLA_MANUFACTURER_PID_CODE_VERSION,
&DummyResponder::GetOlaCodeVersion,
NULL},
Expand Down Expand Up @@ -225,7 +237,7 @@ RDMResponse *DummyResponder::GetParamDescription(
RDMResponse *DummyResponder::GetDeviceInfo(const RDMRequest *request) {
return ResponderHelper::GetDeviceInfo(
request, OLA_DUMMY_DEVICE_MODEL,
PRODUCT_CATEGORY_OTHER, 3,
PRODUCT_CATEGORY_OTHER, 4,
&m_personality_manager,
m_start_address,
0, m_sensors.size());
Expand Down Expand Up @@ -435,6 +447,39 @@ RDMResponse *DummyResponder::GetDNSNameServer(
m_network_manager.get());
}

RDMResponse *DummyResponder::GetManufacturerURL(
const RDMRequest *request) {
return ResponderHelper::GetString(
// TODO(Peter): This field's length isn't limited in the spec
request, OLA_MANUFACTURER_URL, 0, UINT8_MAX);
}

RDMResponse *DummyResponder::GetProductURL(
const RDMRequest *request) {
return ResponderHelper::GetString(
request,
"https://openlighting.org/rdm-tools/dummy-responders/",
0,
UINT8_MAX); // TODO(Peter): This field's length isn't limited in the spec
}

RDMResponse *DummyResponder::GetFirmwareURL(
const RDMRequest *request) {
return ResponderHelper::GetString(
request,
"https://github.com/OpenLightingProject/ola",
0,
UINT8_MAX); // TODO(Peter): This field's length isn't limited in the spec
}

RDMResponse *DummyResponder::GetTestData(const RDMRequest *request) {
return ResponderHelper::GetTestData(request);
}

RDMResponse *DummyResponder::SetTestData(const RDMRequest *request) {
return ResponderHelper::SetTestData(request);
}

RDMResponse *DummyResponder::GetOlaCodeVersion(
const RDMRequest *request) {
return ResponderHelper::GetString(request, VERSION);
Expand Down
11 changes: 11 additions & 0 deletions common/rdm/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ test_programs += \
common/rdm/RDMHelperTester \
common/rdm/RDMMessageTester \
common/rdm/RDMReplyTester \
common/rdm/ResponderHelperTester \
common/rdm/ResponderTagSetTester \
common/rdm/UIDAllocatorTester \
common/rdm/UIDTester

Expand Down Expand Up @@ -142,6 +144,15 @@ common_rdm_RDMCommandSerializerTester_SOURCES = \
common_rdm_RDMCommandSerializerTester_CXXFLAGS = $(COMMON_TESTING_FLAGS)
common_rdm_RDMCommandSerializerTester_LDADD = $(COMMON_TESTING_LIBS)

common_rdm_ResponderHelperTester_SOURCES = common/rdm/ResponderHelperTest.cpp
common_rdm_ResponderHelperTester_CXXFLAGS = $(COMMON_TESTING_FLAGS)
common_rdm_ResponderHelperTester_LDADD = $(COMMON_TESTING_LIBS)

common_rdm_ResponderTagSetTester_SOURCES = \
common/rdm/ResponderTagSetTest.cpp
common_rdm_ResponderTagSetTester_CXXFLAGS = $(COMMON_TESTING_FLAGS)
common_rdm_ResponderTagSetTester_LDADD = $(COMMON_TESTING_LIBS)

common_rdm_QueueingRDMControllerTester_SOURCES = \
common/rdm/QueueingRDMControllerTest.cpp \
common/rdm/TestHelper.h
Expand Down
1 change: 1 addition & 0 deletions common/rdm/OpenLightingEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ namespace ola {
namespace rdm {

const char OLA_MANUFACTURER_LABEL[] = "Open Lighting Project";
const char OLA_MANUFACTURER_URL[] = "https://openlighting.org/";
} // namespace rdm
} // namespace ola
5 changes: 3 additions & 2 deletions common/rdm/PidStoreLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const FieldDescriptor *PidStoreLoader::IntegerFieldToFieldDescriptor(
intervals.push_back(interval);
}

// if not intervals were specified, we automatically add all the labels
// if no intervals were specified, we automatically add all the labels
bool intervals_empty = intervals.empty();

for (int i = 0; i < field.label_size(); ++i) {
Expand Down Expand Up @@ -550,7 +550,8 @@ const FieldDescriptor *PidStoreLoader::StringFieldToFieldDescriptor(
min = field.min_size();

if (!field.has_max_size()) {
OLA_WARN << "String field failed to specify max size";
OLA_WARN << "String field " << field.name()
<< " failed to specify max size";
return NULL;
}
return new ola::messaging::StringFieldDescriptor(
Expand Down
40 changes: 40 additions & 0 deletions common/rdm/RDMHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,5 +1146,45 @@ string UnitToString(uint8_t unit) {
return str.str();
}
}


/**
* Convert a uint8_t representing a shipping lock state to a human-readable string.
* @param shipping_lock_state the shipping lock state value
*/
string ShippingLockStateToString(uint8_t shipping_lock_state) {
switch (shipping_lock_state) {
case SHIPPING_LOCK_STATE_UNLOCKED:
return "Unlocked";
case SHIPPING_LOCK_STATE_LOCKED:
return "Locked";
case SHIPPING_LOCK_STATE_PARTIALLY_LOCKED:
return "Partially locked";
default:
ostringstream str;
str << "Unknown, was " << static_cast<int>(shipping_lock_state);
return str.str();
}
}


/**
* Safely convert a uint8_t to a rdm_shipping_lock_state
*/
bool UIntToShippingLockState(uint8_t state, rdm_shipping_lock_state *shipping_lock_state) {
switch (state) {
case SHIPPING_LOCK_STATE_UNLOCKED:
*shipping_lock_state = SHIPPING_LOCK_STATE_UNLOCKED;
return true;
case SHIPPING_LOCK_STATE_LOCKED:
*shipping_lock_state = SHIPPING_LOCK_STATE_LOCKED;
return true;
case SHIPPING_LOCK_STATE_PARTIALLY_LOCKED:
*shipping_lock_state = SHIPPING_LOCK_STATE_PARTIALLY_LOCKED;
return true;
default:
return false;
}
}
} // namespace rdm
} // namespace ola
134 changes: 134 additions & 0 deletions common/rdm/ResponderHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ using ola::network::InterfacePicker;
using ola::network::IPV4Address;
using ola::network::MACAddress;
using ola::network::NetworkToHost;
using ola::strings::StrNLength;
using std::min;
using std::string;
using std::vector;
Expand Down Expand Up @@ -79,6 +80,24 @@ bool ResponderHelper::ExtractUInt32(const RDMRequest *request,
return GenericExtractValue(request, output);
}

bool ResponderHelper::ExtractString(const RDMRequest *request,
std::string *output,
uint8_t max_length) {
if (request->ParamDataSize() > max_length) {
return false;
}

size_t len = (size_t) request->ParamDataSize();
if (request->ParamData() != NULL) {
// StrNLength ensures we stop on the first null we hit
len = StrNLength(reinterpret_cast<const char*>(request->ParamData()),
min(len, (size_t) max_length));
}
const string value(reinterpret_cast<const char*>(request->ParamData()), len);
*output = value;
return true;
}


RDMResponse *ResponderHelper::GetDeviceInfo(
const RDMRequest *request,
Expand Down Expand Up @@ -1053,6 +1072,121 @@ RDMResponse *ResponderHelper::GetIPV4Address(
queued_message_count);
}

RDMResponse *ResponderHelper::GetTestData(
const RDMRequest *request,
uint8_t queued_message_count) {
uint16_t pattern_length;
if (!ExtractUInt16(request, &pattern_length)) {
return NackWithReason(request, NR_FORMAT_ERROR, queued_message_count);
}

if (pattern_length > MAX_RDM_TEST_DATA_PATTERN_LENGTH) {
return NackWithReason(request, NR_DATA_OUT_OF_RANGE, queued_message_count);
}

uint8_t pattern_data[pattern_length];

for (unsigned int i = 0; i < pattern_length; i++) {
// Need to return values 0-255, 0... etc
pattern_data[i] = i % (UINT8_MAX + 1);
}

return GetResponseFromData(
request,
reinterpret_cast<uint8_t*>(&pattern_data),
sizeof(pattern_data),
RDM_ACK,
queued_message_count);
}

RDMResponse *ResponderHelper::SetTestData(
const RDMRequest *request,
uint8_t queued_message_count) {
return GetResponseFromData(
request,
request->ParamData(),
request->ParamDataSize(),
RDM_ACK,
queued_message_count);
}

RDMResponse *ResponderHelper::GetListTags(
const RDMRequest *request,
const TagSet *tag_set,
uint8_t queued_message_count) {
if (request->ParamDataSize()) {
return NackWithReason(request, NR_FORMAT_ERROR, queued_message_count);
}

uint8_t tags[(MAX_RDM_STRING_LENGTH + 1) * tag_set->Size()];
unsigned int pdl = sizeof(tags);

tag_set->Pack(tags, &pdl);

return GetResponseFromData(request, tags, pdl,
RDM_ACK, queued_message_count);
}

RDMResponse *ResponderHelper::SetAddTag(
const RDMRequest *request,
TagSet *tag_set,
uint8_t queued_message_count) {
string tag;
if (!ResponderHelper::ExtractString(request, &tag)) {
return NackWithReason(request, NR_FORMAT_ERROR, queued_message_count);
}

tag_set->AddTag(tag);

return ResponderHelper::EmptySetResponse(request, queued_message_count);
}

RDMResponse *ResponderHelper::SetRemoveTag(
const RDMRequest *request,
TagSet *tag_set,
uint8_t queued_message_count) {
string tag;
if (!ResponderHelper::ExtractString(request, &tag)) {
return NackWithReason(request, NR_FORMAT_ERROR, queued_message_count);
}

if (tag_set->Contains(tag)) {
tag_set->RemoveTag(tag);

return ResponderHelper::EmptySetResponse(request, queued_message_count);
} else {
return NackWithReason(request, NR_DATA_OUT_OF_RANGE, queued_message_count);
}
}

RDMResponse *ResponderHelper::GetCheckTag(
const RDMRequest *request,
const TagSet *tag_set,
uint8_t queued_message_count) {
string tag;
if (!ResponderHelper::ExtractString(request, &tag)) {
return NackWithReason(request, NR_FORMAT_ERROR, queued_message_count);
}

uint8_t param = tag_set->Contains(tag) ? 1 : 0;

return GetResponseFromData(request, &param, sizeof(param),
RDM_ACK, queued_message_count);
}

RDMResponse *ResponderHelper::SetClearTags(
const RDMRequest *request,
TagSet *tag_set,
uint8_t queued_message_count) {
if (request->ParamDataSize()) {
return NackWithReason(request, NR_FORMAT_ERROR, queued_message_count);
}

tag_set->Clear();

return ResponderHelper::EmptySetResponse(request, queued_message_count);
}

/**
* @brief Handle a request that returns a string
* @note this truncates the string to max_length
Expand Down
Loading
Loading