From 0711bcb259610e0268b3e8ceb358f3fa35340831 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Tue, 11 Jan 2022 10:18:31 -0700 Subject: [PATCH] added misc folder with bos get_bad_tuners, to get tuner errors from all miners on a network --- misc/__init__.py | 0 misc/bos.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 misc/__init__.py create mode 100644 misc/bos.py diff --git a/misc/__init__.py b/misc/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/misc/bos.py b/misc/bos.py new file mode 100644 index 00000000..584f956b --- /dev/null +++ b/misc/bos.py @@ -0,0 +1,33 @@ +import asyncio +from network import MinerNetwork +from miners.bosminer import BOSMiner + + +async def get_bos_bad_tuners(): + miner_network = MinerNetwork("192.168.1.0") + miners = await miner_network.scan_network_for_miners() + tuner_tasks = [] + for miner in miners: + # can only do this if its a subclass of BOSMiner + if BOSMiner in type(miner).__bases__: + tuner_tasks.append(_get_tuner_status(miner)) + tuner_status = await asyncio.gather(*tuner_tasks) + bad_tuner_miners = [] + for item in tuner_status: + bad_boards = [] + for board in item["tuner_status"]: + if board["status"] not in ["Stable", "Testing performance profile"]: + bad_boards.append({"board": board["board"], + "error": board["status"].replace("Hashchain refused to start: ", "")}) + if len(bad_boards) > 0: + bad_tuner_miners.append({"ip": item["ip"], "boards": bad_boards}) + return bad_tuner_miners + + +async def _get_tuner_status(miner): + tuner_status = await miner.api.tunerstatus() + tuner_data = [] + if tuner_status: + for board in tuner_status["TUNERSTATUS"][0]["TunerChainStatus"]: + tuner_data.append({"board": board["HashchainIndex"], "status": board["Status"]}) + return {"ip": str(miner.ip), "tuner_status": tuner_data}