File: gps_l1_ca_read_telemetry_dump.py

package info (click to toggle)
gnss-sdr 0.0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 27,564 kB
  • sloc: cpp: 218,512; ansic: 36,754; python: 2,423; xml: 1,479; sh: 459; makefile: 8
file content (86 lines) | stat: -rw-r--r-- 2,396 bytes parent folder | download
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
"""
 gps_l1_ca_read_telemetry_dump.py
   gps_l1_ca_read_telemetry_dump (filename)

 Open and read GNSS-SDR telemetry binary log files (.dat) into Python, and
 return the contents.

 Irene Pérez Riega, 2023. iperrie@inta.es

      Args:
        filename        - Path to file telemetry[N].dat with the raw data

      Return:
        telemetry       - A dictionary with the processed data

 -----------------------------------------------------------------------------

 GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
 This file is part of GNSS-SDR.

 Copyright (C) 2022  (see AUTHORS file for a list of contributors)
 SPDX-License-Identifier: GPL-3.0-or-later

 -----------------------------------------------------------------------------
"""

import struct


def gps_l1_ca_read_telemetry_dump(filename):

    double_size_bytes = 8
    int_size_bytes = 4
    bytes_shift = 0

    tow_current_symbol_ms = []
    tracking_sample_counter = []
    tow = []
    nav_simbols = []
    prn = []

    f = open(filename, 'rb')
    if f is None:
        return None
    else:
        while True:
            f.seek(bytes_shift, 0)

            tow_current_symbol_ms.append(struct.unpack(
                'd', f.read(double_size_bytes))[0])
            bytes_shift += double_size_bytes
            f.seek(bytes_shift, 0)

            tracking_sample_counter.append(struct.unpack(
                'Q', f.read(double_size_bytes))[0])
            bytes_shift += double_size_bytes
            f.seek(bytes_shift, 0)

            tow.append(struct.unpack(
                'd', f.read(double_size_bytes))[0])
            bytes_shift += double_size_bytes
            f.seek(bytes_shift, 0)

            nav_simbols.append(struct.unpack(
                'I', f.read(int_size_bytes))[0])
            bytes_shift += int_size_bytes
            f.seek(bytes_shift, 0)

            prn.append(struct.unpack('I', f.read(int_size_bytes))[0])
            bytes_shift += int_size_bytes
            f.seek(bytes_shift, 0)

            # Check file
            linea = f.readline()
            if not linea:
                break

        telemetry = {
            'tow_current_symbol_ms': tow_current_symbol_ms,
            'tracking_sample_counter': tracking_sample_counter,
            'tow': tow,
            'nav_simbols': nav_simbols,
            'prn': prn
        }

    return telemetry