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
lisa_overo_link.c
Go to the documentation of this file.
1 #include "lisa/lisa_overo_link.h"
2 
4 
5 void overo_link_init(void) {
13 }
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 #ifdef USE_OVERO_LINK_TELEMETRY
24 #include <string.h>
25 
26 uint8_t overo_link_telemetry_insert_idx;
27 uint8_t overo_link_telemetry_extract_idx;
28 uint8_t overo_link_telemetry_buf[OVERO_LINK_TELEMETRY_BUF_SIZE];
29 
30 uint8_t overo_link_telemetry_get(char* buf, int len) {
31  int8_t available = overo_link_telemetry_insert_idx - overo_link_telemetry_extract_idx;
32  int8_t nb_put;
33  /* we don't cross circular buffer end */
34  if (available >= 0) {
35  nb_put = Min(available, len);
36  memcpy(buf, &overo_link_telemetry_buf[overo_link_telemetry_extract_idx], nb_put);
37  overo_link_telemetry_extract_idx += nb_put;
38  }
39  /* we cross circular buffer end */
40  else {
41  available += OVERO_LINK_TELEMETRY_BUF_SIZE;
42  nb_put = Min(available, len);
43  uint8_t first_put = OVERO_LINK_TELEMETRY_BUF_SIZE - 1 - overo_link_telemetry_extract_idx;
44  memcpy(buf, &overo_link_telemetry_buf[overo_link_telemetry_extract_idx], first_put);
45  overo_link_telemetry_extract_idx += nb_put;
46  if (first_put < nb_put) {
47  memcpy(&buf[first_put], &overo_link_telemetry_buf[0], nb_put - first_put);
48  overo_link_telemetry_extract_idx -= OVERO_LINK_TELEMETRY_BUF_SIZE;
49  }
50  }
51  return nb_put;
52 }
53 
54 #endif /* USE_OVERO_LINK_TELEMETRY */
#define Min(x, y)
#define FALSE
Definition: imu_chimu.h:141
unsigned char uint8_t
Definition: types.h:14
signed char int8_t
Definition: types.h:15