mac_sch_pdu_nr: add unpacking of TA CE in DL-SCH

also add basic test to verify correct unpacking
master
Andre Puschmann 4 years ago
parent 9b7060a098
commit 6dd8c21073

@ -79,6 +79,13 @@ public:
static const uint8_t max_num_lcg_lbsr = 8; static const uint8_t max_num_lcg_lbsr = 8;
std::array<lcg_bsr_t, max_num_lcg_lbsr> get_lbsr(); std::array<lcg_bsr_t, max_num_lcg_lbsr> get_lbsr();
// TA
struct ta_t {
uint8_t tag_id;
uint8_t ta_command;
};
ta_t get_ta();
// setters // setters
void set_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_); void set_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_);
void set_padding(const uint32_t len_); void set_padding(const uint32_t len_);

@ -218,6 +218,16 @@ uint8_t mac_sch_subpdu_nr::get_pcmax()
return 0; return 0;
} }
mac_sch_subpdu_nr::ta_t mac_sch_subpdu_nr::get_ta()
{
ta_t ta = {};
if (lcid == TA_CMD) {
ta.tag_id = (sdu[0] & 0xc0) >> 6;
ta.ta_command = sdu[0] & 0x3f;
}
return ta;
}
mac_sch_subpdu_nr::lcg_bsr_t mac_sch_subpdu_nr::get_sbsr() mac_sch_subpdu_nr::lcg_bsr_t mac_sch_subpdu_nr::get_sbsr()
{ {
lcg_bsr_t sbsr = {}; lcg_bsr_t sbsr = {};

@ -326,6 +326,26 @@ int mac_rar_pdu_unpack_test8()
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }
int mac_dl_sch_pdu_unpack_test9()
{
// MAC PDU with Timing Advance CE and padding
uint8_t tv[] = {0x3d, 0x1f, 0x3f, 0x00, 0x00, 0x00};
if (pcap_handle) {
pcap_handle->write_dl_crnti_nr(tv, sizeof(tv), PCAP_CRNTI, true, PCAP_TTI);
}
srsran::mac_sch_pdu_nr pdu;
pdu.unpack(tv, sizeof(tv));
TESTASSERT(pdu.get_num_subpdus() == 2);
mac_sch_subpdu_nr subpdu = pdu.get_subpdu(0);
TESTASSERT(subpdu.get_ta().tag_id == 0);
TESTASSERT(subpdu.get_ta().ta_command == 31);
return SRSRAN_SUCCESS;
}
int mac_ul_sch_pdu_unpack_test1() int mac_ul_sch_pdu_unpack_test1()
{ {
// UL-SCH MAC PDU with fixed-size CE and DL-SCH subheader with 16-bit length field // UL-SCH MAC PDU with fixed-size CE and DL-SCH subheader with 16-bit length field
@ -657,6 +677,11 @@ int main(int argc, char** argv)
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
if (mac_dl_sch_pdu_unpack_test9()) {
fprintf(stderr, "mac_dl_sch_pdu_unpack_test9() failed.\n");
return SRSRAN_ERROR;
}
if (mac_ul_sch_pdu_unpack_test1()) { if (mac_ul_sch_pdu_unpack_test1()) {
fprintf(stderr, "mac_ul_sch_pdu_unpack_test1() failed.\n"); fprintf(stderr, "mac_ul_sch_pdu_unpack_test1() failed.\n");
return SRSRAN_ERROR; return SRSRAN_ERROR;

Loading…
Cancel
Save