diff --git a/docs/development/msp/README.md b/docs/development/msp/README.md index 7377eef84bc..cbf7814221d 100644 --- a/docs/development/msp/README.md +++ b/docs/development/msp/README.md @@ -277,7 +277,6 @@ When the MSP JSON specification changes, bump `msp_messages.json` version: [107 - MSP_COMP_GPS](#msp_comp_gps) [108 - MSP_ATTITUDE](#msp_attitude) [109 - MSP_ALTITUDE](#msp_altitude) -[110 - MSP_ANALOG](#msp_analog) [111 - MSP_RC_TUNING](#msp_rc_tuning) [113 - MSP_ACTIVEBOXES](#msp_activeboxes) [114 - MSP_MISC](#msp_misc) @@ -1960,21 +1959,6 @@ When the MSP JSON specification changes, bump `msp_messages.json` version: | `variometer` | `int16_t` | 2 | cm/s | Estimated vertical speed (`getEstimatedActualVelocity(Z)`) | | `baroAltitude` | `int32_t` | 4 | cm | Latest raw altitude from barometer (`baroGetLatestAltitude()`). 0 if `USE_BARO` disabled | -## `MSP_ANALOG (110 / 0x6e)` -**Description:** Provides analog sensor readings: battery voltage, current consumption (mAh), RSSI, and current draw (Amps). - -**Request Payload:** **None** - -**Reply Payload:** -|Field|C Type|Size (Bytes)|Units|Description| -|---|---|---|---|---| -| `vbat` | `uint8_t` | 1 | 0.1V | Battery voltage, scaled (`getBatteryVoltage() / 10`), constrained 0-255 | -| `mAhDrawn` | `uint16_t` | 2 | mAh | Consumed battery capacity (`getMAhDrawn()`), constrained 0-65535 | -| `rssi` | `uint16_t` | 2 | 0-1023 or % | Received Signal Strength Indicator (`getRSSI()`). Units depend on source | -| `amperage` | `int16_t` | 2 | 0.01A | Current draw (`getAmperage()`), constrained -32768 to 32767 | - -**Notes:** Superseded by `MSP2_INAV_ANALOG` which provides higher precision and more fields. - ## `MSP_RC_TUNING (111 / 0x6f)` **Description:** Retrieves RC tuning parameters (rates, expos, TPA) for the current control rate profile. @@ -2206,7 +2190,7 @@ When the MSP JSON specification changes, bump `msp_messages.json` version: | `batteryState` | `uint8_t` | 1 | [batteryState_e](https://github.com/iNavFlight/inav/wiki/Enums-reference#enum-batterystate_e) | Enum `batteryState_e` Current battery state (`getBatteryState()`, see `BATTERY_STATE_*`) | | `vbatActual` | `uint16_t` | 2 | 0.01V | Actual battery voltage (`getBatteryVoltage()`) | -**Notes:** Only available if `USE_DJI_HD_OSD` or `USE_MSP_DISPLAYPORT` is defined. Some values are duplicated from `MSP_ANALOG` / `MSP2_INAV_ANALOG` but potentially with different scaling/types. +**Notes:** Only available if `USE_DJI_HD_OSD` or `USE_MSP_DISPLAYPORT` is defined. Some values are duplicated from `MSP2_INAV_ANALOG` but potentially with different scaling/types. ## `MSP_VTXTABLE_BAND (137 / 0x89)` **Description:** Retrieves information about a specific VTX band from the VTX table. (Implementation missing in provided `fc_msp.c`) @@ -3172,7 +3156,7 @@ When the MSP JSON specification changes, bump `msp_messages.json` version: **Notes:** Requires `USE_OPFLOW`. ## `MSP2_INAV_ANALOG (8194 / 0x2002)` -**Description:** Provides detailed analog sensor readings, superseding `MSP_ANALOG` with higher precision and additional fields. +**Description:** Provides detailed analog sensor readings with higher precision and additional fields. **Request Payload:** **None** diff --git a/docs/development/msp/msp-message-routing-architecture.md b/docs/development/msp/msp-message-routing-architecture.md index 582f0e31984..831d26a3886 100644 --- a/docs/development/msp/msp-message-routing-architecture.md +++ b/docs/development/msp/msp-message-routing-architecture.md @@ -87,7 +87,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF - MSP_BOARD_INFO - Hardware identification - MSP_STATUS / MSP_STATUS_EX - Flight controller status - MSP_SENSOR_STATUS - Sensor health status -- MSP_ANALOG - Battery/voltage readings +- MSP2_INAV_ANALOG - Battery/voltage readings - MSP_ATTITUDE - Current attitude (roll/pitch/yaw) - MSP_ALTITUDE - Altitude readings - MSP_RAW_GPS - GPS data diff --git a/docs/development/msp/msp_messages.json b/docs/development/msp/msp_messages.json index 176833915ad..49b5ba579d5 100644 --- a/docs/development/msp/msp_messages.json +++ b/docs/development/msp/msp_messages.json @@ -1,7 +1,7 @@ { "version": { - "major": 2, - "minor": 1, + "major": 3, + "minor": 0, "patch": 0 }, "messages": { @@ -3928,42 +3928,6 @@ "notes": "", "description": "Provides estimated altitude, vertical speed (variometer), and raw barometric altitude." }, - "MSP_ANALOG": { - "code": 110, - "mspv": 1, - "replaced_by": ["MSP2_INAV_ANALOG"], - "request": null, - "reply": { - "payload": [ - { - "name": "vbat", - "ctype": "uint8_t", - "desc": "Battery voltage, scaled (`getBatteryVoltage() / 10`), constrained 0-255", - "units": "0.1V" - }, - { - "name": "mAhDrawn", - "ctype": "uint16_t", - "desc": "Consumed battery capacity (`getMAhDrawn()`), constrained 0-65535", - "units": "mAh" - }, - { - "name": "rssi", - "ctype": "uint16_t", - "desc": "Received Signal Strength Indicator (`getRSSI()`). Units depend on source", - "units": "0-1023 or %" - }, - { - "name": "amperage", - "ctype": "int16_t", - "desc": "Current draw (`getAmperage()`), constrained -32768 to 32767", - "units": "0.01A" - } - ] - }, - "notes": "Superseded by `MSP2_INAV_ANALOG` which provides higher precision and more fields.", - "description": "Provides analog sensor readings: battery voltage, current consumption (mAh), RSSI, and current draw (Amps)." - }, "MSP_RC_TUNING": { "code": 111, "mspv": 1, @@ -4602,7 +4566,7 @@ } ] }, - "notes": "Only available if `USE_DJI_HD_OSD` or `USE_MSP_DISPLAYPORT` is defined. Some values are duplicated from `MSP_ANALOG` / `MSP2_INAV_ANALOG` but potentially with different scaling/types.", + "notes": "Only available if `USE_DJI_HD_OSD` or `USE_MSP_DISPLAYPORT` is defined. Some values are duplicated from `MSP2_INAV_ANALOG` but potentially with different scaling/types.", "description": "Provides battery state information, formatted primarily for DJI FPV Goggles compatibility." }, "MSP_VTXTABLE_BAND": { @@ -6957,7 +6921,7 @@ ] }, "notes": "Requires `USE_CURRENT_METER`/`USE_ADC` for current-related fields; values fall back to zero when unavailable. Capacity fields are reported in the units configured by `batteryMetersConfig()->capacity_unit` (mAh or mWh).", - "description": "Provides detailed analog sensor readings, superseding `MSP_ANALOG` with higher precision and additional fields." + "description": "Provides detailed analog sensor readings with higher precision and additional fields." }, "MSP2_INAV_MISC": { "code": 8195, diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 1edf45749e2..5bf2420b76d 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -767,13 +767,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #endif break; - case MSP_ANALOG: - sbufWriteU8(dst, (uint8_t)constrain(getBatteryVoltage() / 10, 0, 255)); - sbufWriteU16(dst, (uint16_t)constrain(getMAhDrawn(), 0, 0xFFFF)); // milliamp hours drawn from battery - sbufWriteU16(dst, getRSSI()); - sbufWriteU16(dst, (int16_t)constrain(getAmperage(), -0x8000, 0x7FFF)); // send amperage in 0.01 A steps, range is -320A to 320A - break; - case MSP2_INAV_ANALOG: // Bit 1: battery full, Bit 2: use capacity threshold, Bit 3-4: battery state, Bit 5-8: battery cell count sbufWriteU8(dst, batteryWasFullWhenPluggedIn() | (batteryUsesCapacityThresholds() << 1) | (getBatteryState() << 2) | (getBatteryCellCount() << 4)); diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 6b4705a738c..7251b4706b4 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -240,7 +240,6 @@ #define MSP_COMP_GPS 107 //out message distance home, direction home #define MSP_ATTITUDE 108 //out message 2 angles 1 heading #define MSP_ALTITUDE 109 //out message altitude, variometer -#define MSP_ANALOG 110 //DEPRECATED in INAV 9.1 - use MSP2_INAV_ANALOG instead. Will be removed in INAV 10.0 #define MSP_RC_TUNING 111 //out message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID #define MSP_ACTIVEBOXES 113 //out message Active box flags (full width, more than 32 bits) #define MSP_MISC 114 //DEPRECATED in INAV 9.1 - use MSP2_INAV_MISC instead. Will be removed in INAV 10.0 diff --git a/src/main/target/SITL/serial_proxy.c b/src/main/target/SITL/serial_proxy.c index 281fefd3ede..9af469c3286 100644 --- a/src/main/target/SITL/serial_proxy.c +++ b/src/main/target/SITL/serial_proxy.c @@ -46,6 +46,7 @@ #include "drivers/time.h" #include "msp/msp_serial.h" #include "msp/msp_protocol.h" +#include "msp/msp_protocol_v2_inav.h" #include "common/crc.h" #include "rx/sim.h" @@ -524,7 +525,7 @@ static void mspRequestChannels(void) static void mspRequestRssi(void) { - mspSendCommand(MSP_ANALOG, NULL, 0); + mspSendCommand(MSP2_INAV_ANALOG, NULL, 0); } static void requestRXConfigState(void) @@ -549,10 +550,11 @@ static void processMessage(void) rxSimSetChannelValue(channels, count); } } - } else if ( code == MSP_ANALOG ) { + } else if ( code == MSP2_INAV_ANALOG ) { if ( reqCount > 0 ) reqCount--; - if ( message_length_received >= 7 ) { - rssi = *((uint16_t *)(&message_buffer[3])); + // RSSI is the last field of the MSP2_INAV_ANALOG reply payload (byte 22) + if ( message_length_received >= 24 ) { + rssi = *((uint16_t *)(&message_buffer[22])); rxSimSetRssi( rssi ); } } else if ( code == MSP_RX_CONFIG ) {