Ironcup Mar 2020

Dependencies:   mbed mbed-rtos MotionSensor EthernetInterface

Committer:
drelliak
Date:
Sun May 15 19:14:06 2016 +0000
Revision:
19:c709c5a9fb08
Updated protocol;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
drelliak 19:c709c5a9fb08 1 /**
drelliak 19:c709c5a9fb08 2 @file receiver.h
drelliak 19:c709c5a9fb08 3 @brief Receiver side functions declarations.
drelliak 19:c709c5a9fb08 4 */
drelliak 19:c709c5a9fb08 5
drelliak 19:c709c5a9fb08 6 /*
drelliak 19:c709c5a9fb08 7 Copyright 2016 Erik Perillo <erik.perillo@gmail.com>
drelliak 19:c709c5a9fb08 8
drelliak 19:c709c5a9fb08 9 This file is part of piranha-ptc.
drelliak 19:c709c5a9fb08 10
drelliak 19:c709c5a9fb08 11 This is free software: you can redistribute it and/or modify
drelliak 19:c709c5a9fb08 12 it under the terms of the GNU General Public License as published by
drelliak 19:c709c5a9fb08 13 the Free Software Foundation, either version 3 of the License, or
drelliak 19:c709c5a9fb08 14 (at your option) any later version.
drelliak 19:c709c5a9fb08 15
drelliak 19:c709c5a9fb08 16 This is distributed in the hope that it will be useful,
drelliak 19:c709c5a9fb08 17 but WITHOUT ANY WARRANTY; without even the implied warranty of
drelliak 19:c709c5a9fb08 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
drelliak 19:c709c5a9fb08 19 See the GNU General Public License for more details.
drelliak 19:c709c5a9fb08 20
drelliak 19:c709c5a9fb08 21 You should have received a copy of the GNU General Public License
drelliak 19:c709c5a9fb08 22 along with this. If not, see <http://www.gnu.org/licenses/>.
drelliak 19:c709c5a9fb08 23 */
drelliak 19:c709c5a9fb08 24
drelliak 19:c709c5a9fb08 25
drelliak 19:c709c5a9fb08 26 #ifndef __PIRANHA_RCV_PROTOCOL_H__
drelliak 19:c709c5a9fb08 27 #define __PIRANHA_RCV_PROTOCOL_H__
drelliak 19:c709c5a9fb08 28
drelliak 19:c709c5a9fb08 29 #include "protocol.h"
drelliak 19:c709c5a9fb08 30 #include "mbed.h"
drelliak 19:c709c5a9fb08 31 #include "EthernetInterface.h"
drelliak 19:c709c5a9fb08 32
drelliak 19:c709c5a9fb08 33 #define TEST
drelliak 19:c709c5a9fb08 34
drelliak 19:c709c5a9fb08 35 class Receiver
drelliak 19:c709c5a9fb08 36 {
drelliak 19:c709c5a9fb08 37
drelliak 19:c709c5a9fb08 38 #ifdef TEST
drelliak 19:c709c5a9fb08 39 public:
drelliak 19:c709c5a9fb08 40 #else
drelliak 19:c709c5a9fb08 41 protected:
drelliak 19:c709c5a9fb08 42 #endif
drelliak 19:c709c5a9fb08 43 UDPSocket sock;
drelliak 19:c709c5a9fb08 44 char message[MSG_BUF_LEN];
drelliak 19:c709c5a9fb08 45 Endpoint sender_addr;
drelliak 19:c709c5a9fb08 46
drelliak 19:c709c5a9fb08 47 float un_scale(uint16_t value, float min, float max);
drelliak 19:c709c5a9fb08 48 uint8_t get_header();
drelliak 19:c709c5a9fb08 49 uint16_t get_raw_val(int pos=0);
drelliak 19:c709c5a9fb08 50 float get_val(float min, float max, int pos=0);
drelliak 19:c709c5a9fb08 51 void get_vals(float min, float max, float* vals, int size);
drelliak 19:c709c5a9fb08 52
drelliak 19:c709c5a9fb08 53 public:
drelliak 19:c709c5a9fb08 54 Receiver();
drelliak 19:c709c5a9fb08 55 Receiver(Endpoint sender_addr, const UDPSocket& sock);
drelliak 19:c709c5a9fb08 56 Receiver(Endpoint sender_addr, int sock_port=RECEIVER_PORT, int timeout=1);
drelliak 19:c709c5a9fb08 57
drelliak 19:c709c5a9fb08 58 void set_sender_addr(const Endpoint& sender_addr);
drelliak 19:c709c5a9fb08 59 void set_socket(const UDPSocket& sock);
drelliak 19:c709c5a9fb08 60 void set_socket(int port=RECEIVER_PORT, int timeout=1);
drelliak 19:c709c5a9fb08 61 Endpoint get_sender_addr();
drelliak 19:c709c5a9fb08 62 UDPSocket get_socket();
drelliak 19:c709c5a9fb08 63
drelliak 19:c709c5a9fb08 64 bool receive();
drelliak 19:c709c5a9fb08 65 uint8_t get_msg();
drelliak 19:c709c5a9fb08 66 float get_ang_ref();
drelliak 19:c709c5a9fb08 67 float get_cam_ang_ref();
drelliak 19:c709c5a9fb08 68 float get_gnd_vel();
drelliak 19:c709c5a9fb08 69 void get_jog_vel(float* period, float* ratio);
drelliak 19:c709c5a9fb08 70 void get_pid_params(float* params);
drelliak 19:c709c5a9fb08 71 void get_mag_calib(float* params);
drelliak 19:c709c5a9fb08 72 };
drelliak 19:c709c5a9fb08 73
drelliak 19:c709c5a9fb08 74 #endif
drelliak 19:c709c5a9fb08 75