Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions core/app_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def monitorLife(self):
logging.info("Life monitoring thread started")
# Poll DUT to see if it's still responsive, if not, raise timeout exception
file_path = self.result_dir + os.sep + 'battery_level.txt'
csv_path = self.result_dir + os.sep + 'battery_level.csv'
while(True):
try:
if self.platform.lower() == 'windows':
Expand All @@ -795,13 +796,26 @@ def monitorLife(self):
# logging.info("RTC Wake timer reset")
time.sleep(900)
elif self.platform.lower() == 'macos':
result = self._call(["pmset", "-g batt"], blocking=True)
level = result.split("\n")[1].split("\t")[1].split("%")[0]
# Get AppleRawCurrentCapacity level via ioreg
raw_current_capacity_result = self._call(["bash", '-c "ioreg -r -c AppleSmartBattery -a | plutil -extract 0.AppleRawCurrentCapacity raw -"'], blocking=True)
raw_current_capacity_level = raw_current_capacity_result.strip()

# Get AppleRawMaxCapacity level via ioreg
raw_max_capacity_result = self._call(["bash", '-c "ioreg -r -c AppleSmartBattery -a | plutil -extract 0.AppleRawMaxCapacity raw -"'], blocking=True)
raw_max_capacity_level = raw_max_capacity_result.strip()

# Calculate Battery level to 2 decimal places
level = round(float(raw_current_capacity_level) / float(raw_max_capacity_level) * 100, 2)

current_time = datetime.now()
time_s = current_time.strftime("%m/%d/%Y %I:%M:%S %p")
logging.info(f"Battery level: {level}")
logging.info(f"Battery level : {str(level)}")

# Write human-readable txt log
with open(file_path, 'a', newline='') as f:
f.write(f"{time_s}: total battery: {level}\n")
f.write(f"{time_s}: total battery: {str(level)}\n")


if int(level) <= int(self.stop_soc):
break
time.sleep(int(self.poll_rate))
Expand Down
10 changes: 8 additions & 2 deletions utilities/open_source/config_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ if [ "$PreRun" = true ]; then
# add_to_table "Scenario" ""
add_to_table "Run Start Time" "$(date +'%Y-%m-%d %H:%M:%S')"
# Add current battery level without the percent sign
battery_level=$(pmset -g batt | grep -o '[0-9]\+%' | head -n 1 | tr -d '%')
# battery_level=$(pmset -g batt | grep -o '[0-9]\+%' | head -n 1 | tr -d '%')
raw_current_capacity_level=$(ioreg -r -c AppleSmartBattery -a | plutil -extract 0.AppleRawCurrentCapacity raw -)
raw_max_capacity_level=$(ioreg -r -c AppleSmartBattery -a | plutil -extract 0.AppleRawMaxCapacity raw -)
battery_level=$(printf "%.2f" $(echo "$raw_current_capacity_level / $raw_max_capacity_level * 100" | bc -l))
add_to_table "Run Start Battery State (%)" "$battery_level"
battery_status=$(pmset -g batt | grep -o 'discharging\|charging\|charged' | head -n 1)
add_to_table "Run Start Charge State" "$battery_status"
Expand Down Expand Up @@ -144,7 +147,10 @@ elif [ "$PostRun" = true ]; then
run_stop_time=$(date +'%Y-%m-%d %H:%M:%S')
add_to_table "Run Stop Time" "$run_stop_time"
# Add current battery level without the percent sign
battery_level=$(pmset -g batt | grep -o '[0-9]\+%' | head -n 1 | tr -d '%')
# battery_level=$(pmset -g batt | grep -o '[0-9]\+%' | head -n 1 | tr -d '%')
raw_current_capacity_level=$(ioreg -r -c AppleSmartBattery -a | plutil -extract 0.AppleRawCurrentCapacity raw -)
raw_max_capacity_level=$(ioreg -r -c AppleSmartBattery -a | plutil -extract 0.AppleRawMaxCapacity raw -)
battery_level=$(printf "%.2f" $(echo "$raw_current_capacity_level / $raw_max_capacity_level * 100" | bc -l))
add_to_table "Run Stop Battery State (%)" "$battery_level"
battery_status=$(pmset -g batt | grep -o 'discharging\|charging\|charged' | head -n 1)
add_to_table "Run Stop Charge State" "$battery_status"
Expand Down
Binary file modified utilities/proprietary/ParsePowerLight/parse_power_light.dll
Binary file not shown.
Binary file modified utilities/proprietary/ParsePowerLight/parse_power_light.exe
Binary file not shown.
Binary file modified utilities/proprietary/ParsePowerLight/parse_power_light.pdb
Binary file not shown.