mirror of https://gerrit.osmocom.org/osmo-tetra
use ubit_dump() which is part of libosmocore instead of local bitdump()
This commit is contained in:
parent
cea678608f
commit
140c2f80c1
|
@ -56,19 +56,19 @@ static void decode_schf(const uint8_t *bits)
|
|||
uint8_t type3[1024];
|
||||
uint8_t type2[1024];
|
||||
|
||||
printf("SCH/f type5: %s\n", bitdump(bits, 432));
|
||||
printf("SCH/f type5: %s\n", ubit_dump(bits, 432));
|
||||
memcpy(type4, bits, 432);
|
||||
tetra_scramb_bits(SCRAMB_INIT, type4, 432);
|
||||
printf("SCH/F type4: %s\n", bitdump(type4, 432));
|
||||
printf("SCH/F type4: %s\n", ubit_dump(type4, 432));
|
||||
/* Run (120,11) block deinterleaving: type-3 bits */
|
||||
block_deinterleave(432, 103, type4, type3);
|
||||
printf("SCH/F type3: %s\n", bitdump(type3, 432));
|
||||
printf("SCH/F type3: %s\n", ubit_dump(type3, 432));
|
||||
/* De-puncture */
|
||||
memset(type3dp, 0xff, sizeof(type3dp));
|
||||
tetra_rcpc_depunct(TETRA_RCPC_PUNCT_2_3, type3, 432, type3dp);
|
||||
printf("SCH/F type3dp: %s\n", bitdump(type3dp, 288*4));
|
||||
printf("SCH/F type3dp: %s\n", ubit_dump(type3dp, 288*4));
|
||||
viterbi_dec_sb1_wrapper(type3dp, type2, 288);
|
||||
printf("SCH/F type2: %s\n", bitdump(type2, 288));
|
||||
printf("SCH/F type2: %s\n", ubit_dump(type2, 288));
|
||||
|
||||
{
|
||||
uint16_t crc;
|
||||
|
@ -81,7 +81,7 @@ static void decode_schf(const uint8_t *bits)
|
|||
num_crc_err++;
|
||||
}
|
||||
}
|
||||
printf("SCH/F type1: %s\n", bitdump(type2, 268));
|
||||
printf("SCH/F type1: %s\n", ubit_dump(type2, 268));
|
||||
}
|
||||
|
||||
/* Build a full 'downlink continuous SYNC burst' from SYSINFO-PDU and SYNC-PDU */
|
||||
|
@ -112,7 +112,7 @@ int build_ndb_schf()
|
|||
/* Append 4 tail bits: type-2 bits */
|
||||
cur += 4;
|
||||
|
||||
printf("SCH/F type2: %s\n", bitdump(type2, 288));
|
||||
printf("SCH/F type2: %s\n", ubit_dump(type2, 288));
|
||||
|
||||
/* Run rate 2/3 RCPC code: type-3 bits*/
|
||||
{
|
||||
|
@ -122,22 +122,22 @@ int build_ndb_schf()
|
|||
get_punctured_rate(TETRA_RCPC_PUNCT_2_3, master, 432, type3);
|
||||
free(ces);
|
||||
}
|
||||
printf("SCH/F type3: %s\n", bitdump(type3, 432));
|
||||
printf("SCH/F type3: %s\n", ubit_dump(type3, 432));
|
||||
|
||||
/* Run (432,103) block interleaving: type-4 bits */
|
||||
block_interleave(432, 103, type3, type4);
|
||||
printf("SCH/F type4: %s\n", bitdump(type4, 432));
|
||||
printf("SCH/F type4: %s\n", ubit_dump(type4, 432));
|
||||
|
||||
/* Run scrambling (all-zero): type-5 bits */
|
||||
memcpy(type5, type4, 432);
|
||||
tetra_scramb_bits(SCRAMB_INIT, type5, 432);
|
||||
printf("SCH/F type5: %s\n", bitdump(type5, 432));
|
||||
printf("SCH/F type5: %s\n", ubit_dump(type5, 432));
|
||||
|
||||
decode_schf(type5);
|
||||
|
||||
/* Use pdu_acc_ass from testpdu.c */
|
||||
/* Run it through (30,14) RM code: type-2=3=4 bits */
|
||||
printf("AACH type-1: %s\n", bitdump(pdu_acc_ass, 2));
|
||||
printf("AACH type-1: %s\n", ubit_dump(pdu_acc_ass, 2));
|
||||
bb_rm3014 = tetra_rm3014_compute(*(uint16_t *)pdu_acc_ass);
|
||||
printf("AACH RM3014: 0x0%x\n", bb_rm3014);
|
||||
/* convert to big endian */
|
||||
|
@ -146,11 +146,11 @@ int build_ndb_schf()
|
|||
bb_rm3014_be <<= 2;
|
||||
osmo_pbit2ubit(bb_type5, (uint8_t *) &bb_rm3014_be, 30);
|
||||
/* Run scrambling (all-zero): type-5 bits */
|
||||
printf("AACH type-5: %s\n", bitdump(bb_type5, 30));
|
||||
printf("AACH type-5: %s\n", ubit_dump(bb_type5, 30));
|
||||
|
||||
/* Finally, hand it into the physical layer */
|
||||
build_norm_c_d_burst(burst, type5, bb_type5, type5+216, 0);
|
||||
printf("cont norm DL burst: %s\n", bitdump(burst, 255*2));
|
||||
printf("cont norm DL burst: %s\n", ubit_dump(burst, 255*2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -163,19 +163,19 @@ static void decode_sb1(const uint8_t *bits)
|
|||
uint8_t type3[1024];
|
||||
uint8_t type2[1024];
|
||||
|
||||
printf("SB1 type5: %s\n", bitdump(bits, 120));
|
||||
printf("SB1 type5: %s\n", ubit_dump(bits, 120));
|
||||
memcpy(type4, bits, 120);
|
||||
tetra_scramb_bits(SCRAMB_INIT, type4, 120);
|
||||
printf("SB1 type4: %s\n", bitdump(type4, 120));
|
||||
printf("SB1 type4: %s\n", ubit_dump(type4, 120));
|
||||
/* Run (120,11) block deinterleaving: type-3 bits */
|
||||
block_deinterleave(120, 11, type4, type3);
|
||||
printf("SB1 type3: %s\n", bitdump(type3, 120));
|
||||
printf("SB1 type3: %s\n", ubit_dump(type3, 120));
|
||||
/* De-puncture */
|
||||
memset(type3dp, 0xff, sizeof(type3dp));
|
||||
tetra_rcpc_depunct(TETRA_RCPC_PUNCT_2_3, type3, 120, type3dp);
|
||||
printf("SB1 type3dp: %s\n", bitdump(type3dp, 80*4));
|
||||
printf("SB1 type3dp: %s\n", ubit_dump(type3dp, 80*4));
|
||||
viterbi_dec_sb1_wrapper(type3dp, type2, 80);
|
||||
printf("SB1 type2: %s\n", bitdump(type2, 80));
|
||||
printf("SB1 type2: %s\n", ubit_dump(type2, 80));
|
||||
|
||||
{
|
||||
uint16_t crc;
|
||||
|
@ -189,9 +189,9 @@ static void decode_sb1(const uint8_t *bits)
|
|||
}
|
||||
}
|
||||
|
||||
printf("TN %s ", bitdump(type2+10, 2));
|
||||
printf("MCC %s ", bitdump(type2+31, 10));
|
||||
printf("MNC %s\n", bitdump(type2+41, 14));
|
||||
printf("TN %s ", ubit_dump(type2+10, 2));
|
||||
printf("MCC %s ", ubit_dump(type2+31, 10));
|
||||
printf("MNC %s\n", ubit_dump(type2+41, 14));
|
||||
}
|
||||
|
||||
/* Build a full 'downlink continuous SYNC burst' from SYSINFO-PDU and SYNC-PDU */
|
||||
|
@ -228,7 +228,7 @@ int build_sb()
|
|||
/* Append 4 tail bits: type-2 bits */
|
||||
cur += 4;
|
||||
|
||||
printf("SYNC type2: %s\n", bitdump(sb_type2, 80));
|
||||
printf("SYNC type2: %s\n", ubit_dump(sb_type2, 80));
|
||||
|
||||
/* Run rate 2/3 RCPC code: type-3 bits*/
|
||||
{
|
||||
|
@ -238,16 +238,16 @@ int build_sb()
|
|||
get_punctured_rate(TETRA_RCPC_PUNCT_2_3, sb_master, 120, sb_type3);
|
||||
free(ces);
|
||||
}
|
||||
printf("SYNC type3: %s\n", bitdump(sb_type3, 120));
|
||||
printf("SYNC type3: %s\n", ubit_dump(sb_type3, 120));
|
||||
|
||||
/* Run (120,11) block interleaving: type-4 bits */
|
||||
block_interleave(120, 11, sb_type3, sb_type4);
|
||||
printf("SYNC type4: %s\n", bitdump(sb_type4, 120));
|
||||
printf("SYNC type4: %s\n", ubit_dump(sb_type4, 120));
|
||||
|
||||
/* Run scrambling (all-zero): type-5 bits */
|
||||
memcpy(sb_type5, sb_type4, 120);
|
||||
tetra_scramb_bits(SCRAMB_INIT, sb_type5, 120);
|
||||
printf("SYNC type5: %s\n", bitdump(sb_type5, 120));
|
||||
printf("SYNC type5: %s\n", ubit_dump(sb_type5, 120));
|
||||
|
||||
decode_sb1(sb_type5);
|
||||
|
||||
|
@ -264,7 +264,7 @@ int build_sb()
|
|||
/* Append 4 tail bits: type-2 bits */
|
||||
cur += 4;
|
||||
|
||||
printf("SI type2: %s\n", bitdump(si_type2, 140));
|
||||
printf("SI type2: %s\n", ubit_dump(si_type2, 140));
|
||||
|
||||
/* Run rate 2/3 RCPC code: type-3 bits */
|
||||
{
|
||||
|
@ -274,11 +274,11 @@ int build_sb()
|
|||
get_punctured_rate(TETRA_RCPC_PUNCT_2_3, si_master, 216, si_type3);
|
||||
free(ces);
|
||||
}
|
||||
printf("SI type3: %s\n", bitdump(si_type3, 216));
|
||||
printf("SI type3: %s\n", ubit_dump(si_type3, 216));
|
||||
|
||||
/* Run (216,101) block interleaving: type-4 bits */
|
||||
block_interleave(216, 101, si_type3, si_type4);
|
||||
printf("SI type4: %s\n", bitdump(si_type4, 216));
|
||||
printf("SI type4: %s\n", ubit_dump(si_type4, 216));
|
||||
|
||||
/* Run scrambling (all-zero): type-5 bits */
|
||||
memcpy(si_type5, si_type4, 216);
|
||||
|
@ -286,7 +286,7 @@ int build_sb()
|
|||
|
||||
/* Use pdu_acc_ass from testpdu.c */
|
||||
/* Run it through (30,14) RM code: type-2=3=4 bits */
|
||||
printf("AACH type-1: %s\n", bitdump(pdu_acc_ass, 2));
|
||||
printf("AACH type-1: %s\n", ubit_dump(pdu_acc_ass, 2));
|
||||
bb_rm3014 = tetra_rm3014_compute(*(uint16_t *)pdu_acc_ass);
|
||||
printf("AACH RM3014: 0x0%x\n", bb_rm3014);
|
||||
/* convert to big endian */
|
||||
|
@ -295,11 +295,11 @@ int build_sb()
|
|||
bb_rm3014_be <<= 2;
|
||||
osmo_pbit2ubit(bb_type5, (uint8_t *) &bb_rm3014_be, 30);
|
||||
/* Run scrambling (all-zero): type-5 bits */
|
||||
printf("AACH type-5: %s\n", bitdump(bb_type5, 30));
|
||||
printf("AACH type-5: %s\n", ubit_dump(bb_type5, 30));
|
||||
|
||||
/* Finally, hand it into the physical layer */
|
||||
build_sync_c_d_burst(burst, sb_type5, bb_type5, si_type5);
|
||||
printf("cont sync DL burst: %s\n", bitdump(burst, 255*2));
|
||||
printf("cont sync DL burst: %s\n", ubit_dump(burst, 255*2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
|||
}
|
||||
|
||||
printf("%s %s type5: %s\n", tbp->name, tetra_tdma_time_dump(&tcd->time),
|
||||
bitdump(bits, tbp->type345_bits));
|
||||
ubit_dump(bits, tbp->type345_bits));
|
||||
|
||||
/* De-scramble, pay special attention to SB1 pre-defined scrambling */
|
||||
memcpy(type4, bits, tbp->type345_bits);
|
||||
|
@ -177,21 +177,21 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
|||
}
|
||||
|
||||
printf("%s %s type4: %s\n", tbp->name, time_str,
|
||||
bitdump(type4, tbp->type345_bits));
|
||||
ubit_dump(type4, tbp->type345_bits));
|
||||
|
||||
if (tbp->interleave_a) {
|
||||
/* Run block deinterleaving: type-3 bits */
|
||||
block_deinterleave(tbp->type345_bits, tbp->interleave_a, type4, type3);
|
||||
printf("%s %s type3: %s\n", tbp->name, time_str,
|
||||
bitdump(type3, tbp->type345_bits));
|
||||
ubit_dump(type3, tbp->type345_bits));
|
||||
/* De-puncture */
|
||||
memset(type3dp, 0xff, sizeof(type3dp));
|
||||
tetra_rcpc_depunct(TETRA_RCPC_PUNCT_2_3, type3, tbp->type345_bits, type3dp);
|
||||
printf("%s %s type3dp: %s\n", tbp->name, time_str,
|
||||
bitdump(type3dp, tbp->type2_bits*4));
|
||||
ubit_dump(type3dp, tbp->type2_bits*4));
|
||||
viterbi_dec_sb1_wrapper(type3dp, type2, tbp->type2_bits);
|
||||
printf("%s %s type2: %s\n", tbp->name, time_str,
|
||||
bitdump(type2, tbp->type2_bits));
|
||||
ubit_dump(type2, tbp->type2_bits));
|
||||
}
|
||||
|
||||
if (tbp->have_crc16) {
|
||||
|
@ -201,7 +201,7 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
|||
printf("OK\n");
|
||||
tup->crc_ok = 1;
|
||||
printf("%s %s type1: %s\n", tbp->name, time_str,
|
||||
bitdump(type2, tbp->type1_bits));
|
||||
ubit_dump(type2, tbp->type1_bits));
|
||||
} else
|
||||
printf("WRONG\n");
|
||||
}
|
||||
|
@ -211,12 +211,12 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
|||
|
||||
switch (type) {
|
||||
case TPSAP_T_SB1:
|
||||
printf("TMB-SAP SYNC CC %s(0x%02x) ", bitdump(type2+4, 6), bits_to_uint(type2+4, 6));
|
||||
printf("TN %s(%u) ", bitdump(type2+10, 2), bits_to_uint(type2+10, 2));
|
||||
printf("FN %s(%2u) ", bitdump(type2+12, 5), bits_to_uint(type2+12, 5));
|
||||
printf("MN %s(%2u) ", bitdump(type2+17, 6), bits_to_uint(type2+17, 6));
|
||||
printf("MCC %s(%u) ", bitdump(type2+31, 10), bits_to_uint(type2+31, 10));
|
||||
printf("MNC %s(%u)\n", bitdump(type2+41, 14), bits_to_uint(type2+41, 14));
|
||||
printf("TMB-SAP SYNC CC %s(0x%02x) ", ubit_dump(type2+4, 6), bits_to_uint(type2+4, 6));
|
||||
printf("TN %s(%u) ", ubit_dump(type2+10, 2), bits_to_uint(type2+10, 2));
|
||||
printf("FN %s(%2u) ", ubit_dump(type2+12, 5), bits_to_uint(type2+12, 5));
|
||||
printf("MN %s(%2u) ", ubit_dump(type2+17, 6), bits_to_uint(type2+17, 6));
|
||||
printf("MCC %s(%u) ", ubit_dump(type2+31, 10), bits_to_uint(type2+31, 10));
|
||||
printf("MNC %s(%u)\n", ubit_dump(type2+41, 14), bits_to_uint(type2+41, 14));
|
||||
/* obtain information from SYNC PDU */
|
||||
tcd->colour_code = bits_to_uint(type2+4, 6);
|
||||
tcd->time.tn = bits_to_uint(type2+10, 2);
|
||||
|
@ -238,7 +238,7 @@ void tp_sap_udata_ind(enum tp_sap_data_type type, const uint8_t *bits, unsigned
|
|||
/* FIXME: RM3014-decode */
|
||||
tup->crc_ok = 1;
|
||||
memcpy(tup->mac_block, type4, tbp->type1_bits);
|
||||
printf("%s %s type1: %s\n", tbp->name, time_str, bitdump(tup->mac_block, tbp->type1_bits));
|
||||
printf("%s %s type1: %s\n", tbp->name, time_str, ubit_dump(tup->mac_block, tbp->type1_bits));
|
||||
tup->lchan = TETRA_LC_AACH;
|
||||
break;
|
||||
case TPSAP_T_SCH_F:
|
||||
|
|
|
@ -100,7 +100,7 @@ int tetra_burst_sync_in(struct tetra_rx_state *trs, uint8_t *bits, unsigned int
|
|||
} else {
|
||||
/* we have successfully received (at least) one frame */
|
||||
tetra_tdma_time_add_tn(&t_phy_state.time, 1);
|
||||
printf("\nBURST: %s\n", bitdump(trs->bitbuf, TETRA_BITS_PER_TS));
|
||||
printf("\nBURST: %s\n", ubit_dump(trs->bitbuf, TETRA_BITS_PER_TS));
|
||||
rc = tetra_find_train_seq(trs->bitbuf, trs->bits_in_buf,
|
||||
(1 << TETRA_TRAIN_NORM_1)|
|
||||
(1 << TETRA_TRAIN_NORM_2)|
|
||||
|
|
|
@ -38,37 +38,6 @@ uint32_t bits_to_uint(const uint8_t *bits, unsigned int len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
const char *bitdump(const uint8_t *bits, unsigned int len)
|
||||
{
|
||||
int i;
|
||||
static char hexd_buff[4096];
|
||||
|
||||
if (len > sizeof(hexd_buff)-1)
|
||||
len = sizeof(hexd_buff)-1;
|
||||
memset(hexd_buff, 0, sizeof(hexd_buff));
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
char outch;
|
||||
switch (bits[i]) {
|
||||
case 0:
|
||||
outch = '0';
|
||||
break;
|
||||
case 0xff:
|
||||
outch = '?';
|
||||
break;
|
||||
case 1:
|
||||
outch = '1';
|
||||
break;
|
||||
default:
|
||||
outch = 'E';
|
||||
break;
|
||||
}
|
||||
hexd_buff[i] = outch;
|
||||
}
|
||||
hexd_buff[sizeof(hexd_buff)-1] = 0;
|
||||
return hexd_buff;
|
||||
}
|
||||
|
||||
static inline uint32_t tetra_band_base_hz(uint8_t band)
|
||||
{
|
||||
return (band * 100000000);
|
||||
|
|
|
@ -32,7 +32,6 @@ enum tetra_log_chan {
|
|||
/* FIXME: QAM */
|
||||
};
|
||||
|
||||
const char *bitdump(const uint8_t *bits, unsigned int len);
|
||||
uint32_t bits_to_uint(const uint8_t *bits, unsigned int len);
|
||||
|
||||
#include "tetra_tdma.h"
|
||||
|
|
|
@ -85,7 +85,7 @@ static int rx_tm_sdu(uint8_t *bits, unsigned int len)
|
|||
uint8_t mle_pdisc = bits_to_uint(bits, 3);
|
||||
|
||||
printf("TM-SDU(%s): %s", tetra_get_mle_pdisc_name(mle_pdisc),
|
||||
bitdump(bits, len));
|
||||
ubit_dump(bits, len));
|
||||
switch (mle_pdisc) {
|
||||
case TMLE_PDISC_MM:
|
||||
printf(" %s", tetra_get_mm_pdut_name(bits_to_uint(bits+3, 4), 0));
|
||||
|
|
Loading…
Reference in New Issue