Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
joby.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #include "stdio.h"
24 
27 
28 
29 static void handle_channel(void (* callback)(void))
30 {
32  // got start channel, look for channel 0 next
34  } else if (parser.current_channel == -1) {
35  // looking for start channel byte but didn't get it, reset
38  } else {
39  // valid channel, store and look for next
43  // all channels read, reset parser and handle message
48  if (callback != NULL)
49  callback();
50  }
51  }
52 }
53 
54 static void handle_tuple(void (* callback)(void))
55 {
63  handle_channel(callback);
64  } else {
65  // normal didn't match inverted, error, reset
70  }
71  }
72 }
73 
74 void rc_joby_parse(int8_t c, void (* callback)(void))
75 {
79  // only advance parser state to low byte if we're not looking for a sync byte which we didn't find
81  }
82  } else { // READING_LOW_BYTE
83  parser.low_byte_buf = c;
85  handle_tuple(callback);
86  }
87 }
88 
93 }
parser_byte_t current_byte
Definition: joby.h:45
static const int16_t rc_joby_signs[RADIO_CONTROL_NB_CHANNEL]
Definition: joby.c:26
int16_t parser_inverted_buf
Definition: joby.h:49
uint8_t frame_cpt
Definition: radio_control.h:54
uint8_t high_byte_buf
Definition: joby.h:51
uint8_t time_since_last_frame
Definition: radio_control.h:51
void radio_control_impl_init(void)
Definition: joby.c:89
#define RC_JOBY_MAGIC_START
Definition: joby.h:29
int current_channel
Definition: joby.h:47
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:55
void rc_joby_parse(int8_t c, void(*callback)(void))
Definition: joby.c:74
signed short int16_t
Definition: types.h:17
struct RadioControl radio_control
Definition: radio_control.c:25
uint32_t error_counter
Definition: joby.h:54
static void handle_tuple(void(*callback)(void))
Definition: joby.c:54
#define RC_OK
Definition: radio_control.h:45
uint8_t status
Definition: radio_control.h:50
#define RADIO_CONTROL_NB_CHANNEL
Definition: spektrum_arch.h:34
#define RC_JOBY_SIGNS
Definition: joby_9ch.h:39
uint8_t low_byte_buf
Definition: joby.h:52
static void handle_channel(void(*callback)(void))
Definition: joby.c:29
signed char int8_t
Definition: types.h:15
parser_inverted_t current_inverted
Definition: joby.h:46
int16_t parser_normal_buf
Definition: joby.h:50
static struct rc_joby_parser_state parser
Definition: joby.c:25