ardupilot/libraries/AP_HAL_Linux/RCInput_UDP.cpp
José Roberto de Souza 9889f826b3 AP_HAL_Linux: RCInput_UDP: Fix compiling warning
This warning happens because of the difference of datatypes between
32 and 64 bits processors.

%% libraries/AP_HAL_Linux/RCInput_UDP.o
/home/zehortigoza/dev/ardupilot/libraries/AP_HAL_Linux/RCInput_UDP.cpp: In member function 'virtual void Linux::LinuxRCInput_UDP::_timer_tick()':
/home/zehortigoza/dev/ardupilot/libraries/AP_HAL_Linux/RCInput_UDP.cpp:42:72: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t {aka long unsigned int}' [-Wformat=]
             hal.console->printf("no rc cmds received for %llu\n", delay);
2015-10-16 10:28:07 +11:00

55 lines
1.3 KiB
C++

#include <AP_HAL/AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include "RCInput_UDP.h"
#include <stdio.h>
extern const AP_HAL::HAL& hal;
using namespace Linux;
LinuxRCInput_UDP::LinuxRCInput_UDP() :
_port(0),
_last_buf_ts(0),
_last_buf_seq(0)
{}
void LinuxRCInput_UDP::init(void *)
{
_port = RCINPUT_UDP_DEF_PORT;
if(!_socket.bind("0.0.0.0", _port)) {
hal.console->printf("failed to bind UDP socket\n");
}
_socket.set_blocking(false);
return;
}
void LinuxRCInput_UDP::_timer_tick(void)
{
uint64_t delay;
uint16_t seq_inc;
/* Read from udp */
while (_socket.recv(&_buf, sizeof(_buf), 10) == sizeof(_buf)) {
if (_buf.version != RCINPUT_UDP_VERSION) {
hal.console->printf("bad protocol version for UDP RCInput\n");
return;
}
if (_last_buf_ts != 0 &&
(delay = _buf.timestamp_us - _last_buf_ts) > 100000) {
hal.console->printf("no rc cmds received for %llu\n", (unsigned long long)delay);
}
_last_buf_ts = _buf.timestamp_us;
if ((seq_inc = _buf.sequence - _last_buf_seq) > 10) {
hal.console->printf("gap in rc cmds : %u\n", seq_inc);
}
_last_buf_seq = _buf.sequence;
_update_periods(_buf.pwms, RCINPUT_UDP_NUM_CHANNELS);
}
}
#endif