From 1897f03d4c854a0b74a92eb1f846ee1f0f81382b Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 5 Feb 2013 23:59:46 +0100 Subject: calib: Attempt to follow the PCH as well and print the SAPI.. AGCH is reported as part of the PCH because we are not searching for the BS-AG-BLKS-RES inside the SI3 and do not use MphConfigReq to change this setting. --- contrib/sysmobts-calib/sysmobts-calib.c | 44 +++++++++++++++++++++++++++++--- contrib/sysmobts-calib/sysmobts-layer1.c | 27 ++++++++++++++------ contrib/sysmobts-calib/sysmobts-layer1.h | 3 ++- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/contrib/sysmobts-calib/sysmobts-calib.c b/contrib/sysmobts-calib/sysmobts-calib.c index 3cfe7d8d..053032d5 100644 --- a/contrib/sysmobts-calib/sysmobts-calib.c +++ b/contrib/sysmobts-calib/sysmobts-calib.c @@ -43,12 +43,14 @@ enum actions { ACTION_SCAN, ACTION_CALIB, ACTION_BCCH, + ACTION_BCCH_CCCH, }; static const char *modes[] = { [ACTION_SCAN] = "scan", [ACTION_CALIB] = "calibrate", [ACTION_BCCH] = "bcch", + [ACTION_BCCH_CCCH] = "bcch_ccch", }; static const char *bands[] = { @@ -82,6 +84,32 @@ static const char *clk_source[] = { [SuperFemto_ClkSrcId_NetList] = "netlisten", }; +static const struct value_string sapi_names[GsmL1_Sapi_NUM+1] = { + { GsmL1_Sapi_Fcch, "FCCH" }, + { GsmL1_Sapi_Sch, "SCH" }, + { GsmL1_Sapi_Sacch, "SACCH" }, + { GsmL1_Sapi_Sdcch, "SDCCH" }, + { GsmL1_Sapi_Bcch, "BCCH" }, + { GsmL1_Sapi_Pch, "PCH" }, + { GsmL1_Sapi_Agch, "AGCH" }, + { GsmL1_Sapi_Cbch, "CBCH" }, + { GsmL1_Sapi_Rach, "RACH" }, + { GsmL1_Sapi_TchF, "TCH/F" }, + { GsmL1_Sapi_FacchF, "FACCH/F" }, + { GsmL1_Sapi_TchH, "TCH/H" }, + { GsmL1_Sapi_FacchH, "FACCH/H" }, + { GsmL1_Sapi_Nch, "NCH" }, + { GsmL1_Sapi_Pdtch, "PDTCH" }, + { GsmL1_Sapi_Pacch, "PACCH" }, + { GsmL1_Sapi_Pbcch, "PBCCH" }, + { GsmL1_Sapi_Pagch, "PAGCH" }, + { GsmL1_Sapi_Ppch, "PPCH" }, + { GsmL1_Sapi_Pnch, "PNCH" }, + { GsmL1_Sapi_Ptcch, "PTCCH" }, + { GsmL1_Sapi_Prach, "PRACH" }, + { 0, NULL } +}; + static int action = ACTION_SCAN; static int band = GsmL1_FreqBand_900; static int calib = SuperFemto_ClkSrcId_Ocxo; @@ -104,7 +132,7 @@ static void print_help(void) printf(" -s --calibration-source " "ocxo|tcxo|external|gps|trx|rx|edge|netlisten\n"); printf(" -b --band 850|900|1800|1900\n"); - printf(" -m --mode scan|calibrate|bcch\n"); + printf(" -m --mode scan|calibrate|bcch|bcch_ccch\n"); printf(" -a --arfcn NR arfcn for calibration\n"); printf(" -d --dsp-flags NR dsp mask for debug log\n"); printf(" -t --threshold level\n"); @@ -434,6 +462,12 @@ static int bcch_follow(void) rc = follow_bcch(layer1); CHECK_RC_MSG(rc, "Follow BCCH"); + /* follow the pch */ + if (action == ACTION_BCCH_CCCH) { + rc = follow_pch(layer1); + CHECK_RC_MSG(rc, "Follow BCCH/CCCH"); + } + /* now wait for the PhDataInd */ for (;;) { uint32_t fn; @@ -441,15 +475,17 @@ static int bcch_follow(void) uint8_t data[23]; size_t size; struct gsm_time gsmtime; + GsmL1_Sapi_t sapi; - rc = wait_for_data(data, &size, &fn, &block); + rc = wait_for_data(data, &size, &fn, &block, &sapi); if (rc == 1) continue; CHECK_RC_MSG(rc, "No Data Indication"); gsm_fn2gsmtime(&gsmtime, fn); - printf("%02u/%02u/%02u %s\n", + printf("%02u/%02u/%02u %6s %s\n", gsmtime.t1, gsmtime.t2, gsmtime.t3, + get_value_string(sapi_names, sapi), osmo_hexdump(data, size)); } @@ -479,7 +515,7 @@ int main(int argc, char **argv) if (action == ACTION_SCAN) return scan_band(); - else if (action == ACTION_BCCH) + else if (action == ACTION_BCCH || action == ACTION_BCCH_CCCH) return bcch_follow(); else { if (source == SuperFemto_ClkSrcId_NetList) diff --git a/contrib/sysmobts-calib/sysmobts-layer1.c b/contrib/sysmobts-calib/sysmobts-layer1.c index 85aa940a..d1060d1d 100644 --- a/contrib/sysmobts-calib/sysmobts-layer1.c +++ b/contrib/sysmobts-calib/sysmobts-layer1.c @@ -1,6 +1,6 @@ /* Layer1 handling for the DSP/FPGA */ /* - * (C) 2012 Holger Hans Peter Freyther + * (C) 2012-2013 Holger Hans Peter Freyther * * All Rights Reserved * @@ -481,16 +481,16 @@ int follow_sch(int band, int arfcn, int clock, int ref, HANDLE *layer1) return 0; } -int follow_bcch(HANDLE layer1) +static int follow_sapi(HANDLE layer1, const GsmL1_Sapi_t sapi) { int rc; GsmL1_Prim_t prim; - /* 1.) Activate BCCH... */ + /* 1.) Activate BCCH or such... */ memset(&prim, 0, sizeof(prim)); prim.u.mphActivateReq.hLayer1 = layer1; prim.u.mphActivateReq.u8Tn = 0; - prim.u.mphActivateReq.sapi = GsmL1_Sapi_Bcch; + prim.u.mphActivateReq.sapi = sapi; prim.u.mphActivateReq.dir = GsmL1_Dir_RxDownlink; rc = send_recv_sig_prim(GsmL1_PrimId_MphActivateReq, &prim); @@ -511,23 +511,33 @@ int follow_bcch(HANDLE layer1) return rc; } - if (prim.u.phConnectInd.sapi != GsmL1_Sapi_Bcch) { + if (prim.u.phConnectInd.sapi != sapi) { printf("Got a connect indication for the wrong type: %d\n", prim.u.phConnectInd.sapi); return -6; } /* 3.) Wait for PhDataInd... */ - printf("Waiting for BCCH data.\n"); + printf("Waiting for data.\n"); rc = wait_for_indication(GsmL1_PrimId_PhDataInd, &prim); if (rc != 0) { - printf("Didn't get BCCH data.\n"); + printf("Didn't get data.\n"); return rc; } return 0; } +int follow_bcch(HANDLE layer1) +{ + return follow_sapi(layer1, GsmL1_Sapi_Bcch); +} + +int follow_pch(HANDLE layer1) +{ + return follow_sapi(layer1, GsmL1_Sapi_Pch); +} + int find_bsic(void) { int rc, i; @@ -701,7 +711,7 @@ int wait_for_sync(HANDLE layer1, int cor, int calib, int source) return 0; } -int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block) +int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block, GsmL1_Sapi_t *sap) { GsmL1_Prim_t prim; int rc; @@ -715,6 +725,7 @@ int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block) *size = prim.u.phDataInd.msgUnitParam.u8Size; *fn = prim.u.phDataInd.u32Fn; *block = prim.u.phDataInd.u8BlockNbr; + *sap = prim.u.phDataInd.sapi; memcpy(data, prim.u.phDataInd.msgUnitParam.u8Buffer, *size); return 0; } diff --git a/contrib/sysmobts-calib/sysmobts-layer1.h b/contrib/sysmobts-calib/sysmobts-layer1.h index 4e34e47a..e7d59c94 100644 --- a/contrib/sysmobts-calib/sysmobts-layer1.h +++ b/contrib/sysmobts-calib/sysmobts-layer1.h @@ -39,6 +39,7 @@ extern int rf_clock_info(int *clkErr, int *clkErrRes); extern int mph_close(HANDLE layer1); extern int wait_for_sync(HANDLE layer1, int cor, int calib, int source); extern int follow_bcch(HANDLE layer1); -extern int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block); +extern int follow_pch(HANDLE layer1); +extern int wait_for_data(uint8_t *data, size_t *size, uint32_t *fn, uint8_t *block, GsmL1_Sapi_t *sapi); #endif -- cgit v1.2.3