bug: fix some issues with get data on X19 from CGMiner on Vnish to BMMiner on stock.
This commit is contained in:
@@ -12,7 +12,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from pyasic.API import BaseMinerAPI
|
from pyasic.API import BaseMinerAPI, APIError
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class CGMinerAPI(BaseMinerAPI):
|
class CGMinerAPI(BaseMinerAPI):
|
||||||
@@ -36,6 +38,37 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
def __init__(self, ip: str, port: int = 4028):
|
def __init__(self, ip: str, port: int = 4028):
|
||||||
super().__init__(ip, port)
|
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:
|
async def version(self) -> dict:
|
||||||
"""Get miner version info.
|
"""Get miner version info.
|
||||||
<details>
|
<details>
|
||||||
|
|||||||
@@ -281,12 +281,13 @@ class BMMiner(BaseMiner):
|
|||||||
if (not chips) or (not chips > 0):
|
if (not chips) or (not chips > 0):
|
||||||
hashboard.missing = True
|
hashboard.missing = True
|
||||||
data.hashboards.append(hashboard)
|
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:
|
if not env_temp == 0:
|
||||||
env_temp_list.append(int(env_temp))
|
env_temp_list.append(int(env_temp))
|
||||||
if not env_temp_list == []:
|
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:
|
if stats:
|
||||||
temp = stats.get("STATS")
|
temp = stats.get("STATS")
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class CGMiner(BaseMiner):
|
|||||||
miner_data = None
|
miner_data = None
|
||||||
for i in range(PyasicSettings().miner_get_data_retries):
|
for i in range(PyasicSettings().miner_get_data_retries):
|
||||||
miner_data = await self.api.multicommand(
|
miner_data = await self.api.multicommand(
|
||||||
"summary", "pools", "stats", ignore_x19_error=True
|
"summary", "pools", "stats",
|
||||||
)
|
)
|
||||||
if miner_data:
|
if miner_data:
|
||||||
break
|
break
|
||||||
@@ -264,12 +264,13 @@ class CGMiner(BaseMiner):
|
|||||||
if (not chips) or (not chips > 0):
|
if (not chips) or (not chips > 0):
|
||||||
hashboard.missing = True
|
hashboard.missing = True
|
||||||
data.hashboards.append(hashboard)
|
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:
|
if not env_temp == 0:
|
||||||
env_temp_list.append(int(env_temp))
|
env_temp_list.append(int(env_temp))
|
||||||
if not env_temp_list == []:
|
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:
|
if stats:
|
||||||
temp = stats.get("STATS")
|
temp = stats.get("STATS")
|
||||||
|
|||||||
Reference in New Issue
Block a user