-
- Notifications
You must be signed in to change notification settings - Fork 155
Updated screens to support u16 version of dtermSetpointWeight #140
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
Conversation
Weird that this is causing problems, the MSP implementation in the firmware should be using byte 10 as the value (only up to 254 obviously) if bytes 24 / 25 are not present. Is the lua script sending too many bytes? If so, this will potentially cause breakage in many other places in the future. |
The script receives the entire MSP frame and stores it in memory. Since the frame now contains two different versions of dterm setpoint weight (8 bit and 16 bit), it stores them both and sends them both back. Since the entire frame is returned, the 8 bit version is applied and subsequently the 16 bit version is applied on top. If the script only updates byte 10 and not bytes 24&25, the change applied by byte 10 is reverted. |
IMHO, having two interpretations of the same attribute that are applied in sequence by the FC seems a bit kludgy. If this is required, then the FC should not only look at the number of bytes but also create a guard that prevents the 16bit value from updating dtermSetpointWeight if the 8bit has already changed it. |
'Append new values at the end' is how MSP is designed to handle backwards compatibility. If the lua scripts don't do this properly, then that should probably be fixed. Forcing all clients to send the lower 8 bit of the previous value in the legacy field just to stop the firmware from reverting to the legacy behaviour and limit the value range for this parameter sounds like a very cumbersome approach to working around this shortcoming on the client. |
title = "Rates (2/2)", | ||
reboot = false, | ||
eepromWrite = true, | ||
minBytes = 23, |
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.
This will break backwards compatibility with older versions of the firmware. The minimum length for supported versions of the firmware is still 23 bytes.
-- THRESHOLD | ||
{ x = 144, y = 142, min = 20, max = 1000, vals = { 20, 21 }, to = MIDSIZE }, | ||
-- WEIGHT | ||
{ x = 348, y = 100, min = 0, max = 254, vals = { 10 }, to = MIDSIZE, scale = 100 }, |
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.
This should be kept in, to support older versions of the firmware.
@mikeller totally understand the 'append new values at the end' concept. Reducing minBytes to 23 is fine to keep support for older versions. The script will handle new bytes gracefully as they are added, so no problem there either. This situation, though, is unique because the same call is setting the same variable twice on the FC side. The FC should skip over setting it the second time if the first update already made a change. Also, say for example something new is added to MSP_SET_PID_ADVANCED that isn't already in the list, after the second setter for dtermSetpointWeight. In order to send the bytes following the second dtermSetpointWeight value, it too will also need to be sent back to the FC. The FC could handle this exception much more gracefully than the script. |
Otherwise, we will have to impose a maxBytes configuration which will prevent extensibility beyond 23 bytes. |
This call is by no means unique, this pattern is used in a number of other places, and it works well for all other configuration applications.
The flight controller handles this situation (there is no exception) exactly in the way that MSP was designed to work - it supports old applications sending only the first value, and new applications filling an arbitrary value into the slot for the first value, and sending the second value. I do not see what the problem is with what you describe - this is exactly how it is intended to be used - applications that update their support level to a newer version will have to do so by supporting all of the changes in between. Doing a 'pick and choose' of what changes they support won't work, but I don't think there is any expectation of that. Also, please note that blindly resending the frame that was received from the getter as parameters to the setter is only working by pure chance - there is no requirement that the frame formats are identical, and this isn't always the case. |
So what is the proposition? Hard stop sending bytes at 23? |
Btw, I was saying unique with respect to the scripts, not the protocol in general. |
My suggestion would be:
(4. can be made conditional to more than 23 bytes being received, but if that's too much cost in terms of script size it doesn't - the protocol is designed to gracefully ignore any bytes bejond the ones it knows about.) In general, I think it would be a an improvement over the current implementation to store |
5573672
to a75e2f9
Compare I updated it with a simple truncation of the output values to reduce the returned bytes to a max of 23.. think this will work okay? |
I'll take a look at seeing if those conditions can be applied, but it might be a little difficult as the screen is drawn as the reply is processed. |
a75e2f9
to ddd78e1
Compare
Corrects issue where dtermSetpointWeight cannot be updated due to data type change in the MSP definition in 3.4.