2008-05-31 22:26:53 +00:00
|
|
|
/* -*- C++ -*- */
|
2008-11-09 22:41:29 +00:00
|
|
|
|
2008-05-31 22:26:53 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-12-01 04:24:15 +00:00
|
|
|
|
2008-12-05 05:53:41 +00:00
|
|
|
#include <itpp/base/vec.h>
|
|
|
|
#include <itpp/comm/egolay.h>
|
|
|
|
#include <itpp/comm/reedsolomon.h>
|
2008-11-09 22:41:29 +00:00
|
|
|
#include <tdu.h>
|
2009-07-07 21:47:54 +00:00
|
|
|
#include <yank.h>
|
2008-05-31 22:26:53 +00:00
|
|
|
|
2009-01-28 04:50:25 +00:00
|
|
|
using std::string;
|
|
|
|
|
|
|
|
tdu::tdu(const_bit_queue& frame_body, bool has_link_control) :
|
2008-12-02 02:47:56 +00:00
|
|
|
abstract_data_unit(frame_body),
|
2008-05-31 22:26:53 +00:00
|
|
|
d_has_link_control(has_link_control)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-11-09 22:41:29 +00:00
|
|
|
tdu::~tdu()
|
2008-05-31 22:26:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-28 04:50:25 +00:00
|
|
|
string
|
|
|
|
tdu::duid_str() const
|
|
|
|
{
|
|
|
|
return string("TDU");
|
|
|
|
}
|
|
|
|
|
2008-12-02 02:47:56 +00:00
|
|
|
void
|
2008-12-05 05:53:41 +00:00
|
|
|
tdu::correct_errors(bit_vector& frame)
|
2008-11-09 22:41:29 +00:00
|
|
|
{
|
2008-12-05 05:53:41 +00:00
|
|
|
if(d_has_link_control) {
|
|
|
|
apply_golay_correction(frame);
|
|
|
|
apply_rs_correction(frame);
|
|
|
|
}
|
2008-11-09 22:41:29 +00:00
|
|
|
}
|
2008-12-05 05:53:41 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
tdu::apply_golay_correction(bit_vector& frame)
|
|
|
|
{
|
|
|
|
static itpp::Extended_Golay golay;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tdu::apply_rs_correction(bit_vector& frame)
|
|
|
|
{
|
2008-12-06 10:38:11 +00:00
|
|
|
#if 0
|
2008-12-05 05:53:41 +00:00
|
|
|
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));
|
2008-12-06 10:38:11 +00:00
|
|
|
#endif
|
2008-12-05 05:53:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-15 07:46:10 +00:00
|
|
|
uint16_t
|
2009-01-11 11:55:59 +00:00
|
|
|
tdu::frame_size_max() const
|
2008-12-05 05:53:41 +00:00
|
|
|
{
|
2008-12-15 07:46:10 +00:00
|
|
|
return d_has_link_control ? 432 : 144;
|
2008-12-05 05:53:41 +00:00
|
|
|
}
|