mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(crsf): prevent USB CDC / Serial2 blocking and ignore 0x16 echo on GP1
This commit is contained in:
1 parent
14f9218a44
commit
50c1eb05b1
1 file changed
+19
-13
+19
-13
@@ -763,18 +763,21 @@ void traiterTelemetrieCRSF() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Relais de la télémétrie CRSF valide vers SteamFrame FPV (OSD via Radxa/USB)
|
// Relais de la télémétrie CRSF valide vers SteamFrame FPV (OSD via Radxa/USB)
|
||||||
size_t totalLen = (size_t)paquetLongueurAttendue + 2;
|
// Ne jamais relayer 0x16 (RC_CHANNELS_PACKED) si GP1 reçoit un écho des trames émises
|
||||||
if (totalLen <= 64) {
|
if (frameType != 0x16) {
|
||||||
char bufCrsf[140];
|
size_t totalLen = (size_t)paquetLongueurAttendue + 2;
|
||||||
memcpy(bufCrsf, "$CRSF,", 6);
|
if (totalLen <= 64) {
|
||||||
static const char HEX_DIGITS[] = "0123456789ABCDEF";
|
char bufCrsf[140];
|
||||||
for (size_t i = 0; i < totalLen; i++) {
|
memcpy(bufCrsf, "$CRSF,", 6);
|
||||||
uint8_t byteVal = crsfRxBuffer[i];
|
static const char HEX_DIGITS[] = "0123456789ABCDEF";
|
||||||
bufCrsf[6 + i * 2] = HEX_DIGITS[(byteVal >> 4) & 0x0F];
|
for (size_t i = 0; i < totalLen; i++) {
|
||||||
bufCrsf[6 + i * 2 + 1] = HEX_DIGITS[byteVal & 0x0F];
|
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) {
|
void emettreLigneCockpit(const char* ligne) {
|
||||||
Serial2.println(ligne);
|
int needed = (int)strlen(ligne) + 2;
|
||||||
if (cockpitEchoUSB) {
|
if (Serial2.availableForWrite() >= needed) {
|
||||||
|
Serial2.println(ligne);
|
||||||
|
}
|
||||||
|
if (cockpitEchoUSB && Serial && Serial.availableForWrite() >= needed) {
|
||||||
Serial.println(ligne);
|
Serial.println(ligne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user