forked from mutability/mlat-client
-
Notifications
You must be signed in to change notification settings - Fork 22
/
_modes.h
76 lines (63 loc) · 2.35 KB
/
_modes.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
#ifndef _MODES_H
#define _MODES_H
/*
* Part of mlat-client - an ADS-B multilateration client.
* Copyright 2015, Oliver Jowett <[email protected]>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Python.h>
#include <structmember.h>
#include <stdint.h>
/* a modesmessage object */
typedef struct {
PyObject_HEAD
unsigned long long timestamp;
unsigned int signal;
unsigned int df;
unsigned int nuc;
char even_cpr;
char odd_cpr;
char valid;
PyObject *crc;
PyObject *address;
PyObject *altitude;
uint8_t *data;
int datalen;
PyObject *eventdata;
} modesmessage;
/* special DF types for non-Mode-S messages */
#define DF_MODEAC 32
#define DF_EVENT_TIMESTAMP_JUMP 33
#define DF_EVENT_MODE_CHANGE 34
#define DF_EVENT_EPOCH_ROLLOVER 35
#define DF_EVENT_RADARCAPE_STATUS 36
#define DF_EVENT_RADARCAPE_POSITION 37
/* factory function to build a modesmessage from a provided buffer */
PyObject *modesmessage_from_buffer(unsigned long long timestamp, unsigned signal, uint8_t *data, int datalen);
/* factory function to build an event message */
PyObject *modesmessage_new_eventmessage(int type, unsigned long long timestamp, PyObject *eventdata);
/* python entry point */
PyObject *modesmessage_eventmessage(PyObject *self, PyObject *args, PyObject *kwds);
/* crc helpers */
uint32_t modescrc_buffer_crc(uint8_t *buf, Py_ssize_t len); /* internal interface */
PyObject *modescrc_crc(PyObject *self, PyObject *args); /* external interface */
/* submodule init/cleanup */
int modescrc_module_init(PyObject *m);
void modescrc_module_free(PyObject *m);
int modesreader_module_init(PyObject *m);
void modesreader_module_free(PyObject *m);
int modesmessage_module_init(PyObject *m);
void modesmessage_module_free(PyObject *m);
#endif