summaryrefslogtreecommitdiffstats
path: root/blocks/src/lib/tdu.cc
blob: e5cfddeac135b3fefae51e0f78114dbb7f478d3f (plain)
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
/* -*- C++ -*- */

/*
 * Copyright 2008 Steve Glass
 * 
 * This file is part of OP25.
 * 
 * OP25 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, or (at your option)
 * any later version.
 * 
 * OP25 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 OP25; see the file COPYING.  If not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Boston, MA
 * 02110-1301, USA.
 */

#include <itpp/base/vec.h>
#include <itpp/comm/reedsolomon.h>
#include <tdu.h>
#include <op25_yank.h>

using std::string;

tdu::tdu(const_bit_queue& frame_body, bool has_link_control) :
   abstract_data_unit(frame_body),
   d_has_link_control(has_link_control)
{
}

tdu::~tdu()
{
}

string
tdu::duid_str() const
{
   return string("TDU");
}

void
tdu::do_correct_errors(bit_vector& frame)
{
   if(d_has_link_control) {
      apply_golay_correction(frame);
      apply_rs_correction(frame);
   }
}

void
tdu::apply_golay_correction(bit_vector& frame)
{
}

void
tdu::apply_rs_correction(bit_vector& frame)
{
#if 0
   static itpp::Reed_Solomon rs(63, 17, true);
   itpp::bvec b(70);
   swab(frame, 114, 122, b,  0);
   swab(frame, 122, 126, b,  8);
   swab(frame, 138, 142, b, 12);
   swab(frame, 144, 152, b, 16);
   swab(frame, 164, 176, b, 24);
   swab(frame, 188, 200, b, 36);
   swab(frame, 212, 213, b, 48);
   swab(frame, 216, 226, b, 50);
   swab(frame, 238, 250, b, 60);
   itpp::bvec bd(rs.decode(b));
#endif
}

uint16_t
tdu::frame_size_max() const
{
   return d_has_link_control ? 432 : 144;
}