2017-05-26 18:58:04 -03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This file is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2023-12-25 22:21:11 -04:00
|
|
|
#include <AP_HAL/utility/Socket_native.h>
|
2017-05-26 18:58:04 -03:00
|
|
|
#include <AP_HAL/utility/sparse-endian.h>
|
|
|
|
|
|
|
|
#include "RCInput.h"
|
|
|
|
|
2023-12-25 22:21:11 -04:00
|
|
|
#ifndef AP_SOCKET_NATIVE_ENABLED
|
|
|
|
#error "need native"
|
|
|
|
#endif
|
|
|
|
|
2017-05-26 18:58:04 -03:00
|
|
|
namespace Linux {
|
|
|
|
|
|
|
|
class RCInput_SoloLink : public RCInput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RCInput_SoloLink();
|
|
|
|
|
2019-02-21 19:08:12 -04:00
|
|
|
void init() override;
|
|
|
|
void _timer_tick() override;
|
2017-05-26 18:58:04 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const unsigned int PACKET_LEN = 26;
|
|
|
|
static const unsigned int PORT = 5005;
|
|
|
|
|
|
|
|
union packet {
|
|
|
|
struct PACKED {
|
2017-05-26 19:32:53 -03:00
|
|
|
uint64_t timestamp_usec;
|
2017-05-26 18:58:04 -03:00
|
|
|
le16_t seq;
|
|
|
|
le16_t channel[8];
|
|
|
|
};
|
|
|
|
uint8_t buf[PACKET_LEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
bool _check_hdr(ssize_t len);
|
|
|
|
|
2023-12-25 22:41:12 -04:00
|
|
|
SocketAPM_native _socket{true};
|
2017-05-26 18:58:04 -03:00
|
|
|
uint64_t _last_usec = 0;
|
|
|
|
uint16_t _last_seq = 0;
|
|
|
|
union packet _packet;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|