From 01445e5aa988d5f3edb67d64ab7a70f577ab5b9e Mon Sep 17 00:00:00 2001 From: MrScothh <167884257+MrScothh@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:48:34 +0200 Subject: [PATCH] msp: put the host first in a serial passthrough serialPassthrough() does two things for whoever opened the session, and does them for its first port only: it looks there for the +++ that ends the session, and when that port is USB it mirrors the host's line coding onto the other one. The CLI passes the host first. The MSP passthrough passed it second, so a session opened with MSP_SET_PASSTHROUGH could not be closed from the host, and could not change the rate of the port it opened. On a bench, a tool configuring an SRXL2 ESC through MSP_SET_PASSTHROUGH left the board stuck in the passthrough after every session: the +++ reached the ESC's wire and came back as its echo, but the board never left the loop and answered no MSP until it was power cycled. With the host first the same session ends on +++ and the board carries on. The rate the host asks for is now mirrored as well, which is what lets such a tool negotiate an SRXL2 bus up to 400000. The mirror is baselined on the host's line coding when the session starts and only follows changes made during it, so opening a session does not touch the rate of the port being bridged. --- src/main/fc/fc_msp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index d00984f2d85..b241c0df69b 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -223,7 +223,13 @@ static void mspSerialPassthroughFn(serialPort_t *serialPort) { serialPort_t *passthroughPort = mspFindPassthroughSerialPort(); if (passthroughPort && serialPort) { - serialPassthrough(passthroughPort, serialPort, NULL, NULL); + // The port the request came in on goes first, as it does in the CLI. Both of the + // things serialPassthrough() does for whoever opened the session are done for its + // first port only: the +++ that ends the session is looked for there, and a USB + // host's line coding is mirrored onto the other port from there. Passed the other + // way round, a session opened over MSP could not be closed and could not raise the + // rate of the port it opened, which is what an SRXL2 ESC negotiates up to 400000 + serialPassthrough(serialPort, passthroughPort, NULL, NULL); } }