Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
datalink.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) Kirk Scheper <kirkscheper@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 
28 #define MODULES_DATALINK_C
29 
30 #include "datalink.h"
32 
33 #include "generated/modules.h"
34 #include "generated/settings.h"
35 
36 #include "pprzlink/messages.h"
37 
41 uint8_t dl_buffer[MSG_SIZE] __attribute__((aligned));
42 
43 #if USE_NPS
44 bool datalink_enabled = true;
45 #endif
46 
47 void datalink_init(void)
48 {
49  dl_msg_available = false;
50  datalink_time = 0;
51  datalink_nb_msgs = 0;
52 }
53 
55 {
56  datalink_time++; // called at 1Hz
57 }
58 
59 void datalink_parse_PING(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
60 {
61  // Reply to the sender of the message
62  struct pprzlink_msg msg;
63  msg.trans = trans;
64  msg.dev = dev;
65  msg.sender_id = AC_ID;
66  msg.receiver_id = pprzlink_get_msg_sender_id(buf);
67  msg.component_id = 0;
68  pprzlink_msg_send_PONG(&msg);
69 }
70 
71 void WEAK dl_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
72 {
73  uint8_t msg_id = pprzlink_get_msg_id(buf);
74  uint8_t class_id = pprzlink_get_msg_class_id(buf);
75  /* Parse modules datalink */
76  modules_parse_datalink(msg_id, class_id, dev, trans, buf);
77 }
78 
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
#define MSG_SIZE
Definition: main_demo5.c:62
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:74
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98