mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-06 16:03:58 -04:00
HAL_SITL: allow SITL to use SERIALn_PROTOCOL=23
this allows for testing of RC input protocol parsing in SITL
This commit is contained in:
parent
c8de2ec9c7
commit
5e5c30efe8
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "RCInput.h"
|
#include "RCInput.h"
|
||||||
#include <SITL/SITL.h>
|
#include <SITL/SITL.h>
|
||||||
|
#include <AP_RCProtocol/AP_RCProtocol.h>
|
||||||
|
|
||||||
using namespace HALSITL;
|
using namespace HALSITL;
|
||||||
|
|
||||||
@ -10,10 +11,19 @@ extern const AP_HAL::HAL& hal;
|
|||||||
|
|
||||||
void RCInput::init()
|
void RCInput::init()
|
||||||
{
|
{
|
||||||
|
AP::RC().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RCInput::new_input()
|
bool RCInput::new_input()
|
||||||
{
|
{
|
||||||
|
if (!using_rc_protocol) {
|
||||||
|
if (AP::RC().new_input()) {
|
||||||
|
using_rc_protocol = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (using_rc_protocol) {
|
||||||
|
return AP::RC().new_input();
|
||||||
|
}
|
||||||
if (_sitlState->new_rc_input) {
|
if (_sitlState->new_rc_input) {
|
||||||
_sitlState->new_rc_input = false;
|
_sitlState->new_rc_input = false;
|
||||||
return true;
|
return true;
|
||||||
@ -23,6 +33,9 @@ bool RCInput::new_input()
|
|||||||
|
|
||||||
uint16_t RCInput::read(uint8_t ch)
|
uint16_t RCInput::read(uint8_t ch)
|
||||||
{
|
{
|
||||||
|
if (using_rc_protocol) {
|
||||||
|
return AP::RC().read(ch);
|
||||||
|
}
|
||||||
if (ch >= num_channels()) {
|
if (ch >= num_channels()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -42,6 +55,9 @@ uint8_t RCInput::read(uint16_t* periods, uint8_t len)
|
|||||||
|
|
||||||
uint8_t RCInput::num_channels()
|
uint8_t RCInput::num_channels()
|
||||||
{
|
{
|
||||||
|
if (using_rc_protocol) {
|
||||||
|
return AP::RC().num_channels();
|
||||||
|
}
|
||||||
SITL::SITL *_sitl = AP::sitl();
|
SITL::SITL *_sitl = AP::sitl();
|
||||||
if (_sitl) {
|
if (_sitl) {
|
||||||
return MIN(_sitl->rc_chancount.get(), SITL_RC_INPUT_CHANNELS);
|
return MIN(_sitl->rc_chancount.get(), SITL_RC_INPUT_CHANNELS);
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SITL_State *_sitlState;
|
SITL_State *_sitlState;
|
||||||
|
bool using_rc_protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <AP_RCProtocol/AP_RCProtocol.h>
|
||||||
|
|
||||||
using namespace HALSITL;
|
using namespace HALSITL;
|
||||||
|
|
||||||
@ -209,6 +210,8 @@ void Scheduler::_run_io_procs()
|
|||||||
hal.storage->_timer_tick();
|
hal.storage->_timer_tick();
|
||||||
|
|
||||||
check_thread_stacks();
|
check_thread_stacks();
|
||||||
|
|
||||||
|
AP::RC().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user