From 98ba3943a7026638481f98a220333179e62cb824 Mon Sep 17 00:00:00 2001 From: Geoff Sim Date: Wed, 18 Sep 2024 13:05:55 +0100 Subject: [PATCH 1/3] The initial MSP_VARIANT message MUST be processed before the MSP_VTX_CONFIG message. If this does not happen, the VTX may not register properly with the FC and potentially lose further FC MSP VTX messages. This change will ensure the initial messages are processed in order. --- src/msp_displayport.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/msp_displayport.c b/src/msp_displayport.c index 23911f3..340ebcb 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -768,19 +768,22 @@ uint8_t msp_send_header_v2(uint16_t len, uint16_t msg) { return crc; } -void msp_cmd_tx() // send 3 commands to FC +void msp_cmd_tx() // Send between 1 and 5 commands to the FC { uint8_t i; - uint8_t const count = (fc_lock & FC_VTX_CONFIG_LOCK) ? 4 : 5; + + // Wait for variant, then config, then continue with status/rx/osd_canvas + uint8_t const start = (fc_lock & FC_VTX_CONFIG_LOCK) ? 2 : (fc_lock & FC_VARIANT_LOCK) ? 1 : 0; + uint8_t const end = (fc_lock & FC_VTX_CONFIG_LOCK) ? 5 : (fc_lock & FC_VARIANT_LOCK) ? 2 : 1; uint8_t const msp_cmd[5] = { MSP_FC_VARIANT, + MSP_GET_VTX_CONFIG, MSP_STATUS, MSP_RC, MSP_GET_OSD_CANVAS, - MSP_GET_VTX_CONFIG, }; - for (i = 0; i < count; i++) { + for (i = start; i < end; i++) { msp_send_command(0, MSP_HEADER_V1); msp_tx(0x00); // len msp_tx(msp_cmd[i]); // function From 4f23ca84c677c64d28a9ea419c055c86bd3f67c2 Mon Sep 17 00:00:00 2001 From: Geoff Sim Date: Wed, 18 Sep 2024 13:15:39 +0100 Subject: [PATCH 2/3] Update comment. --- src/msp_displayport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/msp_displayport.c b/src/msp_displayport.c index 340ebcb..5ca8bd2 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -768,7 +768,9 @@ uint8_t msp_send_header_v2(uint16_t len, uint16_t msg) { return crc; } -void msp_cmd_tx() // Send between 1 and 5 commands to the FC + // Send commands to the FC. + // Ensure VARIANT is processed first, followed by CONFIG, then the others. +void msp_cmd_tx() { uint8_t i; From 345bf3fbad93ee507c7b92d780d326197150f312 Mon Sep 17 00:00:00 2001 From: Geoff Sim Date: Wed, 18 Sep 2024 17:54:50 +0100 Subject: [PATCH 3/3] Only send MSP_GET_OSD_CANVAS requests to BTFL. A side effect is make VTX cms navigation less "sluggish". --- src/msp_displayport.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/msp_displayport.c b/src/msp_displayport.c index 5ca8bd2..27f5a52 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -772,11 +772,17 @@ uint8_t msp_send_header_v2(uint16_t len, uint16_t msg) { // Ensure VARIANT is processed first, followed by CONFIG, then the others. void msp_cmd_tx() { - uint8_t i; + uint8_t i, start = 0, count = 1; // Wait for variant, then config, then continue with status/rx/osd_canvas - uint8_t const start = (fc_lock & FC_VTX_CONFIG_LOCK) ? 2 : (fc_lock & FC_VARIANT_LOCK) ? 1 : 0; - uint8_t const end = (fc_lock & FC_VTX_CONFIG_LOCK) ? 5 : (fc_lock & FC_VARIANT_LOCK) ? 2 : 1; + if (fc_lock & FC_VARIANT_LOCK) { + start = 1; + if (fc_lock & FC_VTX_CONFIG_LOCK) { + start = 2; + count = (msp_cmp_fc_variant("BTFL")) ? 3 : 2; + } + } + uint8_t const msp_cmd[5] = { MSP_FC_VARIANT, MSP_GET_VTX_CONFIG, @@ -785,7 +791,7 @@ void msp_cmd_tx() MSP_GET_OSD_CANVAS, }; - for (i = start; i < end; i++) { + for (i = start; count--; i++) { msp_send_command(0, MSP_HEADER_V1); msp_tx(0x00); // len msp_tx(msp_cmd[i]); // function