-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support manufacturer-specific parameters #47
base: master
Are you sure you want to change the base?
Conversation
type fix
header
add example for parameters
That's a great improvement. Thanks a lot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, some mostly trivial comments.
If you've implemented manufacturer specific PIDs, it would be good to get them added to the OLA PID store here:
http://rdm.openlighting.org/pid/manufacturer
Via:
https://github.com/OpenLightingProject/rdm-app/blob/master/data/pid_data.py#L1
Also N.B. that manufacturer specific PIDs are supposed to be unique per manufacturer, there should probably be a further warning so people don't reuse those themself!
Ideally somewhere you should check the manufacturer specific PIDs are in the correct range (0x8000-?).
Likewise if neither get nor set are supported.
src/DMXSerial2.cpp
Outdated
uint8_t sensorNr = _rdm.packet.Data[0]; | ||
if (sensorNr >= _initData->sensorsLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sensor numbers don't (currently) have to be contiguous IIRC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently the sensornumber is tied to the index in the sensors struct, so they will always be contiguous. Is there a reason to change this? E.g. are specific sensor numbers tied to specific sensor types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently the sensornumber is tied to the index in the sensors struct, so they will always be contiguous. Is there a reason to change this?
Fair point, no, no specific reason.
E.g. are specific sensor numbers tied to specific sensor types?
No there's no technical reason for it.
// 04.06.2023 Tim Nijssen: Add support for device-specific parameters | ||
// 05.06.2023 Tim Nijssen: integrate sensors example | ||
// 05.06.2023 Tim Nijssen: Add example for device-specific parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I genuinely don't know, and a lot of other stuff has been duplicated, but should these comments be in this ino file given they aren't relevant to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this one for @mathertel to decide on
Have you run the OLA RDM Tests against this too? |
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
Thanks for the review! I've processed most of your comments. I don't think the library should enforce using unique manufacturer-specific PIDs, but perhaps @mathertel could add a remark on this on his website, similarly to how he mentions unique manufacturer codes. Regarding the RDM test, working on it.. I'm having some python3 compatibility issues with running the tests. |
To do: add support for cold reset using RESET_DEVICE 0x01
(leave the warm reset RESET_DEVICE 0xFF to be user-defined) |
Great thanks.
I don't think the library can technically enforce it (unless PIDs had to be centrally registered in a list of defines or something), so a note/remark is all we can manage. It shouldn't actually be an issue until two individual devices meet. But I guess it will stop someone tripping themselves up by not appreciating the subtlety of how the system should work.
Our 0.10.9 release or the 0.10 or master branches should all solve the Python 3 issues. |
RDM test results:
|
Seems like we should add a catch for Set on the device label, return nack Write protected. The first fail is related to #46? |
found the problem with device labels. Writing up to 32 characters to EEPROM takes too long to send the response in time. I've moved the |
Test output:
notice that SetZeroDMXStartAddress was ran directly after SetFullSizeDeviceLabel, causing the timeout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more improvements and comments
if (updateEEPRom) | ||
_saveEEPRom(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also my comments in the main discussion.
src/DMXSerial2.cpp
Outdated
uint8_t sensorNr = _rdm.packet.Data[0]; | ||
if (sensorNr >= _initData->sensorsLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently the sensornumber is tied to the index in the sensors struct, so they will always be contiguous. Is there a reason to change this?
Fair point, no, no specific reason.
E.g. are specific sensor numbers tied to specific sensor types?
No there's no technical reason for it.
No, there's little point implementing a read only device label, but I think you've got to the bottom of that.
I thought we'd fixed that before a few times.
Agreed.
However I believe the correct fix is to implement an Ack Timer, which tells the controller to try again in a time you specify when the device should be ready. I think technically it shouldn't ack until it's actually completed the write (e.g. consider if there's a power cut before it finishes writing, the controller will think the write succeeded when it didn't. Obviously the balance is implementation complexity, so TBH as long as the DMX addresses ones work it may be easiest to just revert that change and put it in the two hard pile, or at least push it to another PR. |
Co-authored-by: Peter Newman <[email protected]>
Co-authored-by: Peter Newman <[email protected]>
You're right, I was misreading the test output.
I have one issue with the current (before my changes) method. Correct me if I'm wrong, but the delayed ACK message would be able to mangle up other communication in the universe happening at that time, right? Queued messages are not implemented right now, but how about this:
That way, we keep queued messages on the to-do list, but the controller can re-issue the SET and will receive an ACK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments/tweaks/improvements
} else { | ||
return false; | ||
} | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really, when we've not done anything. Won't that silence unknown PID type stuff?
*nackReason = E120_NR_SUB_DEVICE_OUT_OF_RANGE; | ||
} else { | ||
|
||
unsigned long seconds = millis() / 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's nice you've added some real data, I'd say the device hours field is where this value should be.
DEVICE_HOURS = "This parameter is used to retrieve or set the number of hours of operation the device has been in
use."
LAMP_HOURS = "This parameter is used to retrieve the number of lamp hours or to set the counter in the device to
a specific starting value."
rdm->Data[0] = (seconds & 0xff000000) >> 24; | ||
rdm->Data[1] = (seconds & 0x00ff0000) >> 16; | ||
rdm->Data[2] = (seconds & 0x0000ff00) >> 8; | ||
rdm->Data[3] = seconds & 0x000000ff; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the existing WRITEINT32 macro, or add one if its missing.
#if defined(SERIAL_DEBUG) | ||
Serial.println("no signal since 30 secs."); | ||
#endif | ||
// Show default color, when no data was received since 30 seconds or more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve English (probably not your issue), but would you mind fixing it elsewhere too please?
// Show default color, when no data was received since 30 seconds or more. | |
// Show default color, when no data was received for 30 seconds or more. |
|
||
} else { | ||
#if defined(SERIAL_DEBUG) | ||
Serial.println("no signal since 30 secs."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serial.println("no signal since 30 secs."); | |
Serial.println("no signal for 30 secs."); |
|
||
|
||
void loop() { | ||
// Calculate how long no data backet was received |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Calculate how long no data backet was received | |
// Find how long ago last data packet was received |
rdm->Data[0] = 0; | ||
rdm->Data[1] = 0; | ||
rdm->Data[2] = 2; | ||
rdm->Data[3] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the existing macro or add one if missing.
@@ -605,14 +622,15 @@ void DMXSerialClass2::term(void) | |||
void DMXSerialClass2::_processRDMMessage(byte CmdClass, uint16_t Parameter, bool8 handled, bool8 doRespond) | |||
{ | |||
uint16_t nackReason = E120_NR_UNKNOWN_PID; | |||
bool8 updateEEPRom = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I'd probably just camel case as updateEeprom, but if not, EEPROM is an acronym of acronyms, ROM is an acronym so itself should remain capitalised surely?
int16_t recordedValue = 0; | ||
bool8 res = false; | ||
if (_sensorFunc) { | ||
res = _sensorFunc(i, &sensorValue, &lowestValue, &highestValue, &recordedValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do something clever here if we're in 0xff mode. Ideally ANDing all the results, but obviously not the default initialisation...
Tracking failure would mean we could OR it I think.
You don't send it gratuitously, the controller will wait and then re-query it when the timeout has expired. IIRC queued messages are mostly about things like when I change the DMX address via a local UI, or temperature sensor readings and stuff.
Yeah I think that ought to work, but it will want a chunk more testing. Could I suggest reverting the changes around this from this PR, which is already quite big and complicated, and pushing it into a separate PR. Realistically there will be other equally buggy responders, so controllers probably deal with them already, which means this is mostly just about making us more compliant and allowing us to pass more tests. Which is a great thing to do, but it would be a shame if it delayed the addition of useful functionality to people in the mean time. |
Hi,
I've been working on implementing manufacturer-specific parameters (PID 0x8000- 0xFFDF), including E120_GET_COMMAND, E120_SET_COMMAND and E120_PARAMETER_DESCRIPTION.
Right now, the parameter values are simply taken from / dumped in a array of bytes and processed in a user-callback function. It's up to the user to store/process/whatever the values.