Improved failsafe state detection when TX module is not receiving input

This commit is contained in:
Pawel Spychalski (DzikuVx)
2018-01-03 19:41:59 +01:00
parent 55964dc330
commit 365df5b269
3 changed files with 14 additions and 15 deletions

View File

@@ -3,19 +3,12 @@
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries",
"C:\\Users\\pspyc\\Documents\\Arduino\\libraries",
"C:\\Users\\pspyc\\Documents\\Arduino\\libraries\\PPMReader"
"${workspaceRoot}"
],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries",
"${workspaceRoot}",
"C:\\Users\\pspyc\\Documents\\Arduino\\libraries"
"${workspaceRoot}"
]
},
"intelliSenseMode": "msvc-x64"

View File

@@ -323,8 +323,11 @@ void loop(void)
int8_t frameToSend = getFrameToTransmit(&qsp);
#ifndef FORCE_TX_WITHOUT_INPUT
//FIXME detect if taranis is really transmitting here
if (frameToSend == QSP_FRAME_RC_DATA && false) {
/*
* If module is not receiving data from radio, do not send RC DATA
* This is the only way to trigger failsafe in that case
*/
if (frameToSend == QSP_FRAME_RC_DATA && !isReceivingSbus(&sbusInput)) {
frameToSend = -1;
}
#endif

View File

@@ -12,6 +12,8 @@
#define SBUS_STATE_FAILSAFE 0x08
#define SBUS_STATE_SIGNALLOSS 0x04
#define SBUS_IS_RECEIVING_THRESHOLD 250 //If there is no SBUS input for 250ms, assume connection is broken
/*
Precomputed mapping from 990-2010 to 173:1811
equivalent to
@@ -22,6 +24,7 @@ int mapChannelToSbus(int in) {
}
int mapSbusToChannel(int in) {
//TODO, speed up this processing
return map(in, 173, 1811, 990, 2010);
}
@@ -121,12 +124,12 @@ void sbusRead(HardwareSerial &_serial, SbusInput_t *sbusInput) {
sbusInput->channels[channelIndex] = mapSbusToChannel(sbusInput->channels[channelIndex]);
}
//FIXME remove this debug
static uint32_t prev = 0;
sbusInput->lastChannelReceivedAt = millis();
Serial.println(sbusInput->lastChannelReceivedAt - prev);
prev = sbusInput->lastChannelReceivedAt;
}
}
}
bool isReceivingSbus(SbusInput_t *sbusInput) {
return !(millis() - sbusInput->lastChannelReceivedAt > SBUS_IS_RECEIVING_THRESHOLD);
}