mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-10 18:24:11 +01:00
Make sure all receiver drivers return correct constants for invalid channels.
This commit is contained in:
parent
51967ae63f
commit
89e640ae7f
@ -222,8 +222,6 @@ static void manualControlTask(void *parameters)
|
|||||||
// until we decide to go to failsafe
|
// until we decide to go to failsafe
|
||||||
if(cmd.Channel[n] == PIOS_RCVR_TIMEOUT)
|
if(cmd.Channel[n] == PIOS_RCVR_TIMEOUT)
|
||||||
valid_input_detected = false;
|
valid_input_detected = false;
|
||||||
else if (cmd.Channel[n] == PIOS_RCVR_INVALID)
|
|
||||||
scaledChannel[n] = 0;
|
|
||||||
else
|
else
|
||||||
scaledChannel[n] = scaleChannel(cmd.Channel[n], settings.ChannelMax[n], settings.ChannelMin[n], settings.ChannelNeutral[n]);
|
scaledChannel[n] = scaleChannel(cmd.Channel[n], settings.ChannelMax[n], settings.ChannelMin[n], settings.ChannelNeutral[n]);
|
||||||
}
|
}
|
||||||
@ -235,17 +233,17 @@ static void manualControlTask(void *parameters)
|
|||||||
settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE ||
|
settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE ||
|
||||||
settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE ||
|
settings.ChannelGroups[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE ||
|
||||||
// Check all channel mappings are valid
|
// Check all channel mappings are valid
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL] == PIOS_RCVR_INVALID ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL] == (uint16_t) PIOS_RCVR_INVALID ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] == PIOS_RCVR_INVALID ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] == (uint16_t) PIOS_RCVR_INVALID ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] == PIOS_RCVR_INVALID ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] == (uint16_t) PIOS_RCVR_INVALID ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] == PIOS_RCVR_INVALID ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] == (uint16_t) PIOS_RCVR_INVALID ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == PIOS_RCVR_INVALID ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t) PIOS_RCVR_INVALID ||
|
||||||
// Check the driver is exists
|
// Check the driver is exists
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL] == PIOS_RCVR_NODRIVER ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL] == (uint16_t) PIOS_RCVR_NODRIVER ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] == PIOS_RCVR_NODRIVER ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_PITCH] == (uint16_t) PIOS_RCVR_NODRIVER ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] == PIOS_RCVR_NODRIVER ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_YAW] == (uint16_t) PIOS_RCVR_NODRIVER ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] == PIOS_RCVR_NODRIVER ||
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE] == (uint16_t) PIOS_RCVR_NODRIVER ||
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == PIOS_RCVR_NODRIVER) {
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t) PIOS_RCVR_NODRIVER) {
|
||||||
|
|
||||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL);
|
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL);
|
||||||
cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE;
|
cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE;
|
||||||
|
@ -211,12 +211,12 @@ static int32_t PIOS_PPM_Get(uint32_t rcvr_id, uint8_t channel)
|
|||||||
|
|
||||||
if (!PIOS_PPM_validate(ppm_dev)) {
|
if (!PIOS_PPM_validate(ppm_dev)) {
|
||||||
/* Invalid device specified */
|
/* Invalid device specified */
|
||||||
return -1;
|
return PIOS_RCVR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel >= PIOS_PPM_IN_MAX_NUM_CHANNELS) {
|
if (channel >= PIOS_PPM_IN_MAX_NUM_CHANNELS) {
|
||||||
/* Channel out of range */
|
/* Channel out of range */
|
||||||
return -1;
|
return PIOS_RCVR_INVALID;
|
||||||
}
|
}
|
||||||
return ppm_dev->CaptureValue[channel];
|
return ppm_dev->CaptureValue[channel];
|
||||||
}
|
}
|
||||||
|
@ -181,12 +181,12 @@ static int32_t PIOS_PWM_Get(uint32_t rcvr_id, uint8_t channel)
|
|||||||
|
|
||||||
if (!PIOS_PWM_validate(pwm_dev)) {
|
if (!PIOS_PWM_validate(pwm_dev)) {
|
||||||
/* Invalid device specified */
|
/* Invalid device specified */
|
||||||
return -1;
|
return PIOS_RCVR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel >= PIOS_PWM_NUM_INPUTS) {
|
if (channel >= PIOS_PWM_NUM_INPUTS) {
|
||||||
/* Channel out of range */
|
/* Channel out of range */
|
||||||
return -1;
|
return PIOS_RCVR_INVALID;
|
||||||
}
|
}
|
||||||
return pwm_dev->CaptureValue[channel];
|
return pwm_dev->CaptureValue[channel];
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ static int32_t PIOS_SBUS_Get(uint32_t rcvr_id, uint8_t channel)
|
|||||||
{
|
{
|
||||||
/* return error if channel is not available */
|
/* return error if channel is not available */
|
||||||
if (channel >= SBUS_NUMBER_OF_CHANNELS) {
|
if (channel >= SBUS_NUMBER_OF_CHANNELS) {
|
||||||
return -1;
|
return PIOS_RCVR_INVALID;
|
||||||
}
|
}
|
||||||
return channel_data[channel];
|
return channel_data[channel];
|
||||||
}
|
}
|
||||||
|
@ -264,12 +264,12 @@ static int32_t PIOS_SPEKTRUM_Get(uint32_t rcvr_id, uint8_t channel)
|
|||||||
{
|
{
|
||||||
struct pios_spektrum_dev * spektrum_dev = (struct pios_spektrum_dev *)rcvr_id;
|
struct pios_spektrum_dev * spektrum_dev = (struct pios_spektrum_dev *)rcvr_id;
|
||||||
|
|
||||||
bool valid = PIOS_SPEKTRUM_validate(spektrum_dev);
|
if(!PIOS_SPEKTRUM_validate(spektrum_dev))
|
||||||
PIOS_Assert(valid);
|
return PIOS_RCVR_INVALID;
|
||||||
|
|
||||||
/* Return error if channel not available */
|
/* Return error if channel not available */
|
||||||
if (channel >= PIOS_SPEKTRUM_NUM_INPUTS) {
|
if (channel >= PIOS_SPEKTRUM_NUM_INPUTS) {
|
||||||
return -1;
|
return PIOS_RCVR_INVALID;
|
||||||
}
|
}
|
||||||
return spektrum_dev->fsm.CaptureValue[channel];
|
return spektrum_dev->fsm.CaptureValue[channel];
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ struct pios_rcvr_driver {
|
|||||||
extern int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel);
|
extern int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel);
|
||||||
|
|
||||||
#define PIOS_RCVR_TIMEOUT 0
|
#define PIOS_RCVR_TIMEOUT 0
|
||||||
#define PIOS_RCVR_NODRIVER 65534
|
#define PIOS_RCVR_NODRIVER -2
|
||||||
#define PIOS_RCVR_INVALID 65535
|
#define PIOS_RCVR_INVALID -1
|
||||||
|
|
||||||
#endif /* PIOS_RCVR_H */
|
#endif /* PIOS_RCVR_H */
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@
|
|||||||
65643CAF1413322000A32F59 /* pios_sbus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_sbus.h; sourceTree = "<group>"; };
|
65643CAF1413322000A32F59 /* pios_sbus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_sbus.h; sourceTree = "<group>"; };
|
||||||
65643CB01413322000A32F59 /* pios_spektrum_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_spektrum_priv.h; sourceTree = "<group>"; };
|
65643CB01413322000A32F59 /* pios_spektrum_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_spektrum_priv.h; sourceTree = "<group>"; };
|
||||||
65643CB91413456D00A32F59 /* pios_tim.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_tim.c; sourceTree = "<group>"; };
|
65643CB91413456D00A32F59 /* pios_tim.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_tim.c; sourceTree = "<group>"; };
|
||||||
|
65643CBA141350C200A32F59 /* pios_sbus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_sbus.c; sourceTree = "<group>"; };
|
||||||
6572CB1613D0F2B200FC2972 /* link_STM32103CB_CC_Rev1_memory.ld */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = link_STM32103CB_CC_Rev1_memory.ld; path = ../../PiOS/STM32F10x/link_STM32103CB_CC_Rev1_memory.ld; sourceTree = SOURCE_ROOT; };
|
6572CB1613D0F2B200FC2972 /* link_STM32103CB_CC_Rev1_memory.ld */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = link_STM32103CB_CC_Rev1_memory.ld; path = ../../PiOS/STM32F10x/link_STM32103CB_CC_Rev1_memory.ld; sourceTree = SOURCE_ROOT; };
|
||||||
6572CB1713D0F2B200FC2972 /* link_STM32103CB_CC_Rev1_sections.ld */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = link_STM32103CB_CC_Rev1_sections.ld; path = ../../PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld; sourceTree = SOURCE_ROOT; };
|
6572CB1713D0F2B200FC2972 /* link_STM32103CB_CC_Rev1_sections.ld */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = link_STM32103CB_CC_Rev1_sections.ld; path = ../../PiOS/STM32F10x/link_STM32103CB_CC_Rev1_sections.ld; sourceTree = SOURCE_ROOT; };
|
||||||
657CEEAD121DB6C8007A1FBE /* homelocation.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = homelocation.xml; sourceTree = "<group>"; };
|
657CEEAD121DB6C8007A1FBE /* homelocation.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = homelocation.xml; sourceTree = "<group>"; };
|
||||||
@ -7779,6 +7780,7 @@
|
|||||||
65E8F0E411EFF25C00BBF654 /* pios_ppm.c */,
|
65E8F0E411EFF25C00BBF654 /* pios_ppm.c */,
|
||||||
65E8F0E511EFF25C00BBF654 /* pios_pwm.c */,
|
65E8F0E511EFF25C00BBF654 /* pios_pwm.c */,
|
||||||
6589A9DB131DEE76006BD67C /* pios_rtc.c */,
|
6589A9DB131DEE76006BD67C /* pios_rtc.c */,
|
||||||
|
65643CBA141350C200A32F59 /* pios_sbus.c */,
|
||||||
65E8F0E611EFF25C00BBF654 /* pios_servo.c */,
|
65E8F0E611EFF25C00BBF654 /* pios_servo.c */,
|
||||||
65E8F0E711EFF25C00BBF654 /* pios_spektrum.c */,
|
65E8F0E711EFF25C00BBF654 /* pios_spektrum.c */,
|
||||||
65E8F0E811EFF25C00BBF654 /* pios_spi.c */,
|
65E8F0E811EFF25C00BBF654 /* pios_spi.c */,
|
||||||
|
Loading…
Reference in New Issue
Block a user