Merge "Replace deprecated serial buffer flush function" am: 3d1fc000a9 am: 6cc758e7a1 am: a706bce138
am: b23aacaf22
Change-Id: I9ba37e13fe11b492adcbc6442512915a70d763cc
diff --git a/acts/framework/acts/controllers/monsoon.py b/acts/framework/acts/controllers/monsoon.py
index 160cca7..de47a32 100644
--- a/acts/framework/acts/controllers/monsoon.py
+++ b/acts/framework/acts/controllers/monsoon.py
@@ -355,6 +355,8 @@
def _SendStruct(self, fmt, *args):
"""Pack a struct (without length or checksum) and send it.
"""
+ # Flush out the input buffer before sending data
+ self._FlushInput()
data = struct.pack(fmt, *args)
data_len = len(data) + 1
checksum = (data_len + sum(bytearray(data))) % 256
@@ -387,7 +389,7 @@
def _FlushInput(self):
""" Flush all read data until no more available. """
- self.ser.flush()
+ self.ser.reset_input_buffer()
flushed = 0
while True:
ready_r, ready_w, ready_x = select.select([self.ser], [],
@@ -397,7 +399,8 @@
elif len(ready_r) > 0:
flushed += 1
self.ser.read(1) # This may cause underlying buffering.
- self.ser.flush() # Flush the underlying buffer too.
+ self.ser.reset_input_buffer(
+ ) # Flush the underlying buffer too.
else:
break
# if flushed > 0:
@@ -917,9 +920,24 @@
def disconnect_dut(self):
"""Disconnect DUT from monsoon.
+ Stop the sl4a service on the DUT and disconnect USB connection
raises:
MonsoonError: monsoon erro trying to disconnect usb
+ """
+ try:
+ self.dut.stop_services()
+ time.sleep(1)
+ self.usb("off")
+ except Exception as e:
+ raise MonsoonError(
+ "Error happended trying to disconnect DUT from Monsoon")
+
+ def monsoon_usb_auto(self):
+ """Set monsoon USB to auto to ready the device for power measurement.
+
Stop the sl4a service on the DUT and disconnect USB connection
+ raises:
+ MonsoonError: monsoon erro trying to set usbpassthrough to auto
"""
try:
self.dut.stop_services()
@@ -927,7 +945,7 @@
self.usb("auto")
except Exception as e:
raise MonsoonError(
- "Error happended trying to disconnect DUT from Monsoon")
+ "Error happended trying to set Monsoon usbpassthrough to auto")
def reconnect_dut(self):
"""Reconnect DUT to monsoon and start sl4a services.
diff --git a/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py
index 7a61295..73373d6 100644
--- a/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py
+++ b/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py
@@ -204,7 +204,7 @@
"Starting power measurement with monsoon box, try #{}".
format(retry_measure))
#Start the power measurement using monsoon
- mon_info['dut'].disconnect_dut()
+ mon_info['dut'].monsoon_usb_auto()
result = mon_info['dut'].measure_power(
mon_info['freq'],
mon_info['duration'],
@@ -237,7 +237,8 @@
break
else:
retry_monsoon += 1
- log.warning('Wait for {} second then try again'.format(MONSOON_RETRY_INTERVAL))
+ log.warning('Wait for {} second then try again'.format(
+ MONSOON_RETRY_INTERVAL))
time.sleep(MONSOON_RETRY_INTERVAL)
# Break the loop to end test if failed to recover monsoon