Improved failsafe state detection when TX module is not receiving input
This commit is contained in:
11
.vscode/c_cpp_properties.json
vendored
11
.vscode/c_cpp_properties.json
vendored
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
11
sbus.cpp
11
sbus.cpp
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user