Skip to content

Commit

Permalink
Merge pull request #299 from tiiuae/field_test_tool_update
Browse files Browse the repository at this point in the history
Update new sensors to field_test_logger and other enhancements
  • Loading branch information
joenpera authored Sep 12, 2023
2 parents 6894ac7 + 4b3e5bf commit 6d6306d
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 58 deletions.
2 changes: 1 addition & 1 deletion common/tools/field_test_logger/S95logger
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name="field_test_logger"
# The path of the client executable
command="/usr/bin/python3"
# Any command line arguments for the client executable
command_args="/usr/local/bin/field_test_logger.py $2"
command_args="/usr/local/bin/field_test_logger.py -u $2"
# The path of the daemon executable
daemon="/usr/bin/daemon"

Expand Down
55 changes: 47 additions & 8 deletions common/tools/field_test_logger/field_test_logger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import csv
import os
import time
import sys
import argparse
from datetime import datetime

import wifi_info
Expand Down Expand Up @@ -94,12 +94,40 @@ def timestamp() -> str:


if __name__ == '__main__':
argparse = argparse.ArgumentParser(description='Field Test Logger',
prog='field_test_logger.py')
argparse.add_argument('-u', '--unique', help='Add unique suffix to log file name')
argparse.add_argument('-i', '--interface',
help='Specify wifi interface name e.g. wlp1s0 (default: wlp1s0)')
argparse.add_argument('-b', '--batman',
help="Specify batman interface name e.g. bat0 (default: bat0)")

args = argparse.parse_args()

if args.batman is None:
BATMAN_ARG = "bat0"
else:
BATMAN_ARG = args.batman

if args.interface is None:
INTERFACE_ARG = "wlp1s0"
else:
INTERFACE_ARG = args.interface

if args.unique is None or args.unique == "":
UNIQUE_ARG = f"_{INTERFACE_ARG}_{BATMAN_ARG}"
else:
UNIQUE_ARG = f"_{INTERFACE_ARG}_{BATMAN_ARG}_{args.unique}"

try:
with open("/etc/comms_pcb_version", "r") as file_r:
PCB_VERSION = file_r.read().strip().split("=")[1]
except FileNotFoundError:
PCB_VERSION = "unknown"

ftl = FieldTestLogger()
wifi_stats = wifi_info.WifiInfo(LOGGING_INTERVAL_SECONDS)
info = infoparser.InfoParser()
uc_arg = ""
if len(sys.argv) > 1:
uc_arg = f"_{sys.argv[1]}"
wifi_stats = wifi_info.WifiInfo(LOGGING_INTERVAL_SECONDS, INTERFACE_ARG, BATMAN_ARG)
info = infoparser.InfoParser(PCB_VERSION)

ftl.register_logger_function("Timestamp", timestamp)
wifi_stats.update()
Expand Down Expand Up @@ -131,6 +159,17 @@ def timestamp() -> str:
ftl.register_logger_function("wifi temp [mC]", info.get_wifi_temp)
ftl.register_logger_function("tmp100 [mC]", info.get_tmp100)

ftl.register_logger_function("3V3 mpcie3 voltage [mV]", info.get_mpcie3_voltage)
ftl.register_logger_function("3V3 mpcie3 current [mA]", info.get_mpcie3_current)
ftl.register_logger_function("3V3 mpcie5 voltage [mV]", info.get_mpcie5_voltage)
ftl.register_logger_function("3V3 mpcie5 current [mA]", info.get_mpcie5_current)
ftl.register_logger_function("3V3 mpcie7 voltage [mV]", info.get_mpcie7_voltage)
ftl.register_logger_function("3V3 mpcie7 current [mA]", info.get_mpcie7_current)

ftl.register_logger_function("bme280 rel. humidity [m%]", info.get_humidity)
ftl.register_logger_function("bme280 pressure [kPa]", info.get_pressure)
ftl.register_logger_function("bme280 temperature [mC]", info.get_temperature)

ftl.register_logger_function("battery voltage [uV]", info.get_battery_voltage)
ftl.register_logger_function("battery current [uA]", info.get_battery_current)
ftl.register_logger_function("nRF voltage [mV]", info.get_nrf_voltage)
Expand All @@ -140,7 +179,7 @@ def timestamp() -> str:
ftl.register_logger_function("DCin (XT30) voltage [mV]", info.get_dc_voltage)
ftl.register_logger_function("DCin (XT30) current [mA]", info.get_dc_current)

ftl.create_csv(f"{wifi_stats.get_mac_addr()}{uc_arg}")
ftl.create_csv(f"{wifi_stats.get_mac_addr()}{UNIQUE_ARG}")

while True:
start = time.time()
Expand All @@ -151,4 +190,4 @@ def timestamp() -> str:

# adjust delay for precise logging interval
if d < LOGGING_INTERVAL_SECONDS:
time.sleep(LOGGING_INTERVAL_SECONDS - d)
time.sleep(LOGGING_INTERVAL_SECONDS - d)
Loading

0 comments on commit 6d6306d

Please sign in to comment.