HAL_SITL: prevent array overruns in RCInput/RCOutput

This commit is contained in:
Andrew Tridgell 2014-11-11 15:15:28 +11:00
parent ed099a73a3
commit a566ebe4ec
2 changed files with 10 additions and 1 deletions

View File

@ -18,6 +18,9 @@ bool SITLRCInput::new_input() {
uint16_t SITLRCInput::read(uint8_t ch) {
_sitlState->new_rc_input = false;
if (ch >= 8) {
return 0;
}
return _override[ch]? _override[ch] : _sitlState->pwm_input[ch];
}

View File

@ -23,7 +23,9 @@ void SITLRCOutput::disable_ch(uint8_t ch)
void SITLRCOutput::write(uint8_t ch, uint16_t period_us)
{
if (ch < 11) {
_sitlState->pwm_output[ch] = period_us;
}
}
void SITLRCOutput::write(uint8_t ch, uint16_t* period_us, uint8_t len)
@ -31,8 +33,12 @@ void SITLRCOutput::write(uint8_t ch, uint16_t* period_us, uint8_t len)
memcpy(_sitlState->pwm_output+ch, period_us, len*sizeof(uint16_t));
}
uint16_t SITLRCOutput::read(uint8_t ch) {
uint16_t SITLRCOutput::read(uint8_t ch)
{
if (ch < 11) {
return _sitlState->pwm_output[ch];
}
return 0;
}
void SITLRCOutput::read(uint16_t* period_us, uint8_t len)