diff --git a/g29_crsf.ino b/g29_crsf.ino index 35d7a42..2dd4621 100644 --- a/g29_crsf.ino +++ b/g29_crsf.ino @@ -763,18 +763,21 @@ void traiterTelemetrieCRSF() { } // Relais de la télémétrie CRSF valide vers SteamFrame FPV (OSD via Radxa/USB) - size_t totalLen = (size_t)paquetLongueurAttendue + 2; - if (totalLen <= 64) { - char bufCrsf[140]; - memcpy(bufCrsf, "$CRSF,", 6); - static const char HEX_DIGITS[] = "0123456789ABCDEF"; - for (size_t i = 0; i < totalLen; i++) { - uint8_t byteVal = crsfRxBuffer[i]; - bufCrsf[6 + i * 2] = HEX_DIGITS[(byteVal >> 4) & 0x0F]; - bufCrsf[6 + i * 2 + 1] = HEX_DIGITS[byteVal & 0x0F]; + // Ne jamais relayer 0x16 (RC_CHANNELS_PACKED) si GP1 reçoit un écho des trames émises + if (frameType != 0x16) { + size_t totalLen = (size_t)paquetLongueurAttendue + 2; + if (totalLen <= 64) { + char bufCrsf[140]; + memcpy(bufCrsf, "$CRSF,", 6); + static const char HEX_DIGITS[] = "0123456789ABCDEF"; + for (size_t i = 0; i < totalLen; i++) { + uint8_t byteVal = crsfRxBuffer[i]; + bufCrsf[6 + i * 2] = HEX_DIGITS[(byteVal >> 4) & 0x0F]; + bufCrsf[6 + i * 2 + 1] = HEX_DIGITS[byteVal & 0x0F]; + } + bufCrsf[6 + totalLen * 2] = '\0'; + emettreLigneCockpit(bufCrsf); } - bufCrsf[6 + totalLen * 2] = '\0'; - emettreLigneCockpit(bufCrsf); } } @@ -807,8 +810,11 @@ void traiterTelemetrieCRSF() { } void emettreLigneCockpit(const char* ligne) { - Serial2.println(ligne); - if (cockpitEchoUSB) { + int needed = (int)strlen(ligne) + 2; + if (Serial2.availableForWrite() >= needed) { + Serial2.println(ligne); + } + if (cockpitEchoUSB && Serial && Serial.availableForWrite() >= needed) { Serial.println(ligne); } }