diff --git a/src/main/io/displayport_msp.c b/src/main/io/displayport_msp.c index 9d7ce61c54..8140d91295 100644 --- a/src/main/io/displayport_msp.c +++ b/src/main/io/displayport_msp.c @@ -54,7 +54,7 @@ static int output(displayPort_t *displayPort, uint8_t cmd, uint8_t *buf, int len return 0; } #endif - return mspSerialPush(cmd, buf, len, MSP_DIRECTION_REPLY); + return mspSerialPush(displayPortProfileMsp()->displayPortSerial, cmd, buf, len, MSP_DIRECTION_REPLY); } static int heartbeat(displayPort_t *displayPort) diff --git a/src/main/msp/msp_serial.c b/src/main/msp/msp_serial.c index 5134d1fd57..31a21ed124 100644 --- a/src/main/msp/msp_serial.c +++ b/src/main/msp/msp_serial.c @@ -34,7 +34,6 @@ #include "drivers/system.h" -#include "io/serial.h" #include "io/displayport_msp.h" #include "msp/msp.h" @@ -69,12 +68,6 @@ void mspSerialAllocatePorts(void) bool sharedWithTelemetry = isSerialPortShared(portConfig, FUNCTION_MSP, TELEMETRY_PORT_FUNCTIONS_MASK); resetMspPort(mspPort, serialPort, sharedWithTelemetry); -#ifdef USE_MSP_DISPLAYPORT - if (serialPort->identifier == displayPortProfileMsp()->displayPortSerial) { - mspPort->isDisplayPort = true; - } -#endif - portIndex++; } @@ -565,14 +558,15 @@ void mspSerialInit(void) mspSerialAllocatePorts(); } -int mspSerialPush(uint8_t cmd, uint8_t *data, int datalen, mspDirection_e direction) +int mspSerialPush(serialPortIdentifier_e port, uint8_t cmd, uint8_t *data, int datalen, mspDirection_e direction) { int ret = 0; for (int portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) { mspPort_t * const mspPort = &mspPorts[portIndex]; - if (!mspPort->port || !mspPort->isDisplayPort) { + // XXX Kludge!!! Avoid zombie VCP port (avoid VCP entirely for now) + if (!mspPort->port || mspPort->port->identifier == SERIAL_PORT_USB_VCP || (port != SERIAL_PORT_NONE && mspPort->port->identifier != port)) { continue; } diff --git a/src/main/msp/msp_serial.h b/src/main/msp/msp_serial.h index f1d27efbe8..b493940daa 100644 --- a/src/main/msp/msp_serial.h +++ b/src/main/msp/msp_serial.h @@ -21,6 +21,9 @@ #pragma once #include "drivers/time.h" + +#include "io/serial.h" + #include "msp/msp.h" // Each MSP port requires state and a receive buffer, revisit this default if someone needs more than 3 MSP ports. @@ -111,7 +114,6 @@ typedef struct mspPort_s { uint8_t checksum2; bool sharedWithTelemetry; mspDescriptor_t descriptor; - bool isDisplayPort; } mspPort_t; void mspSerialInit(void); @@ -120,5 +122,5 @@ void mspSerialProcess(mspEvaluateNonMspData_e evaluateNonMspData, mspProcessComm void mspSerialAllocatePorts(void); void mspSerialReleasePortIfAllocated(struct serialPort_s *serialPort); void mspSerialReleaseSharedTelemetryPorts(void); -int mspSerialPush(uint8_t cmd, uint8_t *data, int datalen, mspDirection_e direction); +int mspSerialPush(serialPortIdentifier_e port, uint8_t cmd, uint8_t *data, int datalen, mspDirection_e direction); uint32_t mspSerialTxBytesFree(void); diff --git a/src/main/sensors/current.c b/src/main/sensors/current.c index ad6dbcf541..269c18ab2f 100644 --- a/src/main/sensors/current.c +++ b/src/main/sensors/current.c @@ -279,7 +279,7 @@ void currentMeterMSPRefresh(timeUs_t currentTimeUs) if (cmp32(currentTimeUs, streamRequestAt) > 0) { streamRequestAt = currentTimeUs + ((1000 * 1000) / 10); // 10hz - mspSerialPush(MSP_ANALOG, NULL, 0, MSP_DIRECTION_REQUEST); + mspSerialPush(SERIAL_PORT_NONE, MSP_ANALOG, NULL, 0, MSP_DIRECTION_REQUEST); } }