From 790a99f9d1b31db8a37232e2f44faa3f6020f7f1 Mon Sep 17 00:00:00 2001 From: Ying Cai Date: Fri, 10 Mar 2023 14:57:47 -0600 Subject: [PATCH] faster PER test --- .github/workflows/scripts/plot_per_results.py | 20 +++++- Tools/Bluetooth/conn_sweep.py | 72 ++++++++++--------- 2 files changed, 57 insertions(+), 35 deletions(-) mode change 100644 => 100755 Tools/Bluetooth/conn_sweep.py diff --git a/.github/workflows/scripts/plot_per_results.py b/.github/workflows/scripts/plot_per_results.py index 43523f73272..4c63c6d9ed3 100755 --- a/.github/workflows/scripts/plot_per_results.py +++ b/.github/workflows/scripts/plot_per_results.py @@ -154,7 +154,7 @@ fig.tight_layout() plt.subplots_adjust(bottom=0.1) ''' - #title = f'packet len: {packetLen}\nphy: {phy_str[phy]}\ntxPower:{txPower}' + title = f'packet len: {packetLen}, txPower: 0.7 dBm\nphy: {phy_str[phy]}' if axs.ndim == 1: axs[col].set_title(title, fontdict={'fontsize': 6, 'fontweight': 'medium'}) @@ -177,8 +177,8 @@ if p[i] > SPEC: #print(f'{a[i]}, {p[i]}') if axs.ndim == 1: - axs[row].axvline(x=a[i], color='r', linestyle=':', linewidth=0.5) - axs[row].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', + axs[col].axvline(x=a[i], color='r', linestyle=':', linewidth=0.5) + axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', verticalalignment='center', fontsize=3) else: axs[row, col].axvline(x=a[i], color='r', linestyle=':', linewidth=0.5) @@ -186,6 +186,15 @@ verticalalignment='center', fontsize=3) break + # mark the last point + i = -1 + if axs.ndim == 1: + axs[col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', + verticalalignment='center', fontsize=3) + else: + axs[row, col].text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', + verticalalignment='center', fontsize=3) + # note fig.text(.5, .01, f'Run on all data channels (no advertising channels).\n{args.desc}', ha='center', fontdict={"fontsize": 5}) @@ -257,6 +266,11 @@ verticalalignment='center', fontsize=8) break + # mark the last point + i = -1 + plt.text(a[i], p[i], f' {p[i]}% @ {a[i]} dBm', horizontalalignment='left', + verticalalignment='center', fontsize=8) + # resize the figure to match the aspect ratio of the Axes fig.set_size_inches(7, 8, forward=True) #fig.text(.5, .10, args.desc, ha='center', fontdict={"fontsize": 12}) diff --git a/Tools/Bluetooth/conn_sweep.py b/Tools/Bluetooth/conn_sweep.py old mode 100644 new mode 100755 index 0988c92f778..fa7553485da --- a/Tools/Bluetooth/conn_sweep.py +++ b/Tools/Bluetooth/conn_sweep.py @@ -109,30 +109,27 @@ def run_script_reset_board(sh_file): parser.add_argument('--brd2_reset', default="", help="script file to reset board2") parser.add_argument('--retry_limit', default=3, help="limit of retry times after fail") parser.add_argument('--short', action='store_true', help="shorter test") +parser.add_argument('--chip', default="", help="DUT chip") +parser.add_argument('--min_pwrs', default="90,90,90,90", help="abs min power") args = parser.parse_args() print("--------------------------------------------------------------------------------------------") pprint(vars(args)) +# default minimum power +min_pwrs = [90, 90, 90, 90] # for PHY 1, 2, 3, 4 + +temp = args.min_pwrs.replace(" ", "") +pwrs = temp.split(",") +if len(pwrs) == 4: + min_pwrs = [int(x) for x in pwrs] + print(f'abs min pwr for each PHY: {min_pwrs}') + packetLengths = args.pktlen.strip().split(",") phys = args.phys.strip().split(",") txPowers = args.txpows.strip().split(",") -if args.attens is None: - if int(args.step) == 0 or int(args.step) == -1: - attens = [20, 70] - else: - attens = list(range(20, 90, int(args.step))) - - # Add the max attenuation - if int(args.step) != -1: - attens.append(90) -else: - temp = args.attens.replace(" ", "") - attens = temp.split(",") - attens = [float(x) for x in attens] - print("slaveSerial :", args.slaveSerial) print("masterSerial :", args.masterSerial) print("slave TRACE :", args.stp) @@ -141,7 +138,6 @@ def run_script_reset_board(sh_file): print("delay :", args.delay) print("packetLengths :", packetLengths) print("phys :", phys) -print("attens :", attens) print("txPowers :", txPowers) print("PER limit :", args.limit) @@ -165,6 +161,23 @@ def run_script_reset_board(sh_file): testing = 1 for packetLen, phy, txPower in itertools.product(packetLengths, phys, txPowers): + + if args.attens is None: + if int(args.step) == 0 or int(args.step) == -1: + attens = [20, 70] + else: + attens = list(range(20, min_pwrs[int(phy)-1], int(args.step))) + + # Add the max attenuation + if int(args.step) != -1: + attens.append(min_pwrs[int(phy)-1]) + else: + temp = args.attens.replace(" ", "") + attens = temp.split(",") + attens = [float(x) for x in attens] + + print(f'attens: {attens}') + if args.short: for atten in attens: per_100 = 0 @@ -248,7 +261,7 @@ def run_script_reset_board(sh_file): start_secs = time.time() print('\n-----------------------------------------------------------------------------------------') - print(f'packetLen: {packetLen}, phy: {phy}, atten: {atten}, txPower: {txPower}, testing point: {testing}') + print(f'{args.chip} - packetLen: {packetLen}, phy: {phy}, atten: {atten}, txPower: {txPower}, testing point: {testing}') print('-------------------------------------------------------------------------------------------') print(f"\nSet the requested attenuation: {atten}.") @@ -256,8 +269,7 @@ def run_script_reset_board(sh_file): set_val = atten + float(args.loss) mini_RCDAT = mini_RCDAT_USB(Namespace(atten=set_val)) - print("\nSleep 1 second") - sleep(1) + sleep(0.1) print("\nReset the packet stats.") hciSlave.cmdFunc(Namespace(cmd="0102FF00"), timeout=10.0) @@ -265,7 +277,6 @@ def run_script_reset_board(sh_file): print("\nSlave listenFunc") hciSlave.listenFunc(Namespace(time=1, stats="False")) - print(f'used {(time.time() - start_secs):.0f} secs.') print("\nMaster listenFunc") hciMaster.listenFunc(Namespace(time=1, stats="False")) @@ -281,26 +292,27 @@ def run_script_reset_board(sh_file): perMaster = hciMaster.connStatsFunc(None) print("\nSlave collects results.") - perSlave = hciSlave.connStatsFunc(None) - - print("\n\nperMaster : ", perMaster) - print("perSlave : ", perSlave) + perSlave = hciSlave.connStatsFunc(None) reset_master = False if perMaster is None: print("perMaster is None. Reset the master.") reset_master = True elif perMaster >= 99.99: - print("perMaster invalid. Reset the master.") + print(f"perMaster {perMaster}% invalid. Reset the master.") reset_master = True + else: + print(f"\n\nperMaster : {perMaster:.2f} %") reset_slave = False if perSlave is None: print("perSlave is None. Flash the slave.") reset_slave = True elif perSlave >= 99.99: - print("perSlave invalid. Flash the slave.") + print(f"perSlave {perSlave}% invalid. Flash the slave.") reset_slave = True + else: + print(f"perSlave : {perSlave:.2f} %") if reset_slave or reset_master: run_script_reset_board(args.brd1_reset) @@ -326,7 +338,7 @@ def run_script_reset_board(sh_file): perMax = perMaster if perSlave > perMax: perMax = perSlave - print("\nperMax : ", perMax) + print(f"\nperMax : {perMax:.2f} %") break # no retry @@ -342,13 +354,9 @@ def run_script_reset_board(sh_file): # Save the results to file results.write(str(packetLen)+","+str(phy)+",-"+str(atten)+","+str(txPower)+","+str(perMaster)+","+str(perSlave)+"\n") end_secs = time.time() - print(f'\nTotally used {(end_secs - start_secs):.0f} seconds for this point.') + print(f'\nTotally used time for this point (secs): {(end_secs - start_secs):.0f}') - if testing >= RESET_CNT: - testing = RESET_CNT - need_to_setup = True - else: - testing += 1 + testing += 1 else: # original method for atten in attens: