-
Notifications
You must be signed in to change notification settings - Fork 55
/
pprz_transport.h
87 lines (74 loc) · 2.24 KB
/
pprz_transport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
* Copyright (C) 2015 Gautier Hattenberger <[email protected]>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
/**
* @file pprzlink/pprz_transport.h
*
* Building and parsing Paparazzi frames.
*
* Pprz frame:
*
* |STX|length|... payload=(length-4) bytes ...|Checksum A|Checksum B|
*
* where checksum is computed over length and payload:
* @code
* ck_A = ck_B = length
* for each byte b in payload
* ck_A += b;
* ck_b += ck_A;
* @endcode
*/
#ifndef PPRZ_TRANSPORT_H
#define PPRZ_TRANSPORT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
#include <stdbool.h>
#include "pprzlink/pprzlink_transport.h"
#include "pprzlink/pprzlink_device.h"
// Start byte
#define PPRZ_STX 0x99
/* PPRZ Transport
*/
struct pprz_transport {
// generic reception interface
struct transport_rx trans_rx;
// specific pprz transport_rx variables
uint8_t status;
uint8_t payload_idx;
uint8_t ck_a_rx, ck_b_rx;
// generic transmission interface
struct transport_tx trans_tx;
// specific pprz transport_tx variables
uint8_t ck_a_tx, ck_b_tx;
};
// Init function
extern void pprz_transport_init(struct pprz_transport *t);
// Checking new data and parsing
extern void pprz_check_and_parse(struct link_device *dev, struct pprz_transport *trans, uint8_t *buf, bool *msg_available);
// Parsing function, only needed for modules doing their own parsing
// without using the pprz_check_and_parse function
extern void parse_pprz(struct pprz_transport *t, uint8_t c);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PPRZ_TRANSPORT_H */