RCInput_SoloLink.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2017 Intel Corporation. All rights reserved.
  3. *
  4. * This file is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. * See the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <unistd.h>
  19. #include <AP_HAL/utility/Socket.h>
  20. #include <AP_HAL/utility/sparse-endian.h>
  21. #include "RCInput.h"
  22. namespace Linux {
  23. class RCInput_SoloLink : public RCInput
  24. {
  25. public:
  26. RCInput_SoloLink();
  27. void init() override;
  28. void _timer_tick() override;
  29. private:
  30. static const unsigned int PACKET_LEN = 26;
  31. static const unsigned int PORT = 5005;
  32. union packet {
  33. struct PACKED {
  34. uint64_t timestamp_usec;
  35. le16_t seq;
  36. le16_t channel[8];
  37. };
  38. uint8_t buf[PACKET_LEN];
  39. };
  40. bool _check_hdr(ssize_t len);
  41. SocketAPM _socket{true};
  42. uint64_t _last_usec = 0;
  43. uint16_t _last_seq = 0;
  44. union packet _packet;
  45. };
  46. }