First cut on Golay decoding of HDU. More to follow
git-svn-id: http://op25.osmocom.org/svn/trunk@153 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
bfd78e82df
commit
5371081cc0
|
@ -77,7 +77,8 @@ _op25_la_SOURCES = \
|
|||
op25.cc \
|
||||
op25_decoder_ff.cc \
|
||||
vc55_imbe_decoder.cc \
|
||||
value_string.cc
|
||||
value_string.cc \
|
||||
egolay.cc
|
||||
|
||||
|
||||
# magic flags
|
||||
|
|
|
@ -27,6 +27,13 @@
|
|||
#include <data_unit.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <yank.h>
|
||||
|
||||
#include <itpp/base/vec.h>
|
||||
#include <vector>
|
||||
|
||||
typedef std::vector<bool> bit_vector;
|
||||
typedef const std::vector<bool> const_bit_vector;
|
||||
|
||||
/**
|
||||
* Abstract P25 data unit.
|
||||
|
|
|
@ -26,10 +26,9 @@
|
|||
#include <ldu1.h>
|
||||
#include <ldu2.h>
|
||||
#include <pdu.h>
|
||||
#include <swab.h>
|
||||
#include <tdu.h>
|
||||
#include <yank.h>
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
data_unit_sptr
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <iosfwd>
|
||||
#include <imbe_decoder.h>
|
||||
#include <stdint.h>
|
||||
#include <swab.h>
|
||||
|
||||
typedef std::deque<bool> bit_queue;
|
||||
typedef const std::deque<bool> const_bit_queue;
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/*!
|
||||
* \file
|
||||
* \brief Implementation of the Extended Golay Code (24, 12, 8)
|
||||
* \author Tony Ottosson
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* IT++ - C++ library of mathematical, signal processing, speech processing,
|
||||
* and communications classes and functions
|
||||
*
|
||||
* Copyright (C) 1995-2008 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//#include <itpp/comm/egolay.h>
|
||||
#include <egolay.h>
|
||||
#include <itpp/comm/commfunc.h>
|
||||
#include <itpp/base/specmat.h>
|
||||
#include <itpp/base/converters.h>
|
||||
|
||||
namespace itpp {
|
||||
|
||||
My_Extended_Golay::My_Extended_Golay(void)
|
||||
{
|
||||
// B="0 1 1 1 1 1 1 1 1 1 1 1;1 1 1 0 1 1 1 0 0 0 1 0;1 1 0 1 1 1 0 0 0 1 0 1;1 0 1 1 1 0 0 0 1 0 1 1;1 1 1 1 0 0 0 1 0 1 1 0;1 1 1 0 0 0 1 0 1 1 0 1;1 1 0 0 0 1 0 1 1 0 1 1;1 0 0 0 1 0 1 1 0 1 1 1;1 0 0 1 0 1 1 0 1 1 1 0;1 0 1 0 1 1 0 1 1 1 0 0;1 1 0 1 1 0 1 1 1 0 0 0;1 0 1 1 0 1 1 1 0 0 0 1";
|
||||
|
||||
B="1 1 0 0 0 1 1 1 0 1 0 1;0 1 1 0 0 0 1 1 1 0 1 1;1 1 1 1 0 1 1 0 1 0 0 0;0 1 1 1 1 0 1 1 0 1 0 0;0 0 1 1 1 1 0 1 1 0 1 0;1 1 0 1 1 0 0 1 1 0 0 1;0 1 1 0 1 1 0 0 1 1 0 1;0 0 1 1 0 1 1 0 0 1 1 1;1 1 0 1 1 1 0 0 0 1 1 0;1 0 1 0 1 0 0 1 0 1 1 1;1 0 0 1 0 0 1 1 1 1 1 0;1 0 0 0 1 1 1 0 1 0 1 1";
|
||||
|
||||
G = concat_horizontal(eye_b(12), B);
|
||||
}
|
||||
|
||||
void My_Extended_Golay::encode(const bvec &uncoded_bits, bvec &coded_bits)
|
||||
{
|
||||
int no_bits = uncoded_bits.length();
|
||||
int no_blocks = floor_i(no_bits / 12.0);
|
||||
|
||||
coded_bits.set_size(24*no_blocks, false);
|
||||
bmat Gt = G.T();
|
||||
int i;
|
||||
|
||||
for (i=0; i<no_blocks; i++)
|
||||
coded_bits.replace_mid(24*i, Gt * uncoded_bits.mid(i*12,12));
|
||||
}
|
||||
|
||||
bvec My_Extended_Golay::encode(const bvec &uncoded_bits)
|
||||
{
|
||||
bvec coded_bits;
|
||||
encode(uncoded_bits, coded_bits);
|
||||
return coded_bits;
|
||||
}
|
||||
|
||||
void My_Extended_Golay::decode(const bvec &coded_bits, bvec &decoded_bits)
|
||||
{
|
||||
int no_bits = coded_bits.length();
|
||||
int no_blocks = floor_i(no_bits / 24.0);
|
||||
|
||||
decoded_bits.set_size(12*no_blocks, false);
|
||||
int i, j;
|
||||
bvec S(12),BS(12),r(12),temp(12),e(24),c(24);
|
||||
bmat eyetemp = eye_b(12);
|
||||
|
||||
for (i=0; i<no_blocks; i++) {
|
||||
r = coded_bits.mid(i*24,24);
|
||||
// Step 1. Compute S=G*r.
|
||||
S = G*r;
|
||||
// Step 2. w(S)<=3. e=(S,0). Goto 8.
|
||||
if( weight(S) <= 3 ) {
|
||||
e = concat(S, zeros_b(12)); goto Step8;
|
||||
}
|
||||
|
||||
// Step 3. w(S+Ii)<=2. e=(S+Ii,yi). Goto 8.
|
||||
for (j=0; j<12; j++) {
|
||||
|
||||
temp = S + B.get_col(j);
|
||||
if ( weight(temp) <=2 ) {
|
||||
e = concat(temp, eyetemp.get_row(j)); goto Step8;
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 4. Compute B*S
|
||||
BS = B*S;
|
||||
|
||||
// Step 5. w(B*S)<=3. e=(0,BS). Goto8.
|
||||
if ( weight(BS) <=3 ) {
|
||||
e = concat(zeros_b(12), BS); goto Step8;
|
||||
}
|
||||
|
||||
// Step 6. w(BS+Ri)<=2. e=(xi,BS+Ri). Goto 8.
|
||||
for (j=0; j<12; j++) {
|
||||
temp = BS + B.get_row(j);
|
||||
if ( weight(temp) <=2 ) {
|
||||
e = concat(eyetemp.get_row(j), temp); goto Step8;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 7. Uncorrectable erreor pattern. Choose the first 12 bits.
|
||||
e = zeros_b(24); goto Step8;
|
||||
|
||||
Step8: // Step 8. c=r+e. STOP
|
||||
c = r + e;
|
||||
decoded_bits.replace_mid(i*12, c.left(12));
|
||||
}
|
||||
}
|
||||
|
||||
bvec My_Extended_Golay::decode(const bvec &coded_bits)
|
||||
{
|
||||
bvec decoded_bits;
|
||||
decode(coded_bits, decoded_bits);
|
||||
return decoded_bits;
|
||||
}
|
||||
|
||||
|
||||
// -------------- Soft-decision decoding is not implemented ------------------
|
||||
void My_Extended_Golay::decode(const vec &received_signal, bvec &output)
|
||||
{
|
||||
it_error("My_Extended_Golay::decode(vec, bvec); soft-decision decoding is not implemented");
|
||||
}
|
||||
|
||||
bvec My_Extended_Golay::decode(const vec &received_signal)
|
||||
{
|
||||
it_error("My_Extended_Golay::decode(vec, bvec); soft-decision decoding is not implemented");
|
||||
return bvec();
|
||||
}
|
||||
|
||||
|
||||
} // namespace itpp
|
|
@ -0,0 +1,83 @@
|
|||
/*!
|
||||
* \file
|
||||
* \brief Definition of the Extended Golay Code (24, 12, 8)
|
||||
* \author Tony Ottosson
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* IT++ - C++ library of mathematical, signal processing, speech processing,
|
||||
* and communications classes and functions
|
||||
*
|
||||
* Copyright (C) 1995-2008 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef EGOLAY_H
|
||||
#define EGOLAY_H
|
||||
|
||||
#include <itpp/base/vec.h>
|
||||
#include <itpp/base/mat.h>
|
||||
#include <itpp/comm/channel_code.h>
|
||||
|
||||
|
||||
namespace itpp {
|
||||
|
||||
/*!
|
||||
\ingroup fec
|
||||
\brief Extended Golay code (24,12,8).
|
||||
\author Tony Ottosson
|
||||
|
||||
The code is given in systematic form with the information bits
|
||||
first, followed by the parity check bits. The decoder uses the
|
||||
arithmetic decoding algorithm that is for example described in
|
||||
Wicker "Error Control Systems for Digital Communication and
|
||||
Storage", Prentice Hall, 1995 (page 143).
|
||||
*/
|
||||
class My_Extended_Golay : public Channel_Code {
|
||||
public:
|
||||
//! Constructor
|
||||
My_Extended_Golay();
|
||||
//! Destructor
|
||||
virtual ~My_Extended_Golay(){ }
|
||||
|
||||
//! Encoder. Will truncate some bits if not \a length = \c integer * 12
|
||||
virtual void encode(const bvec &uncoded_bits, bvec &coded_bits);
|
||||
//! Encoder. Will truncate some bits if not \a length = \c integer * 12
|
||||
virtual bvec encode(const bvec &uncoded_bits);
|
||||
|
||||
//! Decoder. Will truncate some bits if not \a length = \c integer * 24
|
||||
virtual void decode(const bvec &coded_bits, bvec &decoded_bits);
|
||||
//! Decoder. Will truncate some bits if not \a length = \c integer * 24
|
||||
virtual bvec decode(const bvec &coded_bits);
|
||||
|
||||
// Soft-decision decoding is not implemented
|
||||
virtual void decode(const vec &received_signal, bvec &output);
|
||||
virtual bvec decode(const vec &received_signal);
|
||||
|
||||
//! Get the code rate
|
||||
virtual double get_rate() const { return 0.5; };
|
||||
|
||||
//! Gets the generator matrix for the code (also the parity check matrix)
|
||||
bmat get_G() const { return G; }
|
||||
private:
|
||||
bmat B,G;
|
||||
};
|
||||
|
||||
} // namespace itpp
|
||||
|
||||
#endif // #ifndef EGOLAY_H
|
|
@ -21,15 +21,17 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <egolay.h>
|
||||
#include <hdu.h>
|
||||
#include <iomanip>
|
||||
#include <itpp/comm/egolay.h>
|
||||
#include <iostream>
|
||||
#include <itpp/base/vec.h>
|
||||
// #include <itpp/comm/egolay.h>
|
||||
#include <itpp/comm/reedsolomon.h>
|
||||
#include <sstream>
|
||||
#include <swab.h>
|
||||
#include <value_string.h>
|
||||
#include <yank.h>
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
hdu::hdu(const_bit_queue& frame_body) :
|
||||
|
@ -70,18 +72,6 @@ hdu::snapshot() const
|
|||
os << "p" << n++ << endl;
|
||||
os << "S'" << nac_str() << "'" << endl;
|
||||
|
||||
// Source
|
||||
os << "p" << n++ << endl;
|
||||
os << "sS'source'" << endl;
|
||||
os << "p" << n++ << endl;
|
||||
os << "S'" << src_str() << "'" << endl;
|
||||
|
||||
// Dest
|
||||
os << "p" << n++ << endl;
|
||||
os << "sS'dest'" << endl;
|
||||
os << "p" << n++ << endl;
|
||||
os << "S'" << dest_str() << "'" << endl;
|
||||
|
||||
// MFID
|
||||
os << "p" << n++ << endl;
|
||||
os << "sS'mfid'" << endl;
|
||||
|
@ -129,52 +119,64 @@ hdu::correct_errors(bit_vector& frame)
|
|||
void
|
||||
hdu::apply_golay_correction(bit_vector& frame)
|
||||
{
|
||||
#if 0
|
||||
static itpp::Extended_Golay golay;
|
||||
static const size_t NOF_GOLAY_CODEWORDS = 36, GOLAY_CODEWORD_SZ = 18;
|
||||
static const size_t GOLAY_CODEWORDS[nof_golay_codewords][golay_codeword_sz] = {
|
||||
{ 119, 118, 117, 116, 115, 114, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120 },
|
||||
{ 137, 136, 135, 134, 133, 132, 151, 150, 149, 148, 147, 146, 145, 144, 141, 140, 139, 138 },
|
||||
{ 157, 156, 155, 154, 153, 152, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158 },
|
||||
{ 175, 174, 173, 172, 171, 170, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176 },
|
||||
{ 193, 192, 191, 190, 189, 188, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194 },
|
||||
{ 211, 210, 209, 208, 207, 206, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 213, 212 },
|
||||
{ 231, 230, 229, 228, 227, 226, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232 },
|
||||
{ 249, 248, 247, 246, 245, 244, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250 },
|
||||
{ 267, 266, 265, 264, 263, 262, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268 },
|
||||
{ 285, 284, 283, 282, 281, 280, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288 },
|
||||
{ 305, 304, 303, 302, 301, 300, 317, 316, 315, 314, 313, 312, 311, 310, 309, 308, 307, 306 },
|
||||
{ 323, 322, 321, 320, 319, 318, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324 },
|
||||
{ 341, 340, 339, 338, 337, 336, 353, 352, 351, 350, 349, 348, 347, 346, 345, 344, 343, 342 },
|
||||
{ 361, 360, 357, 356, 355, 354, 373, 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, 362 },
|
||||
{ 379, 378, 377, 376, 375, 374, 391, 390, 389, 388, 387, 386, 385, 384, 383, 382, 381, 380 },
|
||||
{ 397, 396, 395, 394, 393, 392, 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, 399, 398 },
|
||||
{ 415, 414, 413, 412, 411, 410, 427, 426, 425, 424, 423, 422, 421, 420, 419, 418, 417, 416 },
|
||||
{ 435, 434, 433, 432, 429, 428, 447, 446, 445, 444, 443, 442, 441, 440, 439, 438, 437, 436 },
|
||||
{ 453, 452, 451, 450, 449, 448, 465, 464, 463, 462, 461, 460, 459, 458, 457, 456, 455, 454 },
|
||||
{ 471, 470, 469, 468, 467, 466, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472 },
|
||||
{ 489, 488, 487, 486, 485, 484, 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490 },
|
||||
{ 509, 508, 507, 506, 505, 504, 521, 520, 519, 518, 517, 516, 515, 514, 513, 512, 511, 510 },
|
||||
{ 527, 526, 525, 524, 523, 522, 539, 538, 537, 536, 535, 534, 533, 532, 531, 530, 529, 528 },
|
||||
{ 545, 544, 543, 542, 541, 540, 557, 556, 555, 554, 553, 552, 551, 550, 549, 548, 547, 546 },
|
||||
{ 563, 562, 561, 560, 559, 558, 577, 576, 573, 572, 571, 570, 569, 568, 567, 566, 565, 564 },
|
||||
{ 583, 582, 581, 580, 579, 578, 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, 584 },
|
||||
{ 601, 600, 599, 598, 597, 596, 613, 612, 611, 610, 609, 608, 607, 606, 605, 604, 603, 602 },
|
||||
{ 619, 618, 617, 616, 615, 614, 631, 630, 629, 628, 627, 626, 625, 624, 623, 622, 621, 620 },
|
||||
{ 637, 636, 635, 634, 633, 632, 651, 650, 649, 648, 645, 644, 643, 642, 641, 640, 639, 638 },
|
||||
{ 657, 656, 655, 654, 653, 652, 669, 668, 667, 666, 665, 664, 663, 662, 661, 660, 659, 658 },
|
||||
{ 675, 674, 673, 672, 671, 670, 687, 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, 676 },
|
||||
{ 693, 692, 691, 690, 689, 688, 705, 704, 703, 702, 701, 700, 699, 698, 697, 696, 695, 694 },
|
||||
{ 711, 710, 709, 708, 707, 706, 725, 724, 723, 722, 721, 720, 717, 716, 715, 714, 713, 712 },
|
||||
{ 731, 730, 729, 728, 727, 726, 743, 742, 741, 740, 739, 738, 737, 736, 735, 734, 733, 732 },
|
||||
{ 749, 748, 747, 746, 745, 744, 761, 760, 759, 758, 757, 756, 755, 754, 753, 752, 751, 750 },
|
||||
{ 767, 766, 765, 764, 763, 762, 779, 778, 777, 776, 775, 774, 773, 772, 771, 770, 769, 768 }
|
||||
};
|
||||
|
||||
for(size_t i = 0; i < NOF_GOLAY_CODEWORDS; ++i) {
|
||||
// ToDo:
|
||||
}
|
||||
static itpp::My_Extended_Golay golay;
|
||||
static const size_t NOF_GOLAY_CODEWORDS = 2, GOLAY_DATA_SZ = 6, GOLAY_CODEWORD_SZ = 18;
|
||||
// static const size_t NOF_GOLAY_CODEWORDS = 36, GOLAY_DATA_SZ = 6, GOLAY_CODEWORD_SZ = 18;
|
||||
static const size_t GOLAY_CODEWORDS[NOF_GOLAY_CODEWORDS][GOLAY_CODEWORD_SZ] = {
|
||||
#if 1
|
||||
{ 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131 },
|
||||
{ 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114 }
|
||||
#else
|
||||
{ 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131 },
|
||||
{ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 144, 145, 146, 147, 148, 149, 150, 151 },
|
||||
{ 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169 },
|
||||
{ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187 },
|
||||
{ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205 },
|
||||
{ 206, 207, 208, 209, 210, 211, 212, 213, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225 },
|
||||
{ 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243 },
|
||||
{ 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261 },
|
||||
{ 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279 },
|
||||
{ 280, 281, 282, 283, 284, 285, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299 },
|
||||
{ 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317 },
|
||||
{ 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335 },
|
||||
{ 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353 },
|
||||
{ 354, 355, 356, 357, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373 },
|
||||
{ 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391 },
|
||||
{ 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409 },
|
||||
{ 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427 },
|
||||
{ 428, 429, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447 },
|
||||
{ 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465 },
|
||||
{ 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483 },
|
||||
{ 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501 },
|
||||
{ 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521 },
|
||||
{ 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539 },
|
||||
{ 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557 },
|
||||
{ 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 576, 577 },
|
||||
{ 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595 },
|
||||
{ 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613 },
|
||||
{ 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631 },
|
||||
{ 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 648, 649, 650, 651 },
|
||||
{ 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669 },
|
||||
{ 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687 },
|
||||
{ 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705 },
|
||||
{ 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 720, 721, 722, 723, 724, 725 },
|
||||
{ 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743 },
|
||||
{ 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761 },
|
||||
{ 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779 }
|
||||
#endif
|
||||
};
|
||||
for(size_t i = 0; i < NOF_GOLAY_CODEWORDS; ++i) {
|
||||
const size_t PAD_SZ = 6;
|
||||
itpp::bvec b(PAD_SZ + GOLAY_CODEWORD_SZ);
|
||||
b.zeros();
|
||||
yank(frame, GOLAY_CODEWORDS[i], GOLAY_CODEWORD_SZ, b, PAD_SZ);
|
||||
itpp::bvec d(golay.decode(b));
|
||||
// yank_back(d, PAD_SZ, frame, GOLAY_CODEWORDS[i], GOLAY_DATA_SZ);
|
||||
|
||||
clog << " IN:" << b << endl;
|
||||
clog << "OUT:" << d << endl;
|
||||
clog << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -207,16 +209,18 @@ hdu::algid_str() const
|
|||
return lookup(algid, ALGIDS, ALGIDS_SZ);
|
||||
}
|
||||
|
||||
string
|
||||
hdu::dest_str() const
|
||||
{
|
||||
return "ToDo";
|
||||
}
|
||||
|
||||
string
|
||||
hdu::kid_str() const
|
||||
{
|
||||
return "ToDo";
|
||||
const size_t KID_BITS[] = {
|
||||
378, 379, 392, 393, 394, 395, 396, 397,
|
||||
410, 411, 412, 413, 414, 415, 428, 429
|
||||
};
|
||||
const size_t KID_BITS_SZ = sizeof(KID_BITS) / sizeof(KID_BITS[0]);
|
||||
uint16_t kid = extract(frame_body(), KID_BITS, KID_BITS_SZ);
|
||||
ostringstream os;
|
||||
os << hex << showbase << setfill('0') << setw(4) << kid;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string
|
||||
|
@ -238,12 +242,13 @@ hdu::mi_str() const
|
|||
uint8_t mi[9];
|
||||
extract(frame_body(), MI_BITS, MI_BITS_SZ, mi);
|
||||
ostringstream os;
|
||||
os << "0x";
|
||||
for(size_t i = 0; i < (sizeof(mi) / sizeof(mi[0])); ++i) {
|
||||
uint16_t octet = mi[i];
|
||||
os << hex << setfill('0') << setw(2) << octet;
|
||||
}
|
||||
|
||||
clog << os.str() << endl;
|
||||
clog << os.str() << endl; // diagnostix
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
@ -270,14 +275,30 @@ hdu::nac_str() const
|
|||
return lookup(nac, NACS, NACS_SZ);
|
||||
}
|
||||
|
||||
string
|
||||
hdu::src_str() const
|
||||
{
|
||||
return "ToDo";
|
||||
}
|
||||
|
||||
string
|
||||
hdu::tgid_str() const
|
||||
{
|
||||
return "ToDo";
|
||||
const size_t TGID_BITS[] = {
|
||||
432,
|
||||
433,
|
||||
434,
|
||||
435,
|
||||
448,
|
||||
449,
|
||||
450,
|
||||
451,
|
||||
452,
|
||||
453,
|
||||
466,
|
||||
467,
|
||||
468,
|
||||
469,
|
||||
470,
|
||||
471
|
||||
};
|
||||
const size_t TGID_BITS_SZ = sizeof(TGID_BITS) / sizeof(TGID_BITS[0]);
|
||||
const uint16_t tgid = extract(frame_body(), TGID_BITS, TGID_BITS_SZ);
|
||||
ostringstream os;
|
||||
os << hex << showbase << setfill('0') << setw(4) << tgid;
|
||||
return os.str();
|
||||
}
|
||||
|
|
|
@ -105,13 +105,6 @@ private:
|
|||
*/
|
||||
std::string algid_str() const;
|
||||
|
||||
/**
|
||||
* Returns a string describing the message destination.
|
||||
*
|
||||
* \return A string identifying the source.
|
||||
*/
|
||||
virtual std::string dest_str() const;
|
||||
|
||||
/**
|
||||
* Returns a string describing the key id (KID).
|
||||
*
|
||||
|
@ -140,13 +133,6 @@ private:
|
|||
*/
|
||||
virtual std::string nac_str() const;
|
||||
|
||||
/**
|
||||
* Returns a string describing the message source.
|
||||
*
|
||||
* \return A string identifying the source.
|
||||
*/
|
||||
virtual std::string src_str() const;
|
||||
|
||||
/**
|
||||
* Returns a string describing the talk group id (TGID).
|
||||
*
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <stdint.h>
|
||||
#include <swab.h>
|
||||
#include <offline_imbe_decoder.h>
|
||||
#include <stdint.h>
|
||||
#include <yank.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ GR_SWIG_BLOCK_MAGIC(op25, decoder_ff);
|
|||
op25_decoder_ff_sptr op25_make_decoder_ff(gr_msg_queue_sptr msgq);
|
||||
|
||||
/*
|
||||
* The actual op25_decoder block.
|
||||
* The op25_decoder block.
|
||||
*/
|
||||
class op25_decoder_ff : public gr_block
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <logfile_du_handler.h>
|
||||
#include <op25_decoder_ff.h>
|
||||
#include <snapshot_du_handler.h>
|
||||
#include <yank.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -122,7 +123,7 @@ op25_decoder_ff::correlated()
|
|||
++errs;
|
||||
}
|
||||
}
|
||||
return (errs <= 6);
|
||||
return (errs <= 4);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -142,12 +143,12 @@ op25_decoder_ff::identified()
|
|||
|
||||
itpp::bvec b(63), zeroes(16);
|
||||
itpp::BCH bch(63, 16, 11,"6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true);
|
||||
swab(d_frame_hdr, NID, NID_SZ, b, 0);
|
||||
yank(d_frame_hdr, NID, NID_SZ, b, 0);
|
||||
b = bch.decode(b);
|
||||
bool identified(b != zeroes);
|
||||
if(identified) {
|
||||
b = bch.encode(b);
|
||||
unswab(b, 0, d_frame_hdr, NID, NID_SZ);
|
||||
yank_back(b, 0, d_frame_hdr, NID, NID_SZ);
|
||||
d_data_unit = data_unit::make_data_unit(d_frame_hdr);
|
||||
} else {
|
||||
data_unit_sptr null;
|
||||
|
@ -184,6 +185,7 @@ op25_decoder_ff::receive_symbol(dibit d)
|
|||
case READING:
|
||||
d_data_unit->extend(d);
|
||||
if(d_data_unit->is_complete()) {
|
||||
d_data_unit->correct_errors();
|
||||
d_data_unit_handler->handle(d_data_unit);
|
||||
data_unit_sptr null;
|
||||
d_data_unit = null;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <snapshot_du_handler.h>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "sniffer_du_handler.h"
|
||||
|
||||
#include <net/if.h>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <linux/if_tun.h>
|
||||
#include <net/if.h>
|
||||
#include <sniffer_du_handler.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
sniffer_du_handler::sniffer_du_handler(data_unit_handler_sptr next) :
|
||||
data_unit_handler(next),
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <itpp/base/vec.h>
|
||||
#include <itpp/comm/egolay.h>
|
||||
#include <itpp/comm/reedsolomon.h>
|
||||
#include <swab.h>
|
||||
#include <tdu.h>
|
||||
#include <yank.h>
|
||||
|
||||
using std::string;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ lookup(uint16_t value, const value_string mappings[], size_t mappings_sz)
|
|||
}
|
||||
}
|
||||
ostringstream os;
|
||||
os << "Unknown (" << hex << value << ")";
|
||||
os << "Unknown (" << hex << showbase << value << ")";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cerrno>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
#include <swab.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
#include <vc55_imbe_decoder.h>
|
||||
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
#ifndef INCLUDED_SWAB_H
|
||||
#define INCLUDED_SWAB_H
|
||||
|
||||
#include <bitset>
|
||||
#include <itpp/base/vec.h>
|
||||
#include <vector>
|
||||
|
||||
typedef std::vector<bool> bit_vector;
|
||||
typedef const std::vector<bool> const_bit_vector;
|
||||
|
||||
/**
|
||||
* Swab in[bits[0)..bits[bits_sz)) to out[where..where+bits_sz).
|
||||
* Yank in[bits[0]..bits[bits_sz]) to out[where,where+bits_sz).
|
||||
*
|
||||
* \param in A const reference to the source.
|
||||
* \param bits An array specifying the ordinals of the bits to copy.
|
||||
|
@ -18,7 +11,7 @@ typedef const std::vector<bool> const_bit_vector;
|
|||
* \param where The offset of the first bit to write.
|
||||
*/
|
||||
template <class X, class Y>
|
||||
void swab(const X& in, const size_t bits[], size_t bits_sz, Y& out, size_t where)
|
||||
void yank(const X& in, const size_t bits[], size_t bits_sz, Y& out, size_t where)
|
||||
{
|
||||
for(size_t i = 0; i < bits_sz; ++i) {
|
||||
out[where+i] = in[bits[i]];
|
||||
|
@ -26,7 +19,7 @@ void swab(const X& in, const size_t bits[], size_t bits_sz, Y& out, size_t where
|
|||
}
|
||||
|
||||
/**
|
||||
* Swab from in[0..bits_sz) to out[bits[0)..bits[bits_sz)).
|
||||
* Yank back from in[where,where+bits_sz) to out[bits[0]..bits[bits_sz]).
|
||||
*
|
||||
* \param in A const reference to the source.
|
||||
* \param where The offset of the first bit to read.
|
||||
|
@ -35,7 +28,7 @@ void swab(const X& in, const size_t bits[], size_t bits_sz, Y& out, size_t where
|
|||
* \param bits_sz The size of the bits array.
|
||||
*/
|
||||
template <class X, class Y>
|
||||
void unswab(const X& in, size_t where, Y& out, const size_t bits[], size_t bits_sz)
|
||||
void yank_back(const X& in, size_t where, Y& out, const size_t bits[], size_t bits_sz)
|
||||
{
|
||||
for(size_t i = 0; i < bits_sz; ++i) {
|
||||
out[bits[i]] = in[where+i];
|
||||
|
@ -55,7 +48,7 @@ template<class X>
|
|||
size_t extract(const X& in, int begin, int end, uint8_t *out)
|
||||
{
|
||||
const size_t out_sz = (7 + end - begin) / 8;
|
||||
memset(out, 0, out_sz);
|
||||
std::fill(out, out + out_sz, 0);
|
||||
for(int i = begin, j = 0; i < end; ++i, ++j) {
|
||||
out[j / 8] ^= in[i] << (7 - (j % 8));
|
||||
}
|
||||
|
@ -75,7 +68,7 @@ template<class X>
|
|||
size_t extract(const X& in, const size_t bits[], size_t bits_sz, uint8_t *out)
|
||||
{
|
||||
const size_t out_sz = (7 + bits_sz) / 8;
|
||||
memset(out, 0, out_sz);
|
||||
std::fill(out, out + out_sz, 0);
|
||||
for(size_t i = 0; i < bits_sz; ++i) {
|
||||
out[i / 8] ^= in[bits[i]] << (7 - (i % 8));
|
||||
}
|
Reference in New Issue