From 82bf8585701557908d76232c229a2c9f215f32a6 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Mon, 15 Feb 2021 16:54:10 -0700 Subject: [PATCH] lf_cisco_dfs.py : added some additional waiting for bash response --- py-scripts/lf_cisco_dfs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/py-scripts/lf_cisco_dfs.py b/py-scripts/lf_cisco_dfs.py index 9c69604a..5e7a20c4 100755 --- a/py-scripts/lf_cisco_dfs.py +++ b/py-scripts/lf_cisco_dfs.py @@ -1445,9 +1445,15 @@ class L3VariableTime(Realm): # spawn bash for lf_hackrf.py child = pexpect.spawn('bash') + time.sleep(0.4) # for testing bash - '''child.expect(r'\$') + i = child.expect([r'\$',pexpect.TIMEOUT],timeout=2) + if i == 0: + logg.info("i: {} received bash prompt for hackrf command".format(i)) + if i == 1: + logg.info("i: {} TIMEOUT in bash prompt".format(i)) + ''' child.sendline('ls -lrt') child.expect([pexpect.TIMEOUT], timeout=1) # do not delete this for it allows for subprocess to see output print(child.before.decode('utf-8', 'ignore')) # do not delete this for it allows for subprocess to see output @@ -1478,15 +1484,18 @@ class L3VariableTime(Realm): command_hackRF = "sudo python lf_hackrf.py --pulse_width {} --pulse_interval {} --pulse_count {} --sweep_time {} --freq {} --if_gain {} --bb_gain {} --gain {}".format(width_,interval_,count_,sweep_time_,frequency_,if_gain_,bb_gain_,gain_) logg.info("hackrf command {}".format(command_hackRF)) child.sendline(command_hackRF) + time.sleep(0.4) i = child.expect(['lanforge:',pexpect.TIMEOUT], timeout=2) if i == 0: logg.info("lanforge prompt received i: {} before {} after {}".format(i,child.before.decode('utf-8', 'ignore'),child.after.decode('utf-8', 'ignore'))) child.sendline('lanforge') + time.sleep(0.4) self.dfs_epoch_start = int(time.time()) j = child.expect(['>>>',pexpect.TIMEOUT], timeout=2) if j == 0: logg.info(">>> prompt received i: {} j: {} before {} after {}".format(i,j,child.before.decode('utf-8', 'ignore'),child.after.decode('utf-8', 'ignore'))) child.sendline('s') + time.sleep(0.4) k = child.expect(['>>>',pexpect.TIMEOUT], timeout=2) if k == 0: logg.info(">>> prompt received i: {} j: {} k: {} before {} after {}".format(i,j,k,child.before.decode('utf-8', 'ignore'),child.after.decode('utf-8', 'ignore')))