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