AP_HAL_Linux: RCInput_RPI: fix using Util class on constructor

Program received signal SIGSEGV, Segmentation fault.
0x000b8760 in Linux::UtilRPI::get_rpi_version() const ()
(gdb) bt
 #0  0x000b8760 in Linux::UtilRPI::get_rpi_version() const ()
 #1  0x000b57ac in Linux::RCInput_RPI::RCInput_RPI() ()
 #2  0x0000acfc in _GLOBAL__sub_I__ZN9HAL_LinuxC2Ev ()
 #3  0x000e1600 in __libc_csu_init ()
 #4  0x76cad228 in __libc_start_main (main=0x7efff774, argc=1994186752,
     argv=0x76cad228 <__libc_start_main+168>, init=0xe15b4 <__libc_csu_init>,
     fini=0xe1614 <__libc_csu_fini>, rtld_fini=0x76fdf464 <_dl_fini>,
     stack_end=0x7efff774) at libc-start.c:246
 #5  0x0000afa4 in _start ()
This commit is contained in:
Lucas De Marchi 2016-11-18 14:23:28 -02:00
parent bc476e1987
commit 8d3361cef4
2 changed files with 20 additions and 12 deletions

View File

@ -395,6 +395,8 @@ void RCInput_RPI::set_sigaction()
//Initial setup of variables
RCInput_RPI::RCInput_RPI():
circle_buffer{nullptr},
con_blocks{nullptr},
prev_tick(0),
delta_time(0),
curr_tick_inc(1000/RCIN_RPI_SAMPLE_FREQ),
@ -405,16 +407,6 @@ RCInput_RPI::RCInput_RPI():
last_signal(228),
state(RCIN_RPI_INITIAL_STATE)
{
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2
int version = 2;
#else
int version = UtilRPI::from(hal.util)->get_rpi_version();
#endif
set_physical_addresses(version);
//Init memory for buffer and for DMA control blocks. See comments in "init_ctrl_data()" to understand values "2" and "113"
circle_buffer = new Memory_table(RCIN_RPI_BUFFER_LENGTH * 2, version);
con_blocks = new Memory_table(RCIN_RPI_BUFFER_LENGTH * 113, version);
}
RCInput_RPI::~RCInput_RPI()
@ -438,6 +430,14 @@ void RCInput_RPI::init_registers()
void RCInput_RPI::init()
{
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2
int version = 2;
#else
int version = UtilRPI::from(hal.util)->get_rpi_version();
#endif
set_physical_addresses(version);
circle_buffer = new Memory_table(RCIN_RPI_BUFFER_LENGTH * 2, version);
con_blocks = new Memory_table(RCIN_RPI_BUFFER_LENGTH * 113, version);
init_registers();
@ -461,6 +461,8 @@ void RCInput_RPI::init()
curr_signal = *((uint8_t*) circle_buffer->get_page(circle_buffer->_virt_pages, curr_pointer)) & 0x10 ? 1 : 0;
last_signal = curr_signal;
curr_pointer++;
_initialized = true;
}
@ -470,6 +472,10 @@ void RCInput_RPI::_timer_tick()
int j;
void* x;
if (!_initialized) {
return;
}
//Now we are getting address in which DMAC is writing at current moment
dma_cb_t* ad = (dma_cb_t*) con_blocks->get_virt_addr(dma_reg[RCIN_RPI_DMA_CONBLK_AD | RCIN_RPI_DMA_CHANNEL << 8]);
for(j = 1; j >= -1; j--){

View File

@ -112,6 +112,8 @@ private:
uint8_t curr_signal;
uint8_t last_signal;
bool _initialized = false;
state_t state;
AP_HAL::DigitalSource *enable_pin;