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)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user