-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Mcu ID for vtx tables #361
Conversation
Addressed all of the review comments by removing dead code and adding check for conditional download of craft name if vtx tables are not supported. |
@kristjanbjarni Looks good 👍. Tested and works as expected. Could you squash please? |
There is still the issue that craft name isn't guaranteed to be unique just like model name. I think the best solution would be if each FC had a unique identifier. STM devices have a unique 96 bit id and it's available through MSP(MSP_UID). This could possibly simplify things and remove a lot of confusion. @mikeller Any thoughts on using the mcu id for this? |
@klutvott123 This is my first pull request so I am not really sure how I squash correctly, seems I messed it up?
I think the only reason for craft name not being unique is if somebody is using it for their pilot name. Since there already exists "Display name" for pilot name I would consider that to be erroneous usage of craft name. But maybe mcu id would be a better idea. |
@klutvott123: Good idea! Using the MCU id will solve this once and for all. |
All right let's do it! @kristjanbjarni I agree, but there will always be someone doing it wrong. By using the mcu id it should just work without the user having to keep track of all their model names and craft names. The code you have already written could easily be adapted to get the mcu id from the FC. Would you like to have a go at it? You had two commits on your branch and wanted to squash them into one commit. I assume your local branch now has the same commit history as the remote. 3 commits and a merge. To get it back to where you were before squashing/pushing/pulling/merging do you can do |
ee32561
to
703c7bf
Compare
@klutvott123 I fixed the commits. Yes I can look into changing the code to use MCU id instead. |
703c7bf
to
4b87e63
Compare
OK changed the name to use instead the MSP_UID as 24 hex characters to make it short and consistant. Tested a couple of quads, seemed to work just fine. |
4b87e63
to
b207b1f
Compare
Updated to use mcuId and fixed the order of the id to be the same order as mcu_id in CLI. I removed the check for apiVersion>1.042 since although you can't download the vtx tables under that version you should still be able to manually copy them to the transmitter and use them with the MCU id, right? |
@kristjanbjarni I think we should keep the check. Vtx tables were introduced in betaflight 4.1(api version 1.042) so I don't see why we would want to load vtx tables for firmware versions older than that. For that we have |
b207b1f
to
06b4e5d
Compare
@klutvott123 Added the check back in |
src/SCRIPTS/BF/ui_init.lua
Outdated
elseif not mcuId then | ||
if apiVersion >= 1.042 then | ||
lcd.drawText(6, radio.yMinLimit, "Waiting for unique device ID") | ||
getMCUId = getMCUId or assert(loadScript("mcu_id.lua"))() | ||
if getMCUId() then | ||
getMCUId = nil | ||
local vtxTables = loadScript("/BF/VTX/"..mcuId..".lua") | ||
if vtxTables and vtxTables() then | ||
vtxTablesReceived = true | ||
vtxTables = nil | ||
end | ||
collectgarbage() | ||
end | ||
else | ||
mcuId = model.getInfo().name | ||
end |
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.
Not sure if storing the model name in mcuId
is the best thing to do. I would combine the conditionals like
elseif apiVersion >= 1.042 and not mcuId then
and leave mcuId = nil
for older versions.
This would require loading vtx tables or defaults in vtx.lua based on apiVersion
like this:
local vtx_tables
if apiVersion >= 1.042 then
vtx_tables = assert(loadScript("/BF/VTX/"..mcuId..".lua"))()
else
vtx_tables = assert(loadScript("/BF/VTX/vtx_defaults.lua"))()
end
Can we change the message to just "Waiting for device ID"? That would make it fit nicely on the 128x64 screens too.
@kristjanbjarni Great! Just added some comments. We're almost there 😁 |
Reads MCU id from MSP and uses that unique id to store the vtx tables. This should solve the problem of using an incorrect vtx table when there are different crafts with different vtx hardware under the same model name.
06b4e5d
to
568595d
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
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.
👍
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.
Nice work, thanks @kristjanbjarni and @klutvott123, this will put this problem to an end once and for all.
Edited PR title to make it clear that we're using mcu ID and not craft name. Just to avoid any confusion |
Sorry, late to the party and got nothing useful to say, but thanks a lot!!! This is brilliant. |
Reads craft name from MSP and uses that name to store the vtx tables. If the craft name is empty it falls back on using the transmitter model name as before. This should solve the problem of using an incorrect vtx table when people have many different crafts with different vtx hardware under the same model name.