bug: fix some issues with get data on X19 from CGMiner on Vnish to BMMiner on stock.

This commit is contained in:
Upstream Data
2022-11-05 10:15:18 -06:00
parent 92f58a9682
commit c6ca1df112
3 changed files with 43 additions and 8 deletions

View File

@@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.API import BaseMinerAPI
from pyasic.API import BaseMinerAPI, APIError
import logging
class CGMinerAPI(BaseMinerAPI):
@@ -36,6 +38,37 @@ class CGMinerAPI(BaseMinerAPI):
def __init__(self, ip: str, port: int = 4028):
super().__init__(ip, port)
async def multicommand(
self, *commands: str, ignore_x19_error: bool = False
) -> dict:
logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}")
# make sure we can actually run each command, otherwise they will fail
commands = self._check_commands(*commands)
# standard multicommand format is "command1+command2"
# doesnt work for S19 which uses the backup _x19_multicommand
command = "+".join(commands)
try:
data = await self.send_command(command, allow_warning=ignore_x19_error)
except APIError:
logging.debug(f"{self.ip}: Handling X19 multicommand.")
data = await self._x19_multicommand(*command.split("+"))
logging.debug(f"{self.ip}: Received multicommand data.")
return data
async def _x19_multicommand(self, *commands):
data = None
try:
data = {}
# send all commands individually
for cmd in commands:
data[cmd] = []
data[cmd].append(await self.send_command(cmd, allow_warning=True))
except APIError as e:
raise APIError(e)
except Exception as e:
logging.warning(f"{self.ip}: API Multicommand Error: {e}")
return data
async def version(self) -> dict:
"""Get miner version info.
<details>

View File

@@ -281,12 +281,13 @@ class BMMiner(BaseMiner):
if (not chips) or (not chips > 0):
hashboard.missing = True
data.hashboards.append(hashboard)
if f"temp_pcb{i}" in temp[1].keys():
env_temp = temp[1][f"temp_pcb{i}"].split("-")[0]
if f"temp_pcb{i}" in boards[1].keys():
env_temp = boards[1][f"temp_pcb{i}"].split("-")[0]
if not env_temp == 0:
env_temp_list.append(int(env_temp))
if not env_temp_list == []:
data.env_temp = sum(env_temp_list) / len(env_temp_list)
data.env_temp = round(sum(env_temp_list) / len(env_temp_list))
if stats:
temp = stats.get("STATS")

View File

@@ -206,7 +206,7 @@ class CGMiner(BaseMiner):
miner_data = None
for i in range(PyasicSettings().miner_get_data_retries):
miner_data = await self.api.multicommand(
"summary", "pools", "stats", ignore_x19_error=True
"summary", "pools", "stats",
)
if miner_data:
break
@@ -264,12 +264,13 @@ class CGMiner(BaseMiner):
if (not chips) or (not chips > 0):
hashboard.missing = True
data.hashboards.append(hashboard)
if f"temp_pcb{i}" in temp[1].keys():
env_temp = temp[1][f"temp_pcb{i}"].split("-")[0]
if f"temp_pcb{i}" in boards[1].keys():
env_temp = boards[1][f"temp_pcb{i}"].split("-")[0]
if not env_temp == 0:
env_temp_list.append(int(env_temp))
if not env_temp_list == []:
data.env_temp = sum(env_temp_list) / len(env_temp_list)
data.env_temp = round(sum(env_temp_list) / len(env_temp_list))
if stats:
temp = stats.get("STATS")