Hello, I trying to communicate with PIXHAWK <----> COMPUTER Serial port.
My code is very simple, first I uncommented in APM_Config.h lines:
#define USERHOOK_INIT userhook_init(); // for code to be run once at startup
#define USERHOOK_SUPERSLOWLOOP userhook_SuperSlowLoop(); // for code to be run at 1hz
Then I wrote very simple example in UserCode.cpp:
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
#include "Copter.h"
static void setup_uart(AP_HAL::UARTDriver *uart, const char *name);
#ifdef USERHOOK_INIT
void Copter::userhook_init()
{
setup_uart(hal.uartE, "uartE");
setup_uart(hal.uartD, "uartD");
}
#endif
#ifdef USERHOOK_FASTLOOP
void Copter::userhook_FastLoop()
{
// put your 100Hz code here
}
#endif
#ifdef USERHOOK_50HZLOOP
void Copter::userhook_50Hz()
{
// put your 50Hz code here
}
#endif
#ifdef USERHOOK_MEDIUMLOOP
void Copter::userhook_MediumLoop()
{
// put your 10Hz code here
}
#endif
#ifdef USERHOOK_SLOWLOOP
void Copter::userhook_SlowLoop()
{
// put your 3.3Hz code here
}
#endif
#ifdef USERHOOK_SUPERSLOWLOOP
void Copter::userhook_SuperSlowLoop()
{
hal.uartE->printf("test");
hal.uartD->printf("test");
}
#endif
/* setup UART at 57600 ---------------------------------------- */
static void setup_uart(AP_HAL::UARTDriver *uart, const char *name)
{
if (uart == NULL)
{
// that UART doesn't exist on this platform
return;
}
///begin(baudrate,Rx,Tx)
uart->begin(57600, 256, 256);
}
But on computer side I cannot see anything. Can anyone help me, is it the correct way? Thank You!