Compare commits

...

61 Commits

Author SHA1 Message Date
Upstream Data
126b0d124c version: bump version number 2022-11-13 18:54:46 -07:00
Upstream Data
81c84a3e8f bug: fix a bug with no try except blocks on pools. 2022-11-13 18:54:26 -07:00
Upstream Data
406d5bd549 version: bump version number 2022-11-13 18:21:18 -07:00
Upstream Data
cd5fe09fd9 bug: fix wrong formatting for multiple error handling 2022-11-13 18:20:15 -07:00
Upstream Data
766fc4efed bug: fix check light not responding properly from graphQL. 2022-11-13 17:06:35 -07:00
Upstream Data
b70fed40c8 bug: add try except statements to get_data to fix bugs with getting data from graphql. 2022-11-13 17:03:41 -07:00
Upstream Data
255d98fd08 bug: fix some issues with validating data from graphql properly 2022-11-13 16:48:22 -07:00
Upstream Data
78304631f7 bug: fix errors not registering properly on braiins OS miners 2022-11-13 16:34:26 -07:00
Upstream Data
ab230844fc bug: fix an issue with chip count not receiving properly in some cases. 2022-11-13 16:31:41 -07:00
Upstream Data
8a58cb9fd3 format: remove extra print 2022-11-13 16:28:36 -07:00
Upstream Data
70b6ed73dc bug: fix manual return from __get_devdetails_and_version 2022-11-13 16:27:42 -07:00
Upstream Data
d2400bf44e bug: fix identifying stock as bosminer. 2022-11-13 16:22:57 -07:00
Upstream Data
db780fe876 version: bump version number 2022-11-13 15:14:16 -07:00
Upstream Data
cd84ae828a bug: fix a bug with some missing temperatures in graphql. 2022-11-13 15:13:56 -07:00
Upstream Data
970d5d1031 version: bump version number 2022-11-13 14:39:23 -07:00
Upstream Data
da0e327ec7 feature: add support for graphQL for BOS miners which may be having API issues, such as BBB. 2022-11-13 14:38:44 -07:00
Upstream Data
4c84a8d572 bug: ensure bosminer check_light backwards compatibility 2022-11-13 11:06:28 -07:00
Upstream Data
1cfd895deb feature: improve speed of bosminer check_light by 10x using graphql. 2022-11-13 11:01:22 -07:00
Upstream Data
d0da08eb10 version: bump version number 2022-11-12 14:51:30 -07:00
Upstream Data
ee4f2cd87d bug: fix win error check not being cross platform 2022-11-12 14:51:10 -07:00
UpstreamData
8a6577c8aa docs: Update README.md. 2022-11-10 14:20:41 -07:00
UpstreamData
ed5eae4187 format: add isort to dev requirements. 2022-11-10 14:17:31 -07:00
UpstreamData
f3b25027ad format: add isort to pre-commit and sort imports. 2022-11-10 14:15:45 -07:00
UpstreamData
228daecbbf version: bump version number 2022-11-08 15:09:32 -07:00
UpstreamData
81aa569d07 feature: rework whatsminer error codes to be able to allow an arbitrary slot number to be returned from the BTMiner API. 2022-11-08 15:08:47 -07:00
upstreamdata
aba8d7b8b9 bug: fix an issue with get data on unknown miners. 2022-11-08 13:38:19 -07:00
Upstream Data
449403bc57 version: bump version number. 2022-11-07 20:35:51 -07:00
Upstream Data
997a1bbe31 feature: add allow_warning to get_data to allow suppressing warnings. 2022-11-07 20:35:23 -07:00
Arceris
2c7e0e3efe Merge pull request #24 from UpstreamData/crc
Merge in branch refactoring the hashboard data
2022-11-07 19:25:06 -07:00
UpstreamData
6051a46654 docs: update docs to show cls.fields() 2022-11-07 12:54:40 -07:00
UpstreamData
c7847d2789 feature: add fields classmethod to all dataclasses to show what the fields are in each class. 2022-11-07 12:53:01 -07:00
UpstreamData
215af72a6b feature: add 0 as error_code for bos errors and X19 errors to make them consistent with the other types of errors. 2022-11-07 12:49:01 -07:00
UpstreamData
b33586f8eb feature: add fields() method to MinerData dataclass. 2022-11-07 10:51:34 -07:00
UpstreamData
8db81d9b3c format: remove prints. 2022-11-07 10:18:50 -07:00
UpstreamData
cf3b2fedf4 bug: fix a missed key step in btminer get errors. 2022-11-07 10:18:22 -07:00
UpstreamData
81db6d8e28 format: remove print in tunerstatus. 2022-11-07 10:11:08 -07:00
UpstreamData
d47e59d057 bug: fix a bug with older versions of BOSMiner having tuner status in a different place. 2022-11-07 10:09:56 -07:00
UpstreamData
8388d2f4ac bug: change MinerData().total_chips from reduce to sum, as reduce was causing issues when instantiating MinerData with a hashboard list that is empty. 2022-11-07 09:37:22 -07:00
UpstreamData
f5ec513ce0 bug: fix BMMiner warning when getting data from X19. 2022-11-07 09:07:32 -07:00
UpstreamData
8975842f0b bug: fix for some BMMiner models which report no boards causing an error when getting data. 2022-11-07 08:52:24 -07:00
Upstream Data
c6ca1df112 bug: fix some issues with get data on X19 from CGMiner on Vnish to BMMiner on stock. 2022-11-05 10:15:18 -06:00
Upstream Data
92f58a9682 bug: fix fan count and ideal chips for M34S+. 2022-11-05 10:04:17 -06:00
Upstream Data
5dc19dbd78 feature: add support for avalonminers using new hashboard model. 2022-11-05 10:03:02 -06:00
Upstream Data
b0fc11bcc1 bug: fix M34S+ not having ideal board count. 2022-11-05 09:50:03 -06:00
Upstream Data
23ebe460a4 format: Reformat some files. 2022-11-05 09:47:25 -06:00
Upstream Data
92db8c8161 format: Improve T9 formatting with get data on hiveon. 2022-11-05 09:44:38 -06:00
Upstream Data
d9b522734a format: reformat T3H+ get_data to improve error handling and checking of data. 2022-11-05 09:40:56 -06:00
Colin Crossman
e02457f0b2 bug: fix import for HashBoard 2022-11-04 21:55:44 -06:00
Colin Crossman
104b4c18c2 format: remove vestigial elements of btminer 2022-11-04 21:28:59 -06:00
Colin Crossman
1970f8c924 feature: add innosilicon support for new HashBoard format. 2022-11-04 21:28:33 -06:00
Colin Crossman
e431a06ac5 feature: add cgminer support for new HashBoard structure 2022-11-04 21:28:07 -06:00
Upstream Data
6da9b58088 bug: fix missing initialization variables on HashBoard when being called from within get_data on bos, T9, and btminer. 2022-11-04 20:26:28 -06:00
Upstream Data
3108443041 feature: add bosminer support for new HashBoard format. 2022-11-04 20:22:07 -06:00
Upstream Data
37ebb9e6c3 feature: add T9 support for new HashBoard format. 2022-11-04 20:10:50 -06:00
Upstream Data
6c2e0f59b1 feature: add the remainder of the backwards compatible MinerData board related parts that were lost in converting to HashBoard dataclass. 2022-11-04 20:00:03 -06:00
Upstream Data
6eb9cdce90 feature: add left_chips, center_chips, and right_chips to MinerData as properties that compute the correct board position from hashboards. 2022-11-04 19:55:13 -06:00
Upstream Data
e96d9447d1 format: reformat btminer.py 2022-11-04 19:44:49 -06:00
Upstream Data
d3cca11322 feature: add new HashBoard data structure to bmminer, and add ideal_hashboards to BaseMiner. 2022-11-04 19:44:19 -06:00
Colin Crossman
86155db455 Initial modifications to account for differential hashboard counts
Now storing the hasboard data as an array of datastructs. Not fully fleshed out yet, but this is where I'm going.
2022-11-04 15:48:30 -06:00
UpstreamData
5b078b4b27 feature: add support for M34S+ and M34S+ VE10 2022-11-04 13:12:28 -06:00
UpstreamData
9672dd6873 bug: fix warnings when new whatsminer API commands don't exist. 2022-11-02 10:32:33 -06:00
91 changed files with 1237 additions and 688 deletions

View File

@@ -9,6 +9,12 @@ repos:
rev: 22.6.0 rev: 22.6.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
- repo: local - repo: local
hooks: hooks:
- id: unittest - id: unittest

View File

@@ -18,6 +18,10 @@ You can install pyasic directly from pip with the command `pip install pyasic`.
For those of you who aren't comfortable with code and developer tools, there are windows builds of GUI applications that use this library [here](https://drive.google.com/drive/folders/1DjR8UOS_g0ehfiJcgmrV0FFoqFvE9akW?usp=sharing). For those of you who aren't comfortable with code and developer tools, there are windows builds of GUI applications that use this library [here](https://drive.google.com/drive/folders/1DjR8UOS_g0ehfiJcgmrV0FFoqFvE9akW?usp=sharing).
## Developer Setup ## Developer Setup
It is highly reccommended that you contribute to this project through [`pyasic-super`](https://github.com/UpstreamData/pyasic-super) using its submodules. This allows testing in conjunction with other `pyasic` related programs.
<br>
This repo uses poetry for dependencies, which can be installed by following the guide on their website [here](https://python-poetry.org/docs/#installation). This repo uses poetry for dependencies, which can be installed by following the guide on their website [here](https://python-poetry.org/docs/#installation).
After you have poetry installed, run `poetry install --with dev`, or `poetry install --with dev,docs` if you want to include packages required for documentation. After you have poetry installed, run `poetry install --with dev`, or `poetry install --with dev,docs` if you want to include packages required for documentation.

View File

@@ -230,7 +230,7 @@ These functions are
## [`MinerConfig`][pyasic.config.MinerConfig] and [`MinerData`][pyasic.data.MinerData] ## [`MinerConfig`][pyasic.config.MinerConfig] and [`MinerData`][pyasic.data.MinerData]
Pyasic implements a few dataclasses as helpers to make data return types consistent across different miners and miner APIs. Pyasic implements a few dataclasses as helpers to make data return types consistent across different miners and miner APIs. The different fields of these dataclasses can all be viewed with the classmethod `cls.fields()`.
<br> <br>

View File

@@ -59,6 +59,8 @@ details {
</ul> </ul>
</details> </details>
</ul> </ul>
</details>
<details>
<summary>M3X Series:</summary> <summary>M3X Series:</summary>
<ul> <ul>
<details> <details>
@@ -109,6 +111,12 @@ details {
<details> <details>
<summary><a href="../whatsminer/M3X/#m32s">M32S</a></summary> <summary><a href="../whatsminer/M3X/#m32s">M32S</a></summary>
</details> </details>
<details>
<summary><a href="../whatsminer/M3X/#m34s">M34S+</a></summary>
<ul>
<li><a href="../whatsminer/M3X/#m34sve10">VE10</a></li>
</ul>
</details>
</ul> </ul>
</details> </details>
<details> <details>

View File

@@ -193,3 +193,19 @@
options: options:
show_root_heading: false show_root_heading: false
heading_level: 4 heading_level: 4
## M34S+
::: pyasic.miners.whatsminer.btminer.M3X.M34S_Plus.BTMinerM34SPlus
handler: python
options:
show_root_heading: false
heading_level: 4
## M34S+VE10
::: pyasic.miners.whatsminer.btminer.M3X.M34S_Plus.BTMinerM34SPlusVE10
handler: python
options:
show_root_heading: false
heading_level: 4

View File

@@ -13,12 +13,12 @@
# limitations under the License. # limitations under the License.
import asyncio import asyncio
import json
import ipaddress import ipaddress
import warnings import json
import logging import logging
from typing import Union
import re import re
import warnings
from typing import Union
from pyasic.errors import APIError, APIWarning from pyasic.errors import APIError, APIWarning
@@ -72,20 +72,21 @@ If you are sure you want to use this command please use API.send_command("{comma
) )
return return_commands return return_commands
async def multicommand(self, *commands: str) -> dict: async def multicommand(self, *commands: str, allow_warning: bool = True) -> dict:
"""Creates and sends multiple commands as one command to the miner. """Creates and sends multiple commands as one command to the miner.
Parameters: Parameters:
*commands: The commands to send as a multicommand to the miner. *commands: The commands to send as a multicommand to the miner.
allow_warning: A boolean to supress APIWarnings.
""" """
logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}") logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}")
# make sure we can actually run each command, otherwise they will fail # make sure we can actually run each command, otherwise they will fail
commands = self._check_commands(*commands) commands = self._check_commands(*commands)
# standard multicommand format is "command1+command2" # standard multicommand format is "command1+command2"
# doesnt work for S19 which uses the backup _x19_multicommand # doesn't work for S19 which uses the backup _x19_multicommand
command = "+".join(commands) command = "+".join(commands)
try: try:
data = await self.send_command(command) data = await self.send_command(command, allow_warning=allow_warning)
except APIError: except APIError:
return {} return {}
logging.debug(f"{self.ip}: Received multicommand data.") logging.debug(f"{self.ip}: Received multicommand data.")
@@ -97,7 +98,7 @@ If you are sure you want to use this command please use API.send_command("{comma
reader, writer = await asyncio.open_connection(str(self.ip), self.port) reader, writer = await asyncio.open_connection(str(self.ip), self.port)
# handle OSError 121 # handle OSError 121
except OSError as e: except OSError as e:
if e.winerror == "121": if getattr(e, "winerror") == "121":
logging.warning("Semaphore Timeout has Expired.") logging.warning("Semaphore Timeout has Expired.")
return b"{}" return b"{}"
@@ -129,15 +130,15 @@ If you are sure you want to use this command please use API.send_command("{comma
command: Union[str, bytes], command: Union[str, bytes],
parameters: Union[str, int, bool] = None, parameters: Union[str, int, bool] = None,
ignore_errors: bool = False, ignore_errors: bool = False,
x19_command: bool = False, allow_warning: bool = True,
) -> dict: ) -> dict:
"""Send an API command to the miner and return the result. """Send an API command to the miner and return the result.
Parameters: Parameters:
command: The command to sent to the miner. command: The command to sent to the miner.
parameters: Any additional parameters to be sent with the command. parameters: Any additional parameters to be sent with the command.
ignore_errors: Whether or not to raise APIError when the command returns an error. ignore_errors: Whether to raise APIError when the command returns an error.
x19_command: Whether this is a command for an x19 that may be an issue (such as a "+" delimited multicommand) allow_warning: Whether to warn if the command fails.
Returns: Returns:
The return data from the API command parsed from JSON into a dict. The return data from the API command parsed from JSON into a dict.
@@ -157,7 +158,7 @@ If you are sure you want to use this command please use API.send_command("{comma
# validate the command succeeded # validate the command succeeded
validation = self._validate_command_output(data) validation = self._validate_command_output(data)
if not validation[0]: if not validation[0]:
if not x19_command: if allow_warning:
logging.warning( logging.warning(
f"{self.ip}: API Command Error: {command}: {validation[1]}" f"{self.ip}: API Command Error: {command}: {validation[1]}"
) )

View File

@@ -13,8 +13,7 @@
# limitations under the License. # limitations under the License.
import logging import logging
from pyasic.API import BaseMinerAPI from pyasic.API import APIError, BaseMinerAPI
from pyasic.API import APIError
class BMMinerAPI(BaseMinerAPI): class BMMinerAPI(BaseMinerAPI):
@@ -39,16 +38,16 @@ class BMMinerAPI(BaseMinerAPI):
super().__init__(ip, port) super().__init__(ip, port)
async def multicommand( async def multicommand(
self, *commands: str, ignore_x19_error: bool = False self, *commands: str, allow_warning: bool = True
) -> dict: ) -> dict:
logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}") logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}")
# make sure we can actually run each command, otherwise they will fail # make sure we can actually run each command, otherwise they will fail
commands = self._check_commands(*commands) commands = self._check_commands(*commands)
# standard multicommand format is "command1+command2" # standard multicommand format is "command1+command2"
# doesnt work for S19 which uses the backup _x19_multicommand # doesn't work for S19 which uses the backup _x19_multicommand
command = "+".join(commands) command = "+".join(commands)
try: try:
data = await self.send_command(command, x19_command=ignore_x19_error) data = await self.send_command(command, allow_warning=allow_warning)
except APIError: except APIError:
logging.debug(f"{self.ip}: Handling X19 multicommand.") logging.debug(f"{self.ip}: Handling X19 multicommand.")
data = await self._x19_multicommand(*command.split("+")) data = await self._x19_multicommand(*command.split("+"))
@@ -62,7 +61,7 @@ class BMMinerAPI(BaseMinerAPI):
# send all commands individually # send all commands individually
for cmd in commands: for cmd in commands:
data[cmd] = [] data[cmd] = []
data[cmd].append(await self.send_command(cmd, x19_command=True)) data[cmd].append(await self.send_command(cmd, allow_warning=True))
except APIError as e: except APIError as e:
raise APIError(e) raise APIError(e)
except Exception as e: except Exception as e:

View File

@@ -13,22 +13,21 @@
# limitations under the License. # limitations under the License.
import asyncio import asyncio
import re
import json
import hashlib
import binascii
import base64 import base64
import binascii
import hashlib
import json
import logging import logging
import re
from typing import Union from typing import Union
from passlib.handlers.md5_crypt import md5_crypt
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from passlib.handlers.md5_crypt import md5_crypt
from pyasic.errors import APIError
from pyasic.API import BaseMinerAPI from pyasic.API import BaseMinerAPI
from pyasic.errors import APIError
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
### IMPORTANT ### ### IMPORTANT ###
# you need to change the password of the miners using the Whatsminer # you need to change the password of the miners using the Whatsminer
# tool, then you can set them back to admin with this tool, but they # tool, then you can set them back to admin with this tool, but they
@@ -767,7 +766,7 @@ class BTMinerAPI(BaseMinerAPI):
General miner info. General miner info.
</details> </details>
""" """
return await self.send_command("get_miner_info") return await self.send_command("get_miner_info", allow_warning=False)
async def get_error_code(self) -> dict: async def get_error_code(self) -> dict:
"""Get a list of error codes from the miner. """Get a list of error codes from the miner.
@@ -781,4 +780,4 @@ class BTMinerAPI(BaseMinerAPI):
A list of error codes on the miner. A list of error codes on the miner.
</details> </details>
""" """
return await self.send_command("get_error_code") return await self.send_command("get_error_code", allow_warning=False)

View File

@@ -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 import logging
from pyasic.API import APIError, BaseMinerAPI
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, allow_warning: bool = True
) -> 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=allow_warning)
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>

View File

@@ -16,26 +16,20 @@ from pyasic.API.bosminer import BOSMinerAPI
from pyasic.API.btminer import BTMinerAPI from pyasic.API.btminer import BTMinerAPI
from pyasic.API.cgminer import CGMinerAPI from pyasic.API.cgminer import CGMinerAPI
from pyasic.API.unknown import UnknownAPI from pyasic.API.unknown import UnknownAPI
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import ( from pyasic.data import (
MinerData,
BraiinsOSError, BraiinsOSError,
InnosiliconError, InnosiliconError,
MinerData,
WhatsminerError, WhatsminerError,
X19Error, X19Error,
) )
from pyasic.errors import APIError, APIWarning from pyasic.errors import APIError, APIWarning
from pyasic.miners import get_miner from pyasic.miners import get_miner
from pyasic.miners.base import AnyMiner from pyasic.miners.base import AnyMiner
from pyasic.miners.miner_factory import MinerFactory from pyasic.miners.miner_factory import MinerFactory
from pyasic.miners.miner_listener import MinerListener from pyasic.miners.miner_listener import MinerListener
from pyasic.network import MinerNetwork from pyasic.network import MinerNetwork
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
__all__ = [ __all__ = [

View File

@@ -12,15 +12,15 @@
# 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 dataclasses import dataclass, asdict import json
from typing import Literal, List
import random import random
import string import string
import time
from dataclasses import asdict, dataclass, fields
from typing import List, Literal
import toml import toml
import yaml import yaml
import json
import time
@dataclass @dataclass
@@ -37,6 +37,10 @@ class _Pool:
username: str = "" username: str = ""
password: str = "" password: str = ""
@classmethod
def fields(cls):
return fields(cls)
def from_dict(self, data: dict): def from_dict(self, data: dict):
"""Convert raw pool data as a dict to usable data and save it to this class. """Convert raw pool data as a dict to usable data and save it to this class.
@@ -136,6 +140,10 @@ class _PoolGroup:
group_name: str = None group_name: str = None
pools: List[_Pool] = None pools: List[_Pool] = None
@classmethod
def fields(cls):
return fields(cls)
def __post_init__(self): def __post_init__(self):
if not self.group_name: if not self.group_name:
self.group_name = "".join( self.group_name = "".join(
@@ -263,6 +271,10 @@ class MinerConfig:
dps_shutdown_enabled: bool = None dps_shutdown_enabled: bool = None
dps_shutdown_duration: float = None dps_shutdown_duration: float = None
@classmethod
def fields(cls):
return fields(cls)
def as_dict(self) -> dict: def as_dict(self) -> dict:
"""Convert the data in this class to a dict.""" """Convert the data in this class to a dict."""
data_dict = asdict(self) data_dict = asdict(self)

View File

@@ -12,14 +12,26 @@
# 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 typing import Union, List
from dataclasses import dataclass, field, asdict
from datetime import datetime, timezone
import time
import json
import copy import copy
import json
import time
from dataclasses import asdict, dataclass, field, fields
from datetime import datetime, timezone
from functools import reduce
from typing import List, Union
from .error_codes import X19Error, WhatsminerError, BraiinsOSError, InnosiliconError from .error_codes import BraiinsOSError, InnosiliconError, WhatsminerError, X19Error
@dataclass
class HashBoard:
slot: int = 0
hashrate: float = 0.0
temp: int = -1
chip_temp: int = -1
chips: int = 0
expected_chips: int = 0
missing: bool = True
@dataclass @dataclass
@@ -73,17 +85,19 @@ class MinerData:
model: str = "Unknown" model: str = "Unknown"
hostname: str = "Unknown" hostname: str = "Unknown"
hashrate: float = 0 hashrate: float = 0
left_board_hashrate: float = 0.0 hashboards: List[HashBoard] = field(default_factory=list)
center_board_hashrate: float = 0.0 ideal_hashboards: int = 1
right_board_hashrate: float = 0.0 left_board_hashrate: float = field(init=False)
center_board_hashrate: float = field(init=False)
right_board_hashrate: float = field(init=False)
temperature_avg: int = field(init=False) temperature_avg: int = field(init=False)
env_temp: float = -1.0 env_temp: float = -1.0
left_board_temp: int = -1 left_board_temp: int = field(init=False)
left_board_chip_temp: int = -1 left_board_chip_temp: int = field(init=False)
center_board_temp: int = -1 center_board_temp: int = field(init=False)
center_board_chip_temp: int = -1 center_board_chip_temp: int = field(init=False)
right_board_temp: int = -1 right_board_temp: int = field(init=False)
right_board_chip_temp: int = -1 right_board_chip_temp: int = field(init=False)
wattage: int = -1 wattage: int = -1
wattage_limit: int = -1 wattage_limit: int = -1
fan_1: int = -1 fan_1: int = -1
@@ -91,9 +105,9 @@ class MinerData:
fan_3: int = -1 fan_3: int = -1
fan_4: int = -1 fan_4: int = -1
fan_psu: int = -1 fan_psu: int = -1
left_chips: int = 0 left_chips: int = field(init=False)
center_chips: int = 0 center_chips: int = field(init=False)
right_chips: int = 0 right_chips: int = field(init=False)
total_chips: int = field(init=False) total_chips: int = field(init=False)
ideal_chips: int = 1 ideal_chips: int = 1
percent_ideal: float = field(init=False) percent_ideal: float = field(init=False)
@@ -109,6 +123,11 @@ class MinerData:
fault_light: Union[bool, None] = None fault_light: Union[bool, None] = None
efficiency: int = field(init=False) efficiency: int = field(init=False)
@classmethod
def fields(cls):
return [f.name for f in fields(cls)]
def __post_init__(self): def __post_init__(self):
self.datetime = datetime.now(timezone.utc).astimezone() self.datetime = datetime.now(timezone.utc).astimezone()
@@ -163,12 +182,148 @@ class MinerData:
@property @property
def total_chips(self): # noqa - Skip PyCharm inspection def total_chips(self): # noqa - Skip PyCharm inspection
return self.right_chips + self.center_chips + self.left_chips return sum([hb.chips for hb in self.hashboards])
@total_chips.setter @total_chips.setter
def total_chips(self, val): def total_chips(self, val):
pass pass
@property
def left_chips(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) in [2, 3]:
return self.hashboards[0].chips
return 0
@left_chips.setter
def left_chips(self, val):
pass
@property
def center_chips(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 1:
return self.hashboards[0].chips
if len(self.hashboards) == 3:
return self.hashboards[1].chips
return 0
@center_chips.setter
def center_chips(self, val):
pass
@property
def right_chips(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 2:
return self.hashboards[1].chips
if len(self.hashboards) == 3:
return self.hashboards[2].chips
return 0
@right_chips.setter
def right_chips(self, val):
pass
@property
def left_board_hashrate(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) in [2, 3]:
return self.hashboards[0].hashrate
return 0
@left_board_hashrate.setter
def left_board_hashrate(self, val):
pass
@property
def center_board_hashrate(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 1:
return self.hashboards[0].hashrate
if len(self.hashboards) == 3:
return self.hashboards[1].hashrate
return 0
@center_board_hashrate.setter
def center_board_hashrate(self, val):
pass
@property
def right_board_hashrate(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 2:
return self.hashboards[1].hashrate
if len(self.hashboards) == 3:
return self.hashboards[2].hashrate
return 0
@right_board_hashrate.setter
def right_board_hashrate(self, val):
pass
@property
def left_board_temp(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) in [2, 3]:
return self.hashboards[0].temp
return 0
@left_board_temp.setter
def left_board_temp(self, val):
pass
@property
def center_board_temp(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 1:
return self.hashboards[0].temp
if len(self.hashboards) == 3:
return self.hashboards[1].temp
return 0
@center_board_temp.setter
def center_board_temp(self, val):
pass
@property
def right_board_temp(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 2:
return self.hashboards[1].temp
if len(self.hashboards) == 3:
return self.hashboards[2].temp
return 0
@right_board_temp.setter
def right_board_temp(self, val):
pass
@property
def left_board_chip_temp(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) in [2, 3]:
return self.hashboards[0].chip_temp
return 0
@left_board_chip_temp.setter
def left_board_chip_temp(self, val):
pass
@property
def center_board_chip_temp(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 1:
return self.hashboards[0].chip_temp
if len(self.hashboards) == 3:
return self.hashboards[1].chip_temp
return 0
@center_board_chip_temp.setter
def center_board_chip_temp(self, val):
pass
@property
def right_board_chip_temp(self): # noqa - Skip PyCharm inspection
if len(self.hashboards) == 2:
return self.hashboards[1].chip_temp
if len(self.hashboards) == 3:
return self.hashboards[2].chip_temp
return 0
@right_board_chip_temp.setter
def right_board_chip_temp(self, val):
pass
@property @property
def nominal(self): # noqa - Skip PyCharm inspection def nominal(self): # noqa - Skip PyCharm inspection
return self.ideal_chips == self.total_chips return self.ideal_chips == self.total_chips
@@ -189,13 +344,9 @@ class MinerData:
def temperature_avg(self): # noqa - Skip PyCharm inspection def temperature_avg(self): # noqa - Skip PyCharm inspection
total_temp = 0 total_temp = 0
temp_count = 0 temp_count = 0
for temp in [ for hb in self.hashboards:
self.left_board_chip_temp, if hb.temp and not hb.temp == -1:
self.center_board_chip_temp, total_temp += hb.temp
self.right_board_chip_temp,
]:
if temp and not temp == -1:
total_temp += temp
temp_count += 1 temp_count += 1
if not temp_count > 0: if not temp_count > 0:
return 0 return 0

View File

@@ -12,7 +12,7 @@
# 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 dataclasses import dataclass, asdict from dataclasses import asdict, dataclass, fields
@dataclass @dataclass
@@ -21,9 +21,15 @@ class X19Error:
Attributes: Attributes:
error_message: The error message as a string. error_message: The error message as a string.
error_code: The error code as an int. 0 if the message is not assigned a code.
""" """
error_message: str error_message: str
error_code: int = 0
@classmethod
def fields(cls):
return fields(cls)
def asdict(self): def asdict(self):
return asdict(self) return asdict(self)

View File

@@ -12,13 +12,13 @@
# 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 .whatsminer import WhatsminerError
from .bos import BraiinsOSError
from .X19 import X19Error
from .innosilicon import InnosiliconError
from typing import TypeVar from typing import TypeVar
from .bos import BraiinsOSError
from .innosilicon import InnosiliconError
from .whatsminer import WhatsminerError
from .X19 import X19Error
MinerErrorData = TypeVar( MinerErrorData = TypeVar(
"MinerErrorData", WhatsminerError, BraiinsOSError, X19Error, InnosiliconError "MinerErrorData", WhatsminerError, BraiinsOSError, X19Error, InnosiliconError
) )

View File

@@ -12,7 +12,7 @@
# 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 dataclasses import dataclass, asdict from dataclasses import asdict, dataclass, fields
@dataclass @dataclass
@@ -21,9 +21,16 @@ class BraiinsOSError:
Attributes: Attributes:
error_message: The error message as a string. error_message: The error message as a string.
error_code: The error code as an int. 0 if the message is not assigned a code.
""" """
error_message: str error_message: str
error_code: int = 0
@classmethod
def fields(cls):
return fields(cls)
def asdict(self): def asdict(self):
return asdict(self) return asdict(self)

View File

@@ -12,7 +12,7 @@
# 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 dataclasses import dataclass, field, asdict from dataclasses import asdict, dataclass, field, fields
@dataclass @dataclass
@@ -27,6 +27,11 @@ class InnosiliconError:
error_code: int error_code: int
error_message: str = field(init=False) error_message: str = field(init=False)
@classmethod
def fields(cls):
return fields(cls)
@property @property
def error_message(self): # noqa - Skip PyCharm inspection def error_message(self): # noqa - Skip PyCharm inspection
if self.error_code in ERROR_CODES: if self.error_code in ERROR_CODES:

View File

@@ -12,7 +12,7 @@
# 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 dataclasses import dataclass, field, asdict from dataclasses import asdict, dataclass, field, fields
@dataclass @dataclass
@@ -27,11 +27,25 @@ class WhatsminerError:
error_code: int error_code: int
error_message: str = field(init=False) error_message: str = field(init=False)
@classmethod
def fields(cls):
return fields(cls)
@property @property
def error_message(self): # noqa - Skip PyCharm inspection def error_message(self): # noqa - Skip PyCharm inspection
if self.error_code in ERROR_CODES: err_type = int(str(self.error_code)[:-2])
return ERROR_CODES[self.error_code] err_subtype = int(str(self.error_code)[-2:-1])
return "Unknown error type." err_value = int(str(self.error_code)[-1:])
try:
select_err_subtype = ERROR_CODES[err_type][err_subtype]
if err_value in select_err_subtype:
return select_err_subtype[err_value]
elif "n" in select_err_subtype:
return select_err_subtype["n"].replace("{n}", str(err_value)) # noqa: picks up `select_err_subtype["n"]` as not being numeric?
else:
return "Unknown error type."
except KeyError:
return "Unknown error type."
@error_message.setter @error_message.setter
def error_message(self, val): def error_message(self, val):
@@ -42,131 +56,158 @@ class WhatsminerError:
ERROR_CODES = { ERROR_CODES = {
110: "Intake fan speed error.", 1: { # Fan error
111: "Exhaust fan speed error.", 1: { # Fan speed error of 1000+
120: "Intake fan speed error. Fan speed deviates by more than 2000.", 0: "Intake fan speed error.",
121: "Exhaust fan speed error. Fan speed deviates by more than 2000.", 1: "Exhaust fan speed error.",
130: "Intake fan speed error. Fan speed deviates by more than 3000.", },
131: "Exhaust fan speed error. Fan speed deviates by more than 3000.", 2: { # Fan speed error of 2000+
140: "Fan speed too high.", 0: "Intake fan speed error. Fan speed deviates by more than 2000.",
200: "Power probing error. No power found.", 1: "Exhaust fan speed error. Fan speed deviates by more than 2000.",
201: "Power supply and configuration file don't match.", },
202: "Power output voltage error.", 3: { # Fan speed error of 3000+
203: "Power protecting due to high environment temperature.", 0: "Intake fan speed error. Fan speed deviates by more than 3000.",
204: "Power current protecting due to high environment temperature.", 1: "Exhaust fan speed error. Fan speed deviates by more than 3000.",
205: "Power current error.", },
206: "Power input low voltage error.", 4: {0: "Fan speed too high."}, # High speed
207: "Power input current protecting due to bad power input.", },
210: "Power error.", 2: { # Power error
213: "Power input voltage and current do not match power output.", 0: {
216: "Power remained unchanged for a long time.", 0: "Power probing error. No power found.",
217: "Power set enable error.", 1: "Power supply and configuration file don't match.",
218: "Power input voltage is lower than 230V for high power mode.", 2: "Power output voltage error.",
233: "Power output high temperature protection error.", 3: "Power protecting due to high environment temperature.",
234: "Power output high temperature protection error.", 4: "Power current protecting due to high environment temperature.",
235: "Power output high temperature protection error.", 5: "Power current error.",
236: "Power output high current protection error.", 6: "Power input low voltage error.",
237: "Power output high current protection error.", 7: "Power input current protecting due to bad power input.",
238: "Power output high current protection error.", },
239: "Power output high voltage protection error.", 1: {
240: "Power output low voltage protection error.", 0: "Power error.",
241: "Power output current imbalance error.", 3: "Power input voltage and current do not match power output.",
243: "Power input high temperature protection error.", 6: "Power remained unchanged for a long time.",
244: "Power input high temperature protection error.", 7: "Power set enable error.",
245: "Power input high temperature protection error.", 8: "Power input voltage is lower than 230V for high power mode.",
246: "Power input high voltage protection error.", },
247: "Power input high voltage protection error.", 3: {
248: "Power input high current protection error.", 3: "Power output high temperature protection error.",
249: "Power input high current protection error.", 4: "Power output high temperature protection error.",
250: "Power input low voltage protection error.", 5: "Power output high temperature protection error.",
251: "Power input low voltage protection error.", 6: "Power output high current protection error.",
253: "Power supply fan error.", 7: "Power output high current protection error.",
254: "Power supply fan error.", 8: "Power output high current protection error.",
255: "Power output high power protection error.", 9: "Power output high voltage protection error.",
256: "Power output high power protection error.", },
257: "Input over current protection of power supply on primary side.", 4: {
263: "Power communication warning.", 0: "Power output low voltage protection error.",
264: "Power communication error.", 1: "Power output current imbalance error.",
267: "Power watchdog protection.", 3: "Power input high temperature protection error.",
268: "Power output high current protection.", 4: "Power input high temperature protection error.",
269: "Power input high current protection.", 5: "Power input high temperature protection error.",
270: "Power input high voltage protection.", 6: "Power input high voltage protection error.",
271: "Power input low voltage protection.", 7: "Power input high voltage protection error.",
272: "Excessive power supply output warning.", 8: "Power input high current protection error.",
273: "Power input too high warning.", 9: "Power input high current protection error.",
274: "Power fan warning.", },
275: "Power high temperature warning.", 5: {
300: "Right board temperature sensor detection error.", 0: "Power input low voltage protection error.",
301: "Center board temperature sensor detection error.", 1: "Power input low voltage protection error.",
302: "Left board temperature sensor detection error.", 3: "Power supply fan error.",
320: "Right board temperature reading error.", 4: "Power supply fan error.",
321: "Center board temperature reading error.", 5: "Power output high power protection error.",
322: "Left board temperature reading error.", 6: "Power output high power protection error.",
329: "Control board temperature sensor communication error.", 7: "Input over current protection of power supply on primary side.",
350: "Right board temperature protecting.", },
351: "Center board temperature protecting.", 6: {
352: "Left board temperature protecting.", 3: "Power communication warning.",
360: "Hashboard high temperature error.", 4: "Power communication error.",
410: "Right board eeprom detection error.", 7: "Power watchdog protection.",
411: "Center board eeprom detection error.", 8: "Power output high current protection.",
412: "Left board eeprom detection error.", 9: "Power input high current protection.",
420: "Right board eeprom parsing error.", },
421: "Center board eeprom parsing error.", 7: {
422: "Left board eeprom parsing error.", 0: "Power input high voltage protection.",
430: "Right board chip bin type error.", 1: "Power input low voltage protection.",
431: "Center board chip bin type error.", 2: "Excessive power supply output warning.",
432: "Left board chip bin type error.", 3: "Power input too high warning.",
440: "Right board eeprom chip number X error.", 4: "Power fan warning.",
441: "Center board eeprom chip number X error.", 5: "Power high temperature warning.",
442: "Left board eeprom chip number X error.", },
450: "Right board eeprom xfer error.", },
451: "Center board eeprom xfer error.", 3: { # temperature error
452: "Left board eeprom xfer error.", 0: { # sensor detection error
510: "Right board miner type error.", "n": "Slot {n} temperature sensor detection error."
511: "Center board miner type error.", },
512: "Left board miner type error.", 2: { # temperature reading error
520: "Right board bin type error.", "n": "Slot {n} temperature reading error.",
521: "Center board bin type error.", 9: "Control board temperature sensor communication error.",
522: "Left board bin type error.", },
530: "Right board not found.", 5: {"n": "Slot {n} temperature protecting."}, # temperature protection
531: "Center board not found.", 6: {0: "Hashboard high temperature error."}, # high temp
532: "Left board not found.", },
540: "Right board error reading chip id.", 4: { # EEPROM error
541: "Center board error reading chip id.", 1: {"n": "Slot {n} eeprom detection error."}, # EEPROM detection error
542: "Left board error reading chip id.", 2: {"n": "Slot {n} eeprom parsing error."}, # EEPROM parsing error
550: "Right board has bad chips.", 3: {"n": "Slot {n} chip bin type error."}, # chip bin error
551: "Center board has bad chips.", 4: {"n": "Slot {n} eeprom chip number X error."}, # EEPROM chip number error
552: "Left board has bad chips.", 5: {"n": "Slot {n} eeprom xfer error."}, # EEPROM xfer error
560: "Right board loss of balance error.", },
561: "Center board loss of balance error.", 5: { # hashboard error
562: "Left board loss of balance error.", 1: {"n": "Slot {n} miner type error."}, # board miner type error
600: "Environment temperature is too high.", 2: {"n": "Slot {n} bin type error."}, # chip bin type error
610: "Environment temperature is too high for high performance mode.", 3: {"n": "Slot {n} not found."}, # board not found error
701: "Control board no support chip.", 4: {"n": "Slot {n} error reading chip id."}, # reading chip id error
710: "Control board rebooted as an exception.", 5: {"n": "Slot {n} has bad chips."}, # board has bad chips error
712: "Control board rebooted as an exception.", 6: {"n": "Slot {n} loss of balance error."}, # loss of balance error
800: "CGMiner checksum error.", },
801: "System monitor checksum error.", 6: { # env temp error
802: "Remote daemon checksum error.", 0: {0: "Environment temperature is too high."}, # normal env temp error
2010: "All pools are disabled.", 1: { # high power env temp error
2020: "Pool 0 connection failed.", 0: "Environment temperature is too high for high performance mode."
2021: "Pool 1 connection failed.", },
2022: "Pool 2 connection failed.", },
2023: "Pool 3 connection failed.", 7: { # control board error
2030: "High rejection rate on pool.", 0: {1: "Control board no support chip."},
2040: "The pool does not support asicboost mode.", 1: {
2310: "Hashrate is too low.", 0: "Control board rebooted as an exception.",
2320: "Hashrate is too low.", 2: "Control board rebooted as an exception.",
2340: "Hashrate loss is too high.", },
2350: "Hashrate loss is too high.", },
5070: "Right hashboard water velocity is abnormal.", 8: { # checksum error
5071: "Center hashboard water velocity is abnormal.", 0: {
5072: "Left hashboard water velocity is abnormal.", 0: "CGMiner checksum error.",
5110: "Right hashboard frequency up timeout.", 1: "System monitor checksum error.",
5111: "Center hashboard frequency up timeout.", 2: "Remote daemon checksum error.",
5112: "Left hashboard frequency up timeout.", }
8410: "Software version error.", },
100001: "/antiv/signature illegal.", 20: { # pool error
100002: "/antiv/dig/init.d illegal.", 1: {0: "All pools are disabled."}, # all disabled error
100003: "/antiv/dig/pf_partial.dig illegal.", 2: {"n": "Pool {n} connection failed."}, # pool connection failed error
3: {0: "High rejection rate on pool."}, # rejection rate error
4: { # asicboost not supported error
0: "The pool does not support asicboost mode."
},
},
23: { # hashrate error
1: {0: "Hashrate is too low."},
2: {0: "Hashrate is too low."},
3: {0: "Hashrate loss is too high."},
4: {0: "Hashrate loss is too high."},
},
50: { # water velocity error
7: {"n": "Slot {n} water velocity is abnormal."}, # abnormal water velocity
},
51: { # frequency error
7: {"n": "Slot {n} frequency up timeout."}, # frequency up timeout
},
84: {
1: {0: "Software version error."},
},
1000: {
0: {
1: "/antiv/signature illegal.",
2: "/antiv/dig/init.d illegal.",
3: "/antiv/dig/pf_partial.dig illegal.",
},
},
} }

View File

@@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import logging import logging
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings

View File

@@ -15,9 +15,10 @@
import ipaddress import ipaddress
from typing import Union from typing import Union
from pyasic.miners.base import BaseMiner, AnyMiner from pyasic.miners.base import AnyMiner, BaseMiner
from pyasic.miners.miner_factory import MinerFactory from pyasic.miners.miner_factory import MinerFactory
# abstracted version of get miner that is easier to access # abstracted version of get miner that is easier to access
async def get_miner(ip: Union[ipaddress.ip_address, str]) -> AnyMiner: async def get_miner(ip: Union[ipaddress.ip_address, str]) -> AnyMiner:
return await MinerFactory().get_miner(ip) return await MinerFactory().get_miner(ip)

View File

@@ -14,16 +14,13 @@
import ipaddress import ipaddress
import logging import logging
from typing import Union, List from typing import List, Union
from pyasic.API.bmminer import BMMinerAPI from pyasic.API.bmminer import BMMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.data import MinerData
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData from pyasic.data.error_codes import MinerErrorData
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
@@ -185,13 +182,17 @@ class BMMiner(BaseMiner):
async def resume_mining(self) -> bool: async def resume_mining(self) -> bool:
return False return False
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = False) -> MinerData:
"""Get data from the miner. """Get data from the miner.
Returns: Returns:
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data. A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
""" """
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
)
board_offset = -1 board_offset = -1
fan_offset = -1 fan_offset = -1
@@ -219,7 +220,7 @@ class BMMiner(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", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -242,7 +243,7 @@ class BMMiner(BaseMiner):
if stats: if stats:
boards = stats.get("STATS") boards = stats.get("STATS")
if boards: if boards:
if len(boards) > 0: if len(boards) > 1:
for board_num in range(1, 16, 5): for board_num in range(1, 16, 5):
for _b_num in range(5): for _b_num in range(5):
b = boards[1].get(f"chain_acn{board_num + _b_num}") b = boards[1].get(f"chain_acn{board_num + _b_num}")
@@ -252,30 +253,38 @@ class BMMiner(BaseMiner):
if board_offset == -1: if board_offset == -1:
board_offset = 1 board_offset = 1
data.left_chips = boards[1].get(f"chain_acn{board_offset}") env_temp_list = []
data.center_chips = boards[1].get(f"chain_acn{board_offset+1}") for i in range(board_offset, board_offset + self.ideal_hashboards):
data.right_chips = boards[1].get(f"chain_acn{board_offset+2}") hashboard = HashBoard(
slot=i - board_offset, expected_chips=self.nominal_chips
)
try: chip_temp = boards[1].get(f"temp{i}")
data.left_board_hashrate = round( if chip_temp:
float(boards[1].get(f"chain_rate{board_offset}")) / 1000, 2 hashboard.chip_temp = round(chip_temp)
)
except ValueError as e: temp = boards[1].get(f"temp2_{i}")
data.left_board_hashrate = round(0.00, 2) if temp:
try: hashboard.temp = round(temp)
data.center_board_hashrate = round(
float(boards[1].get(f"chain_rate{board_offset+1}")) / 1000, hashrate = boards[1].get(f"chain_rate{i}")
2, if hashrate:
) hashboard.hashrate = round(float(hashrate) / 1000, 2)
except ValueError as e:
data.center_board_hashrate = round(0.00, 2) chips = boards[1].get(f"chain_acn{i}")
try: if chips:
data.right_board_hashrate = round( hashboard.chips = chips
float(boards[1].get(f"chain_rate{board_offset+2}")) / 1000, hashboard.missing = False
2, if (not chips) or (not chips > 0):
) hashboard.missing = True
except ValueError as e: data.hashboards.append(hashboard)
data.right_board_hashrate = round(0.00, 2)
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 = round(sum(env_temp_list) / len(env_temp_list))
if stats: if stats:
temp = stats.get("STATS") temp = stats.get("STATS")
@@ -293,20 +302,6 @@ class BMMiner(BaseMiner):
data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}") data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}")
) )
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
env_temp_list = []
for item in range(3):
board_temp = temp[1].get(f"temp{item + board_offset}")
chip_temp = temp[1].get(f"temp2_{item + board_offset}")
setattr(data, f"{board_map[item]}_chip_temp", chip_temp)
setattr(data, f"{board_map[item]}_temp", board_temp)
if f"temp_pcb{item}" in temp[1].keys():
env_temp = temp[1][f"temp_pcb{item}"].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)
if pools: if pools:
pool_1 = None pool_1 = None
pool_2 = None pool_2 = None

View File

@@ -13,22 +13,19 @@
# limitations under the License. # limitations under the License.
import ipaddress import ipaddress
import logging
import json import json
from typing import Union, List import logging
from typing import List, Union
import toml import toml
import httpx
from pyasic.miners.base import BaseMiner
from pyasic.API.bosminer import BOSMinerAPI from pyasic.API.bosminer import BOSMinerAPI
from pyasic.errors import APIError
from pyasic.data.error_codes import BraiinsOSError, MinerErrorData
from pyasic.data import MinerData
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import BraiinsOSError, MinerErrorData
from pyasic.errors import APIError
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
@@ -69,6 +66,24 @@ class BOSMiner(BaseMiner):
# return the result, either command output or None # return the result, either command output or None
return str(result) return str(result)
async def send_graphql_query(self, query) -> Union[dict, None]:
url = f"http://{self.ip}/graphql"
async with httpx.AsyncClient() as client:
_auth = await client.post(
url,
json={
"query": 'mutation{auth{login(username:"'
+ self.uname
+ '", password:"'
+ self.pwd
+ '"){__typename}}}'
},
)
d = await client.post(url, json={"query": query})
if d.status_code == 200:
return d.json()
return None
async def fault_light_on(self) -> bool: async def fault_light_on(self) -> bool:
"""Sends command to turn on fault light on the miner.""" """Sends command to turn on fault light on the miner."""
logging.debug(f"{self}: Sending fault_light on command.") logging.debug(f"{self}: Sending fault_light on command.")
@@ -152,6 +167,11 @@ class BOSMiner(BaseMiner):
""" """
if self.hostname: if self.hostname:
return self.hostname return self.hostname
# get hostname through GraphQL
if data := await self.send_graphql_query("{bos {hostname}}"):
self.hostname = data["data"]["bos"]["hostname"]
return self.hostname
try: try:
async with (await self._get_ssh_connection()) as conn: async with (await self._get_ssh_connection()) as conn:
if conn is not None: if conn is not None:
@@ -215,9 +235,15 @@ class BOSMiner(BaseMiner):
if self.version: if self.version:
logging.debug(f"Found version for {self.ip}: {self.version}") logging.debug(f"Found version for {self.ip}: {self.version}")
return self.version return self.version
version_data = None
# try to get data from graphql
data = await self.send_graphql_query("{bos{info{version{full}}}}")
if data:
version_data = data["bos"]["info"]["version"]["full"]
# get output of bos version file if not version_data:
version_data = await self.send_ssh_command("cat /etc/bos_version") # try version data file
version_data = await self.send_ssh_command("cat /etc/bos_version")
# if we get the version data, parse it # if we get the version data, parse it
if version_data: if version_data:
@@ -248,6 +274,15 @@ class BOSMiner(BaseMiner):
async def check_light(self) -> bool: async def check_light(self) -> bool:
if self.light: if self.light:
return self.light return self.light
# get light through GraphQL
if data := await self.send_graphql_query("{bos {faultLight}}"):
try:
self.light = data["data"]["bos"]["faultLight"]
return self.light
except (TypeError, KeyError, ValueError):
pass
# get light via ssh if that fails (10x slower)
data = ( data = (
await self.send_ssh_command("cat /sys/class/leds/'Red LED'/delay_off") await self.send_ssh_command("cat /sys/class/leds/'Red LED'/delay_off")
).strip() ).strip()
@@ -266,7 +301,10 @@ class BOSMiner(BaseMiner):
logging.warning(e) logging.warning(e)
if tunerstatus: if tunerstatus:
tuner = tunerstatus[0].get("TUNERSTATUS") try:
tuner = tunerstatus[0].get("TUNERSTATUS")
except KeyError:
tuner = tunerstatus.get("TUNERSTATUS")
if tuner: if tuner:
if len(tuner) > 0: if len(tuner) > 0:
chain_status = tuner[0].get("TunerChainStatus") chain_status = tuner[0].get("TunerChainStatus")
@@ -286,6 +324,7 @@ class BOSMiner(BaseMiner):
if board["Status"] not in [ if board["Status"] not in [
"Stable", "Stable",
"Testing performance profile", "Testing performance profile",
"Tuning individual chips"
]: ]:
_error = board["Status"].split(" {")[0] _error = board["Status"].split(" {")[0]
_error = _error[0].lower() + _error[1:] _error = _error[0].lower() + _error[1:]
@@ -294,13 +333,25 @@ class BOSMiner(BaseMiner):
) )
return errors return errors
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = True) -> MinerData:
"""Get data from the miner. """Get data from the miner.
Returns: Returns:
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data. A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
""" """
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) d = await self._graphql_get_data()
if d:
return d
data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips)
for i in range(self.ideal_hashboards)
],
)
board_offset = -1 board_offset = -1
fan_offset = -1 fan_offset = -1
@@ -331,6 +382,7 @@ class BOSMiner(BaseMiner):
"devdetails", "devdetails",
"fans", "fans",
"devs", "devs",
allow_warning=allow_warning,
) )
except APIError as e: except APIError as e:
if str(e.message) == "Not ready": if str(e.message) == "Not ready":
@@ -361,14 +413,13 @@ class BOSMiner(BaseMiner):
temp = temps[0].get("TEMPS") temp = temps[0].get("TEMPS")
if temp: if temp:
if len(temp) > 0: if len(temp) > 0:
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
offset = 6 if temp[0]["ID"] in [6, 7, 8] else temp[0]["ID"] offset = 6 if temp[0]["ID"] in [6, 7, 8] else temp[0]["ID"]
for board in temp: for board in temp:
_id = board["ID"] - offset _id = board["ID"] - offset
chip_temp = round(board["Chip"]) chip_temp = round(board["Chip"])
board_temp = round(board["Board"]) board_temp = round(board["Board"])
setattr(data, f"{board_map[_id]}_chip_temp", chip_temp) data.hashboards[_id].chip_temp = chip_temp
setattr(data, f"{board_map[_id]}_temp", board_temp) data.hashboards[_id].temp = board_temp
if fans: if fans:
fan_data = fans[0].get("FANS") fan_data = fans[0].get("FANS")
@@ -461,27 +512,155 @@ class BOSMiner(BaseMiner):
boards = devdetails[0].get("DEVDETAILS") boards = devdetails[0].get("DEVDETAILS")
if boards: if boards:
if len(boards) > 0: if len(boards) > 0:
board_map = {0: "left_chips", 1: "center_chips", 2: "right_chips"}
offset = 6 if boards[0]["ID"] in [6, 7, 8] else boards[0]["ID"] offset = 6 if boards[0]["ID"] in [6, 7, 8] else boards[0]["ID"]
for board in boards: for board in boards:
_id = board["ID"] - offset _id = board["ID"] - offset
chips = board["Chips"] chips = board["Chips"]
setattr(data, board_map[_id], chips) data.hashboards[_id].chips = chips
if chips > 0:
data.hashboards[_id].missing = False
else:
data.hashboards[_id].missing = True
if devs: if devs:
boards = devs[0].get("DEVS") boards = devs[0].get("DEVS")
if boards: if boards:
if len(boards) > 0: if len(boards) > 0:
board_map = {
0: "left_board_hashrate",
1: "center_board_hashrate",
2: "right_board_hashrate",
}
offset = 6 if boards[0]["ID"] in [6, 7, 8] else boards[0]["ID"] offset = 6 if boards[0]["ID"] in [6, 7, 8] else boards[0]["ID"]
for board in boards: for board in boards:
_id = board["ID"] - offset _id = board["ID"] - offset
hashrate = round(board["MHS 1m"] / 1000000, 2) hashrate = round(board["MHS 1m"] / 1000000, 2)
setattr(data, board_map[_id], hashrate) data.hashboards[_id].hashrate = hashrate
return data
async def _graphql_get_data(self) -> Union[MinerData, None]:
data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips, missing=True)
for i in range(self.ideal_hashboards)
],
)
query = "{bos {hostname}, bosminer{config{... on BosminerConfig{groups{pools{url, user}, strategy{... on QuotaStrategy {quota}}}}}, info{fans{name, rpm}, workSolver{realHashrate{mhs1M}, temperatures{degreesC}, power{limitW, approxConsumptionW}, childSolvers{name, realHashrate{mhs1M}, hwDetails{chips}, tuner{statusMessages}, temperatures{degreesC}}}}}}"
query_data = await self.send_graphql_query(query)
if not query_data:
return None
query_data = query_data["data"]
data.mac = await self.get_mac()
data.model = await self.get_model()
if query_data.get("bos"):
if query_data["bos"].get("hostname"):
data.hostname = query_data["bos"]["hostname"]
try:
if query_data["bosminer"]["info"]["workSolver"]["realHashrate"].get("mhs1M"):
data.hashrate = round(
query_data["bosminer"]["info"]["workSolver"]["realHashrate"]["mhs1M"]
/ 1000000,
2,
)
except (TypeError, KeyError, ValueError):
pass
boards = None
if query_data.get("bosminer"):
if query_data["bosminer"].get("info"):
if query_data["bosminer"]["info"].get("workSolver"):
boards = query_data["bosminer"]["info"]["workSolver"].get("childSolvers")
if boards:
offset = 6 if int(boards[0]["name"]) in [6, 7, 8] else int(boards[0]["name"])
for hb in boards:
_id = int(hb["name"]) - offset
board = data.hashboards[_id]
board.hashrate = round(hb["realHashrate"]["mhs1M"] / 1000000, 2)
temps = hb["temperatures"]
if len(temps) > 0:
board.temp = round(hb["temperatures"][0]["degreesC"])
if len(temps) > 1:
board.chip_temp = round(hb["temperatures"][1]["degreesC"])
details = hb.get("hwDetails")
if details:
if chips := details["chips"]:
board.chips = chips
board.missing = False
tuner = hb.get("tuner")
if tuner:
if msg := tuner.get("statusMessages"):
if len(msg) > 0:
if hb["tuner"]["statusMessages"][0] not in [
"Stable",
"Testing performance profile",
"Tuning individual chips"
]:
data.errors.append(
BraiinsOSError(f"Slot {_id} {hb['tuner']['statusMessages'][0]}")
)
try:
data.wattage = query_data["bosminer"]["info"]["workSolver"]["power"]["approxConsumptionW"]
except (TypeError, KeyError, ValueError):
pass
try:
data.wattage_limit = query_data["bosminer"]["info"]["workSolver"]["power"]["limitW"]
except (TypeError, KeyError, ValueError):
pass
for n in range(self.fan_count):
try:
setattr(data, f"fan_{n + 1}", query_data["bosminer"]["info"]["fans"][n]["rpm"])
except (TypeError, KeyError, ValueError):
pass
groups = None
if query_data.get("bosminer"):
if query_data["bosminer"].get("config"):
groups = query_data["bosminer"]["config"].get("groups")
if groups:
if len(groups) == 1:
try:
data.pool_1_user = groups[0]["pools"][0]["user"]
except (TypeError, KeyError, ValueError):
pass
try:
data.pool_1_url = groups[0]["pools"][0]["url"]
except (TypeError, KeyError, ValueError):
pass
try:
data.pool_2_user = groups[0]["pools"][1]["user"]
except (TypeError, KeyError, ValueError):
pass
try:
data.pool_2_url = groups[0]["pools"][1]["url"]
except (TypeError, KeyError, ValueError):
pass
data.quota = 0
else:
try:
data.pool_1_user = groups[0]["pools"][0]["user"]
except (TypeError, KeyError, ValueError):
pass
try:
data.pool_1_url = groups[0]["pools"][0]["url"]
except (TypeError, KeyError, ValueError):
pass
try:
data.pool_2_user = groups[1]["pools"][0]["user"]
except (TypeError, KeyError, ValueError):
pass
try:
data.pool_2_url = groups[1]["pools"][0]["url"]
except (TypeError, KeyError, ValueError):
pass
if groups[0]["strategy"].get("quota"):
data.quota = groups[0]["strategy"]["quota"] + "/" + groups[1]["strategy"]["quota"]
data.fault_light = await self.check_light()
return data return data
async def get_mac(self): async def get_mac(self):

View File

@@ -12,16 +12,15 @@
# 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.
import logging
import ipaddress import ipaddress
from typing import Union, List import logging
from typing import List, Union
from pyasic.API.bosminer import BOSMinerAPI from pyasic.API.bosminer import BOSMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import MinerData from pyasic.data import MinerData
from pyasic.data.error_codes import MinerErrorData from pyasic.data.error_codes import MinerErrorData
from pyasic.miners.base import BaseMiner
class BOSMinerOld(BaseMiner): class BOSMinerOld(BaseMiner):

View File

@@ -14,17 +14,14 @@
import ipaddress import ipaddress
import logging import logging
from typing import Union, List from typing import List, Union
from pyasic.API.btminer import BTMinerAPI from pyasic.API.btminer import BTMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.errors import APIError
from pyasic.data import MinerData
from pyasic.data.error_codes import WhatsminerError, MinerErrorData
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import MinerErrorData, WhatsminerError
from pyasic.errors import APIError
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
@@ -109,7 +106,6 @@ class BTMiner(BaseMiner):
if "Code" in data.keys(): if "Code" in data.keys():
if data["Code"] == 131: if data["Code"] == 131:
return True return True
print(data)
return False return False
async def check_light(self) -> bool: async def check_light(self) -> bool:
@@ -166,28 +162,22 @@ class BTMiner(BaseMiner):
for err in err_data["Msg"]["error_code"]: for err in err_data["Msg"]["error_code"]:
if isinstance(err, dict): if isinstance(err, dict):
for code in err: for code in err:
data.append( data.append(WhatsminerError(error_code=int(code)))
WhatsminerError(
error_code=int(code)
)
)
else: else:
data.append( data.append(WhatsminerError(error_code=int(err)))
WhatsminerError(
error_code=int(err)
)
)
except APIError: except APIError:
summary_data = await self.api.summary() summary_data = await self.api.summary()
if summary_data[0].get("Error Code Count"): if summary_data.get("SUMMARY"):
for i in range(summary_data[0]["Error Code Count"]): summary_data = summary_data["SUMMARY"]
if summary_data[0].get(f"Error Code {i}"): if summary_data[0].get("Error Code Count"):
if not summary_data[0][f"Error Code {i}"] == "": for i in range(summary_data[0]["Error Code Count"]):
data.append( if summary_data[0].get(f"Error Code {i}"):
WhatsminerError( if not summary_data[0][f"Error Code {i}"] == "":
error_code=summary_data[0][f"Error Code {i}"] data.append(
WhatsminerError(
error_code=summary_data[0][f"Error Code {i}"]
)
) )
)
return data return data
@@ -248,13 +238,17 @@ class BTMiner(BaseMiner):
cfg = cfg.from_api(pools["POOLS"]) cfg = cfg.from_api(pools["POOLS"])
return cfg return cfg
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = True) -> MinerData:
"""Get data from the miner. """Get data from the miner.
Returns: Returns:
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data. A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
""" """
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
)
mac = None mac = None
@@ -283,7 +277,7 @@ class BTMiner(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):
try: try:
miner_data = await self.api.multicommand("summary", "devs", "pools") miner_data = await self.api.multicommand("summary", "devs", "pools", allow_warning=allow_warning)
if miner_data: if miner_data:
break break
except APIError: except APIError:
@@ -361,44 +355,25 @@ class BTMiner(BaseMiner):
if isinstance(err, dict): if isinstance(err, dict):
for code in err: for code in err:
data.errors.append( data.errors.append(
WhatsminerError( WhatsminerError(error_code=int(code))
error_code=int(code)
)
) )
else: else:
data.errors.append( data.errors.append(WhatsminerError(error_code=int(err)))
WhatsminerError(
error_code=int(err)
)
)
if devs: if devs:
temp_data = devs.get("DEVS") dev_data = devs.get("DEVS")
if temp_data: if dev_data:
board_map = {0: "left_board", 1: "center_board", 2: "right_board"} for board in dev_data:
for board in temp_data: temp_board = HashBoard(
_id = board["ASC"] slot=board["ASC"],
chip_temp = round(board["Chip Temp Avg"]) chip_temp=round(board["Chip Temp Avg"]),
board_temp = round(board["Temperature"]) temp=round(board["Temperature"]),
hashrate = round(board["MHS 1m"] / 1000000, 2) hashrate=round(board["MHS 1m"] / 1000000, 2),
setattr(data, f"{board_map[_id]}_chip_temp", chip_temp) chips=board["Effective Chips"],
setattr(data, f"{board_map[_id]}_temp", board_temp) missing=False if board["Effective Chips"] > 0 else True,
setattr(data, f"{board_map[_id]}_hashrate", hashrate) expected_chips=self.nominal_chips,
)
if devs: data.hashboards.append(temp_board)
boards = devs.get("DEVS")
if boards:
if len(boards) > 0:
board_map = {0: "left_chips", 1: "center_chips", 2: "right_chips"}
if "ID" in boards[0].keys():
id_key = "ID"
else:
id_key = "ASC"
offset = boards[0][id_key]
for board in boards:
_id = board[id_key] - offset
chips = board["Effective Chips"]
setattr(data, board_map[_id], chips)
if pools: if pools:
pool_1 = None pool_1 = None

View File

@@ -14,17 +14,14 @@
import ipaddress import ipaddress
import logging import logging
from typing import Union, List from typing import List, Union
from pyasic.API.cgminer import CGMinerAPI from pyasic.API.cgminer import CGMinerAPI
from pyasic.miners.base import BaseMiner
from pyasic.errors import APIError
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.data import MinerData
from pyasic.data.error_codes import MinerErrorData from pyasic.data.error_codes import MinerErrorData
from pyasic.errors import APIError
from pyasic.miners.base import BaseMiner
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
@@ -173,13 +170,17 @@ class CGMiner(BaseMiner):
async def get_mac(self) -> str: async def get_mac(self) -> str:
return "00:00:00:00:00:00" return "00:00:00:00:00:00"
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = False) -> MinerData:
"""Get data from the miner. """Get data from the miner.
Returns: Returns:
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data. A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
""" """
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
)
board_offset = -1 board_offset = -1
fan_offset = -1 fan_offset = -1
@@ -202,7 +203,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", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -235,19 +236,38 @@ class CGMiner(BaseMiner):
if board_offset == -1: if board_offset == -1:
board_offset = 1 board_offset = 1
data.left_chips = boards[1].get(f"chain_acn{board_offset}") env_temp_list = []
data.center_chips = boards[1].get(f"chain_acn{board_offset+1}") for i in range(board_offset, board_offset + self.ideal_hashboards):
data.right_chips = boards[1].get(f"chain_acn{board_offset+2}") hashboard = HashBoard(
slot=i - board_offset, expected_chips=self.nominal_chips
)
data.left_board_hashrate = round( chip_temp = boards[1].get(f"temp{i}")
float(boards[1].get(f"chain_rate{board_offset}")) / 1000, 2 if chip_temp:
) hashboard.chip_temp = round(chip_temp)
data.center_board_hashrate = round(
float(boards[1].get(f"chain_rate{board_offset+1}")) / 1000, 2 temp = boards[1].get(f"temp2_{i}")
) if temp:
data.right_board_hashrate = round( hashboard.temp = round(temp)
float(boards[1].get(f"chain_rate{board_offset+2}")) / 1000, 2
) hashrate = boards[1].get(f"chain_rate{i}")
if hashrate:
hashboard.hashrate = round(float(hashrate) / 1000, 2)
chips = boards[1].get(f"chain_acn{i}")
if chips:
hashboard.chips = chips
hashboard.missing = False
if (not chips) or (not chips > 0):
hashboard.missing = True
data.hashboards.append(hashboard)
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 = round(sum(env_temp_list) / len(env_temp_list))
if stats: if stats:
temp = stats.get("STATS") temp = stats.get("STATS")
@@ -265,19 +285,6 @@ class CGMiner(BaseMiner):
data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}") data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}")
) )
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
env_temp_list = []
for item in range(3):
board_temp = temp[1].get(f"temp{item + board_offset}")
chip_temp = temp[1].get(f"temp2_{item + board_offset}")
setattr(data, f"{board_map[item]}_chip_temp", chip_temp)
setattr(data, f"{board_map[item]}_temp", board_temp)
if f"temp_pcb{item}" in temp[1].keys():
env_temp = temp[1][f"temp_pcb{item}"].split("-")[0]
if not env_temp == 0:
env_temp_list.append(int(env_temp))
data.env_temp = sum(env_temp_list) / len(env_temp_list)
if pools: if pools:
pool_1 = None pool_1 = None
pool_2 = None pool_2 = None

View File

@@ -12,9 +12,10 @@
# 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.miners._backends import BMMiner
import ipaddress import ipaddress
from pyasic.miners._backends import BMMiner
class Hiveon(BMMiner): class Hiveon(BMMiner):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -14,5 +14,5 @@
from .antminer import * from .antminer import *
from .avalonminer import * from .avalonminer import *
from .whatsminer import *
from .innosilicon import * from .innosilicon import *
from .whatsminer import *

View File

@@ -16,7 +16,6 @@ from .S17 import S17
from .S17_Plus import S17Plus from .S17_Plus import S17Plus
from .S17_Pro import S17Pro from .S17_Pro import S17Pro
from .S17e import S17e from .S17e import S17e
from .T17 import T17 from .T17 import T17
from .T17_Plus import T17Plus from .T17_Plus import T17Plus
from .T17e import T17e from .T17e import T17e

View File

@@ -14,12 +14,8 @@
from .S19 import S19 from .S19 import S19
from .S19_Pro import S19Pro from .S19_Pro import S19Pro
from .S19_XP import S19XP
from .S19a import S19a
from .S19j import S19j from .S19j import S19j
from .S19j_Pro import S19jPro from .S19j_Pro import S19jPro
from .S19_XP import S19XP
from .S19a import S19a
from .T19 import T19 from .T19 import T19

View File

@@ -15,7 +15,6 @@
from .M20 import M20, M20V10 from .M20 import M20, M20V10
from .M20S import M20S, M20SV10, M20SV20 from .M20S import M20S, M20SV10, M20SV20
from .M20S_Plus import M20SPlus from .M20S_Plus import M20SPlus
from .M21 import M21 from .M21 import M21
from .M21S import M21S, M21SV20, M21SV60 from .M21S import M21S, M21SV20, M21SV60
from .M21S_Plus import M21SPlus from .M21S_Plus import M21SPlus

View File

@@ -0,0 +1,35 @@
# Copyright 2022 Upstream Data Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners.base import BaseMiner
class M34SPlus(BaseMiner):
def __init__(self, ip: str):
super().__init__()
self.ip = ip
self.model = "M34S+"
self.ideal_hashboards = 4
self.nominal_chips = 116
self.fan_count = 0
class M34SPlusVE10(BaseMiner):
def __init__(self, ip: str):
super().__init__()
self.ip = ip
self.model = "M34S+ VE10"
self.ideal_hashboards = 4
self.nominal_chips = 116
self.fan_count = 0

View File

@@ -12,25 +12,24 @@
# 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 .M30S import M30S, M30SVE10, M30SVE20, M30SVG20, M30SV50 from .M30S import M30S, M30SV50, M30SVE10, M30SVE20, M30SVG20
from .M30S_Plus import M30SPlus, M30SPlusVG60, M30SPlusVE40, M30SPlusVF20 from .M30S_Plus import M30SPlus, M30SPlusVE40, M30SPlusVF20, M30SPlusVG60
from .M30S_Plus_Plus import ( from .M30S_Plus_Plus import (
M30SPlusPlus, M30SPlusPlus,
M30SPlusPlusVG30, M30SPlusPlusVG30,
M30SPlusPlusVG40, M30SPlusPlusVG40,
M30SPlusPlusVH60, M30SPlusPlusVH60,
) )
from .M31S import M31S from .M31S import M31S
from .M31S_Plus import ( from .M31S_Plus import (
M31SPlus, M31SPlus,
M31SPlusVE20,
M31SPlusV30, M31SPlusV30,
M31SPlusV40, M31SPlusV40,
M31SPlusV80,
M31SPlusV60, M31SPlusV60,
M31SPlusV80,
M31SPlusV90, M31SPlusV90,
M31SPlusVE20,
) )
from .M32 import M32, M32V20 from .M32 import M32, M32V20
from .M32S import M32S from .M32S import M32S
from .M34S_Plus import M34SPlus, M34SPlusVE10

View File

@@ -14,4 +14,4 @@
from .M2X import * from .M2X import *
from .M3X import * from .M3X import *
from .M5X import * from .M5X import *

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import S17 # noqa - Ignore access to _module from pyasic.miners._types import S17 # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17(BMMinerX17, S17): class BMMinerS17(BMMinerX17, S17):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import S17Plus # noqa - Ignore access to _module from pyasic.miners._types import S17Plus # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17Plus(BMMinerX17, S17Plus): class BMMinerS17Plus(BMMinerX17, S17Plus):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import S17Pro # noqa - Ignore access to _module from pyasic.miners._types import S17Pro # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17Pro(BMMinerX17, S17Pro): class BMMinerS17Pro(BMMinerX17, S17Pro):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import S17e # noqa - Ignore access to _module from pyasic.miners._types import S17e # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerS17e(BMMinerX17, S17e): class BMMinerS17e(BMMinerX17, S17e):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import T17 # noqa - Ignore access to _module from pyasic.miners._types import T17 # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerT17(BMMinerX17, T17): class BMMinerT17(BMMinerX17, T17):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import T17Plus # noqa - Ignore access to _module from pyasic.miners._types import T17Plus # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerT17Plus(BMMinerX17, T17Plus): class BMMinerT17Plus(BMMinerX17, T17Plus):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X17 import BMMinerX17
from pyasic.miners._types import T17e # noqa - Ignore access to _module from pyasic.miners._types import T17e # noqa - Ignore access to _module
from .X17 import BMMinerX17
class BMMinerT17e(BMMinerX17, T17e): class BMMinerT17e(BMMinerX17, T17e):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,12 +12,12 @@
# 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.miners._backends import BMMiner # noqa - Ignore access to _module from typing import Union
from pyasic.settings import PyasicSettings
import httpx import httpx
from typing import Union
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class BMMinerX17(BMMiner): class BMMinerX17(BMMiner):

View File

@@ -16,7 +16,6 @@ from .S17 import BMMinerS17
from .S17_Plus import BMMinerS17Plus from .S17_Plus import BMMinerS17Plus
from .S17_Pro import BMMinerS17Pro from .S17_Pro import BMMinerS17Pro
from .S17e import BMMinerS17e from .S17e import BMMinerS17e
from .T17 import BMMinerT17 from .T17 import BMMinerT17
from .T17_Plus import BMMinerT17Plus from .T17_Plus import BMMinerT17Plus
from .T17e import BMMinerT17e from .T17e import BMMinerT17e

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import S19 # noqa - Ignore access to _module from pyasic.miners._types import S19 # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19(BMMinerX19, S19): class BMMinerS19(BMMinerX19, S19):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import S19Pro # noqa - Ignore access to _module from pyasic.miners._types import S19Pro # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19Pro(BMMinerX19, S19Pro): class BMMinerS19Pro(BMMinerX19, S19Pro):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import S19XP # noqa - Ignore access to _module from pyasic.miners._types import S19XP # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19XP(BMMinerX19, S19XP): class BMMinerS19XP(BMMinerX19, S19XP):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import S19a # noqa - Ignore access to _module from pyasic.miners._types import S19a # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19a(BMMinerX19, S19a): class BMMinerS19a(BMMinerX19, S19a):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import S19j # noqa - Ignore access to _module from pyasic.miners._types import S19j # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19j(BMMinerX19, S19j): class BMMinerS19j(BMMinerX19, S19j):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import S19jPro # noqa - Ignore access to _module from pyasic.miners._types import S19jPro # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerS19jPro(BMMinerX19, S19jPro): class BMMinerS19jPro(BMMinerX19, S19jPro):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .X19 import BMMinerX19
from pyasic.miners._types import T19 # noqa - Ignore access to _module from pyasic.miners._types import T19 # noqa - Ignore access to _module
from .X19 import BMMinerX19
class BMMinerT19(BMMinerX19, T19): class BMMinerT19(BMMinerX19, T19):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,16 +12,16 @@
# 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.miners._backends import BMMiner # noqa - Ignore access to _module import asyncio
import json
from pyasic.config import MinerConfig from typing import List, Union
from pyasic.data.error_codes import X19Error, MinerErrorData
from pyasic.settings import PyasicSettings
import httpx import httpx
import json
import asyncio from pyasic.config import MinerConfig
from typing import Union, List from pyasic.data.error_codes import MinerErrorData, X19Error
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class BMMinerX19(BMMiner): class BMMinerX19(BMMiner):

View File

@@ -14,12 +14,8 @@
from .S19 import BMMinerS19 from .S19 import BMMinerS19
from .S19_Pro import BMMinerS19Pro from .S19_Pro import BMMinerS19Pro
from .S19_XP import BMMinerS19XP
from .S19a import BMMinerS19a
from .S19j import BMMinerS19j from .S19j import BMMinerS19j
from .S19j_Pro import BMMinerS19jPro from .S19j_Pro import BMMinerS19jPro
from .S19_XP import BMMinerS19XP
from .S19a import BMMinerS19a
from .T19 import BMMinerT19 from .T19 import BMMinerT19

View File

@@ -16,7 +16,6 @@ from .S17 import BOSMinerS17
from .S17_Plus import BOSMinerS17Plus from .S17_Plus import BOSMinerS17Plus
from .S17_Pro import BOSMinerS17Pro from .S17_Pro import BOSMinerS17Pro
from .S17e import BOSMinerS17e from .S17e import BOSMinerS17e
from .T17 import BOSMinerT17 from .T17 import BOSMinerT17
from .T17_Plus import BOSMinerT17Plus from .T17_Plus import BOSMinerT17Plus
from .T17e import BOSMinerT17e from .T17e import BOSMinerT17e

View File

@@ -14,8 +14,6 @@
from .S19 import BOSMinerS19 from .S19 import BOSMinerS19
from .S19_Pro import BOSMinerS19Pro from .S19_Pro import BOSMinerS19Pro
from .S19j import BOSMinerS19j from .S19j import BOSMinerS19j
from .S19j_Pro import BOSMinerS19jPro from .S19j_Pro import BOSMinerS19jPro
from .T19 import BOSMinerT19 from .T19 import BOSMinerT19

View File

@@ -16,7 +16,6 @@ from .S17 import CGMinerS17
from .S17_Plus import CGMinerS17Plus from .S17_Plus import CGMinerS17Plus
from .S17_Pro import CGMinerS17Pro from .S17_Pro import CGMinerS17Pro
from .S17e import CGMinerS17e from .S17e import CGMinerS17e
from .T17 import CGMinerT17 from .T17 import CGMinerT17
from .T17_Plus import CGMinerT17Plus from .T17_Plus import CGMinerT17Plus
from .T17e import CGMinerT17e from .T17e import CGMinerT17e

View File

@@ -14,8 +14,6 @@
from .S19 import CGMinerS19 from .S19 import CGMinerS19
from .S19_Pro import CGMinerS19Pro from .S19_Pro import CGMinerS19Pro
from .S19j import CGMinerS19j from .S19j import CGMinerS19j
from .S19j_Pro import CGMinerS19jPro from .S19j_Pro import CGMinerS19jPro
from .T19 import CGMinerT19 from .T19 import CGMinerT19

View File

@@ -12,10 +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.data import HashBoard, MinerData
from pyasic.miners._backends import Hiveon # noqa - Ignore access to _module from pyasic.miners._backends import Hiveon # noqa - Ignore access to _module
from pyasic.miners._types import T9 # noqa - Ignore access to _module from pyasic.miners._types import T9 # noqa - Ignore access to _module
from pyasic.data import MinerData
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
@@ -33,13 +32,17 @@ class HiveonT9(Hiveon, T9):
) )
return mac return mac
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = False) -> MinerData:
"""Get data from the miner. """Get data from the miner.
Returns: Returns:
A [`MinerData`][pyasic.data.MinerData] instance containing the miners data. A [`MinerData`][pyasic.data.MinerData] instance containing the miners data.
""" """
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
)
board_offset = -1 board_offset = -1
fan_offset = -1 fan_offset = -1
@@ -67,7 +70,7 @@ class HiveonT9(Hiveon, T9):
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", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -97,14 +100,17 @@ class HiveonT9(Hiveon, T9):
) )
board_map = { board_map = {
"left": [2, 9, 10], 0: [2, 9, 10],
"center": [3, 11, 12], 1: [3, 11, 12],
"right": [4, 13, 14], 2: [4, 13, 14],
} }
env_temp_list = [] env_temp_list = []
for board in board_map.keys(): for board in board_map.keys():
hashboard = HashBoard(
slot=board, expected_chips=self.nominal_chips
)
chips = 0 chips = 0
hashrate = 0 hashrate = 0
chip_temp = 0 chip_temp = 0
@@ -121,10 +127,15 @@ class HiveonT9(Hiveon, T9):
hashrate += boards[1][f"chain_rate{chipset}"] hashrate += boards[1][f"chain_rate{chipset}"]
chips += boards[1][f"chain_acn{chipset}"] chips += boards[1][f"chain_acn{chipset}"]
setattr(data, f"{board}_chips", chips) hashboard.hashrate = hashrate
setattr(data, f"{board}_board_hashrate", hashrate) hashboard.chips = chips
setattr(data, f"{board}_board_temp", board_temp) hashboard.temp = board_temp
setattr(data, f"{board}_board_chip_temp", chip_temp) hashboard.chip_temp = chip_temp
hashboard.missing = True
if chips and chips > 0:
hashboard.missing = False
data.hashboards.append(hashboard)
if not env_temp_list == []: if not env_temp_list == []:
data.env_temp = sum(env_temp_list) / len(env_temp_list) data.env_temp = sum(env_temp_list) / len(env_temp_list)

View File

@@ -12,9 +12,10 @@
# 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 .A10X import CGMinerA10X
from pyasic.miners._types import Avalon1026 # noqa - Ignore access to _module from pyasic.miners._types import Avalon1026 # noqa - Ignore access to _module
from .A10X import CGMinerA10X
class CGMinerAvalon1026(CGMinerA10X, Avalon1026): class CGMinerAvalon1026(CGMinerA10X, Avalon1026):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .A10X import CGMinerA10X
from pyasic.miners._types import Avalon1047 # noqa - Ignore access to _module from pyasic.miners._types import Avalon1047 # noqa - Ignore access to _module
from .A10X import CGMinerA10X
class CGMinerAvalon1047(CGMinerA10X, Avalon1047): class CGMinerAvalon1047(CGMinerA10X, Avalon1047):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .A10X import CGMinerA10X
from pyasic.miners._types import Avalon1066 # noqa - Ignore access to _module from pyasic.miners._types import Avalon1066 # noqa - Ignore access to _module
from .A10X import CGMinerA10X
class CGMinerAvalon1066(CGMinerA10X, Avalon1066): class CGMinerAvalon1066(CGMinerA10X, Avalon1066):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,13 +12,13 @@
# 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.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.data import MinerData
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerA10X(CGMiner): class CGMinerA10X(CGMiner):
@@ -80,8 +80,16 @@ class CGMinerA10X(CGMiner):
) )
return mac return mac
async def get_data(self): async def get_data(self, allow_warning: bool = True):
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips)
for i in range(self.ideal_hashboards)
],
)
model = await self.get_model() model = await self.get_model()
mac = None mac = None
@@ -92,7 +100,7 @@ class CGMinerA10X(CGMiner):
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(
"version", "summary", "pools", "stats" "version", "summary", "pools", "stats", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -145,27 +153,20 @@ class CGMinerA10X(CGMiner):
f"fan_{fan+1}", f"fan_{fan+1}",
int(raw_data[f"Fan{fan+1}"]), int(raw_data[f"Fan{fan+1}"]),
) )
if "MTmax" in raw_data.keys(): for board in range(self.ideal_hashboards):
data.left_board_chip_temp = int(raw_data["MTmax"][0]) chip_temp = raw_data.get("MTmax")
data.center_board_chip_temp = int(raw_data["MTmax"][1]) if chip_temp:
data.right_board_chip_temp = int(raw_data["MTmax"][2]) data.hashboards[board].chip_temp = chip_temp[board]
if "MTavg" in raw_data.keys():
data.left_board_temp = int(raw_data["MTavg"][0])
data.center_board_temp = int(raw_data["MTavg"][1])
data.right_board_temp = int(raw_data["MTavg"][2])
if "PVT_T0" in raw_data: temp = raw_data.get("MTavg")
data.left_chips = len( if temp:
[item for item in raw_data["PVT_T0"] if not item == "0"] data.hashboards[board].temp = temp[board]
)
if "PVT_T1" in raw_data: chips = raw_data.get(f"PVT_T{board}")
data.center_chips = len( if chips:
[item for item in raw_data["PVT_T1"] if not item == "0"] data.hashboards[board].chips = len(
) [item for item in chips if not item == "0"]
if "PVT_T2" in raw_data: )
data.right_chips = len(
[item for item in raw_data["PVT_T2"] if not item == "0"]
)
if pools: if pools:
pool_1 = None pool_1 = None

View File

@@ -12,9 +12,10 @@
# 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 .A7X import CGMinerA7X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon721 # noqa - Ignore access to _module from pyasic.miners._types import Avalon721 # noqa - Ignore access to _module
from .A7X import CGMinerA7X # noqa - Ignore access to _module
class CGMinerAvalon721(CGMinerA7X, Avalon721): class CGMinerAvalon721(CGMinerA7X, Avalon721):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .A7X import CGMinerA7X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon741 # noqa - Ignore access to _module from pyasic.miners._types import Avalon741 # noqa - Ignore access to _module
from .A7X import CGMinerA7X # noqa - Ignore access to _module
class CGMinerAvalon741(CGMinerA7X, Avalon741): class CGMinerAvalon741(CGMinerA7X, Avalon741):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .A7X import CGMinerA7X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon761 # noqa - Ignore access to _module from pyasic.miners._types import Avalon761 # noqa - Ignore access to _module
from .A7X import CGMinerA7X # noqa - Ignore access to _module
class CGMinerAvalon761(CGMinerA7X, Avalon761): class CGMinerAvalon761(CGMinerA7X, Avalon761):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,13 +12,13 @@
# 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.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.data import MinerData
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerA7X(CGMiner): class CGMinerA7X(CGMiner):
@@ -80,8 +80,16 @@ class CGMinerA7X(CGMiner):
) )
return mac return mac
async def get_data(self): async def get_data(self, allow_warning: bool = True):
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips)
for i in range(self.ideal_hashboards)
],
)
model = await self.get_model() model = await self.get_model()
mac = None mac = None
@@ -92,7 +100,7 @@ class CGMinerA7X(CGMiner):
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(
"version", "summary", "pools", "stats" "version", "summary", "pools", "stats", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -145,27 +153,20 @@ class CGMinerA7X(CGMiner):
f"fan_{fan+1}", f"fan_{fan+1}",
int(raw_data[f"Fan{fan+1}"]), int(raw_data[f"Fan{fan+1}"]),
) )
if "MTmax" in raw_data.keys(): for board in range(self.ideal_hashboards):
data.left_board_chip_temp = int(raw_data["MTmax"][0]) chip_temp = raw_data.get("MTmax")
data.center_board_chip_temp = int(raw_data["MTmax"][1]) if chip_temp:
data.right_board_chip_temp = int(raw_data["MTmax"][2]) data.hashboards[board].chip_temp = chip_temp[board]
if "MTavg" in raw_data.keys():
data.left_board_temp = int(raw_data["MTavg"][0])
data.center_board_temp = int(raw_data["MTavg"][1])
data.right_board_temp = int(raw_data["MTavg"][2])
if "PVT_T0" in raw_data: temp = raw_data.get("MTavg")
data.left_chips = len( if temp:
[item for item in raw_data["PVT_T0"] if not item == "0"] data.hashboards[board].temp = temp[board]
)
if "PVT_T1" in raw_data: chips = raw_data.get(f"PVT_T{board}")
data.center_chips = len( if chips:
[item for item in raw_data["PVT_T1"] if not item == "0"] data.hashboards[board].chips = len(
) [item for item in chips if not item == "0"]
if "PVT_T2" in raw_data: )
data.right_chips = len(
[item for item in raw_data["PVT_T2"] if not item == "0"]
)
if pools: if pools:
pool_1 = None pool_1 = None

View File

@@ -12,9 +12,10 @@
# 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 .A8X import CGMinerA8X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon821 # noqa - Ignore access to _module from pyasic.miners._types import Avalon821 # noqa - Ignore access to _module
from .A8X import CGMinerA8X # noqa - Ignore access to _module
class CGMinerAvalon821(CGMinerA8X, Avalon821): class CGMinerAvalon821(CGMinerA8X, Avalon821):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .A8X import CGMinerA8X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon841 # noqa - Ignore access to _module from pyasic.miners._types import Avalon841 # noqa - Ignore access to _module
from .A8X import CGMinerA8X # noqa - Ignore access to _module
class CGMinerAvalon841(CGMinerA8X, Avalon841): class CGMinerAvalon841(CGMinerA8X, Avalon841):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,9 +12,10 @@
# 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 .A8X import CGMinerA8X # noqa - Ignore access to _module
from pyasic.miners._types import Avalon851 # noqa - Ignore access to _module from pyasic.miners._types import Avalon851 # noqa - Ignore access to _module
from .A8X import CGMinerA8X # noqa - Ignore access to _module
class CGMinerAvalon851(CGMinerA8X, Avalon851): class CGMinerAvalon851(CGMinerA8X, Avalon851):
def __init__(self, ip: str) -> None: def __init__(self, ip: str) -> None:

View File

@@ -12,13 +12,13 @@
# 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.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.data import MinerData
from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerA8X(CGMiner): class CGMinerA8X(CGMiner):
@@ -80,8 +80,16 @@ class CGMinerA8X(CGMiner):
) )
return mac return mac
async def get_data(self): async def get_data(self, allow_warning: bool = True):
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips)
for i in range(self.ideal_hashboards)
],
)
model = await self.get_model() model = await self.get_model()
mac = None mac = None
@@ -92,7 +100,7 @@ class CGMinerA8X(CGMiner):
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(
"version", "summary", "pools", "stats" "version", "summary", "pools", "stats", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -145,27 +153,20 @@ class CGMinerA8X(CGMiner):
f"fan_{fan+1}", f"fan_{fan+1}",
int(raw_data[f"Fan{fan+1}"]), int(raw_data[f"Fan{fan+1}"]),
) )
if "MTmax" in raw_data.keys(): for board in range(self.ideal_hashboards):
data.left_board_chip_temp = int(raw_data["MTmax"][0]) chip_temp = raw_data.get("MTmax")
data.center_board_chip_temp = int(raw_data["MTmax"][1]) if chip_temp:
data.right_board_chip_temp = int(raw_data["MTmax"][2]) data.hashboards[board].chip_temp = chip_temp[board]
if "MTavg" in raw_data.keys():
data.left_board_temp = int(raw_data["MTavg"][0])
data.center_board_temp = int(raw_data["MTavg"][1])
data.right_board_temp = int(raw_data["MTavg"][2])
if "PVT_T0" in raw_data: temp = raw_data.get("MTavg")
data.left_chips = len( if temp:
[item for item in raw_data["PVT_T0"] if not item == "0"] data.hashboards[board].temp = temp[board]
)
if "PVT_T1" in raw_data: chips = raw_data.get(f"PVT_T{board}")
data.center_chips = len( if chips:
[item for item in raw_data["PVT_T1"] if not item == "0"] data.hashboards[board].chips = len(
) [item for item in chips if not item == "0"]
if "PVT_T2" in raw_data: )
data.right_chips = len(
[item for item in raw_data["PVT_T2"] if not item == "0"]
)
if pools: if pools:
pool_1 = None pool_1 = None

View File

@@ -12,14 +12,14 @@
# 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.
import logging
import re
from pyasic.config import MinerConfig
from pyasic.data import HashBoard, MinerData
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.miners._types import Avalon921 # noqa - Ignore access to _module from pyasic.miners._types import Avalon921 # noqa - Ignore access to _module
from pyasic.data import MinerData
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings
import re
from pyasic.config import MinerConfig
import logging
class CGMinerAvalon921(CGMiner, Avalon921): class CGMinerAvalon921(CGMiner, Avalon921):
@@ -81,8 +81,16 @@ class CGMinerAvalon921(CGMiner, Avalon921):
) )
return mac return mac
async def get_data(self): async def get_data(self, allow_warning: bool = True):
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips)
for i in range(self.ideal_hashboards)
],
)
model = await self.get_model() model = await self.get_model()
mac = None mac = None
@@ -95,7 +103,7 @@ class CGMinerAvalon921(CGMiner, Avalon921):
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(
"version", "summary", "pools", "stats" "version", "summary", "pools", "stats", allow_warning=allow_warning
) )
if miner_data: if miner_data:
break break
@@ -146,27 +154,20 @@ class CGMinerAvalon921(CGMiner, Avalon921):
f"fan_{fan+1}", f"fan_{fan+1}",
int(raw_data[f"Fan{fan+1}"]), int(raw_data[f"Fan{fan+1}"]),
) )
if "MTmax" in raw_data.keys(): for board in range(self.ideal_hashboards):
data.left_board_chip_temp = int(raw_data["MTmax"][0]) chip_temp = raw_data.get("MTmax")
data.center_board_chip_temp = int(raw_data["MTmax"][1]) if chip_temp:
data.right_board_chip_temp = int(raw_data["MTmax"][2]) data.hashboards[board].chip_temp = chip_temp[board]
if "MTavg" in raw_data.keys():
data.left_board_temp = int(raw_data["MTavg"][0])
data.center_board_temp = int(raw_data["MTavg"][1])
data.right_board_temp = int(raw_data["MTavg"][2])
if "PVT_T0" in raw_data: temp = raw_data.get("MTavg")
data.left_chips = len( if temp:
[item for item in raw_data["PVT_T0"] if not item == "0"] data.hashboards[board].temp = temp[board]
)
if "PVT_T1" in raw_data: chips = raw_data.get(f"PVT_T{board}")
data.center_chips = len( if chips:
[item for item in raw_data["PVT_T1"] if not item == "0"] data.hashboards[board].chips = len(
) [item for item in chips if not item == "0"]
if "PVT_T2" in raw_data: )
data.right_chips = len(
[item for item in raw_data["PVT_T2"] if not item == "0"]
)
if pools: if pools:
pool_1 = None pool_1 = None

View File

@@ -12,20 +12,21 @@
# 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.
import asyncssh
import logging
import ipaddress import ipaddress
import logging
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import TypeVar, List, Union from typing import List, TypeVar, Union
import asyncssh
from pyasic.data import MinerData
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import MinerData
from pyasic.data.error_codes import ( from pyasic.data.error_codes import (
WhatsminerError,
BraiinsOSError, BraiinsOSError,
InnosiliconError, InnosiliconError,
X19Error,
MinerErrorData, MinerErrorData,
WhatsminerError,
X19Error,
) )
@@ -43,6 +44,7 @@ class BaseMiner(ABC):
self.version = None self.version = None
self.fan_count = 2 self.fan_count = 2
self.config = None self.config = None
self.ideal_hashboards = 3
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
if cls is BaseMiner: if cls is BaseMiner:
@@ -191,7 +193,7 @@ class BaseMiner(ABC):
pass pass
@abstractmethod @abstractmethod
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = True) -> MinerData:
"""Get data from the miner in the form of [`MinerData`][pyasic.data.MinerData]. """Get data from the miner in the form of [`MinerData`][pyasic.data.MinerData].
Returns: Returns:

View File

@@ -12,18 +12,19 @@
# 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.miners._backends import CGMiner # noqa - Ignore access to _module import logging
from pyasic.miners._types import InnosiliconT3HPlus # noqa - Ignore access to _module import warnings
from pyasic.data import MinerData from typing import List, Union
from pyasic.data.error_codes import InnosiliconError, MinerErrorData
from pyasic.settings import PyasicSettings
from pyasic.config import MinerConfig
from pyasic.errors import APIError
import httpx import httpx
import warnings
from typing import Union, List from pyasic.config import MinerConfig
import logging from pyasic.data import HashBoard, MinerData
from pyasic.data.error_codes import InnosiliconError, MinerErrorData
from pyasic.errors import APIError
from pyasic.miners._backends import CGMiner # noqa - Ignore access to _module
from pyasic.miners._types import InnosiliconT3HPlus # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus): class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
@@ -157,8 +158,16 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
errors.append(InnosiliconError(error_code=err)) errors.append(InnosiliconError(error_code=err))
return errors return errors
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = False) -> MinerData:
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3) data = MinerData(
ip=str(self.ip),
ideal_chips=self.nominal_chips * self.ideal_hashboards,
ideal_hashboards=self.ideal_hashboards,
hashboards=[
HashBoard(slot=i, expected_chips=self.nominal_chips)
for i in range(self.ideal_hashboards)
],
)
board_offset = -1 board_offset = -1
fan_offset = -1 fan_offset = -1
@@ -179,7 +188,7 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
all_data = None all_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", allow_warning=allow_warning
) )
if miner_data: if miner_data:
@@ -215,32 +224,31 @@ class CGMinerInnosiliconT3HPlus(CGMiner, InnosiliconT3HPlus):
if stats: if stats:
stats = stats[0] stats = stats[0]
if stats.get("STATS"): if stats.get("STATS"):
board_map = {0: "left", 1: "center", 2: "right"}
for idx, board in enumerate(stats["STATS"]): for idx, board in enumerate(stats["STATS"]):
data.hashboards[idx].missing = True
chips = board.get("Num active chips") chips = board.get("Num active chips")
if chips: if chips:
setattr(data, f"{board_map[idx]}_chips", chips) data.hashboards[idx].chips = chips
temp = board.get("Temp") if chips > 0:
if temp: data.hashboards[idx].missing = False
setattr(data, f"{board_map[idx]}_board_chip_temp", temp)
if all_data: if all_data:
if all_data.get("chain"): if all_data.get("chain"):
board_map = {0: "left", 1: "center", 2: "right"}
for idx, board in enumerate(all_data["chain"]): for idx, board in enumerate(all_data["chain"]):
temp = board.get("Temp max") temp = board.get("Temp min")
if temp: if temp:
setattr(data, f"{board_map[idx]}_board_chip_temp", temp) data.hashboards[idx].temp = round(temp)
temp_board = board.get("Temp min")
if temp_board: hashrate = board.get("Hash Rate H")
setattr(data, f"{board_map[idx]}_board_temp", temp_board) if hashrate:
hr = board.get("Hash Rate H") data.hashboards[idx].hashrate = round(
if hr: hashrate / 1000000000000, 2
setattr(
data,
f"{board_map[idx]}_board_hashrate",
round(hr / 1000000000000, 2),
) )
chip_temp = board.get("Temp max")
if chip_temp:
data.hashboards[idx].chip_temp = round(chip_temp)
if all_data.get("fansSpeed"): if all_data.get("fansSpeed"):
speed = round((all_data["fansSpeed"] * 6000) / 100) speed = round((all_data["fansSpeed"] * 6000) / 100)
for fan in range(self.fan_count): for fan in range(self.fan_count):

View File

@@ -12,38 +12,32 @@
# 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 typing import Tuple, List, Union
from collections.abc import AsyncIterable
from pyasic.miners.base import AnyMiner
import httpx
from pyasic.miners.antminer import *
from pyasic.miners.avalonminer import *
from pyasic.miners.whatsminer import *
from pyasic.miners.innosilicon import *
from pyasic.miners._backends.cgminer import CGMiner # noqa - Ignore _module import
from pyasic.miners._backends.bmminer import BMMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer import BOSMiner # noqa - Ignore _module import
from pyasic.miners._backends.btminer import BTMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer_old import ( # noqa - Ignore _module import
BOSMinerOld,
)
from pyasic.miners.unknown import UnknownMiner
from pyasic.errors import APIError
from pyasic.misc import Singleton
import asyncio import asyncio
import ipaddress import ipaddress
import json import json
import logging import logging
from collections.abc import AsyncIterable
from pyasic.settings import PyasicSettings from typing import List, Tuple, Union
import asyncssh import asyncssh
import httpx
from pyasic.errors import APIError
from pyasic.miners._backends.bmminer import BMMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer import BOSMiner # noqa - Ignore _module import
from pyasic.miners._backends.bosminer_old import ( # noqa - Ignore _module import
BOSMinerOld,
)
from pyasic.miners._backends.btminer import BTMiner # noqa - Ignore _module import
from pyasic.miners._backends.cgminer import CGMiner # noqa - Ignore _module import
from pyasic.miners.antminer import *
from pyasic.miners.avalonminer import *
from pyasic.miners.base import AnyMiner
from pyasic.miners.innosilicon import *
from pyasic.miners.unknown import UnknownMiner
from pyasic.miners.whatsminer import *
from pyasic.misc import Singleton
from pyasic.settings import PyasicSettings
MINER_CLASSES = { MINER_CLASSES = {
"ANTMINER S9": { "ANTMINER S9": {
@@ -216,6 +210,11 @@ MINER_CLASSES = {
"BTMiner": BTMinerM32, "BTMiner": BTMinerM32,
"20": BTMinerM32V20, "20": BTMinerM32V20,
}, },
"M34S+": {
"Default": BTMinerM34SPlus,
"BTMiner": BTMinerM34SPlus,
"E10": BTMinerM34SPlusVE10,
},
"M50": { "M50": {
"Default": BTMinerM50, "Default": BTMinerM50,
"BTMiner": BTMinerM50, "BTMiner": BTMinerM50,
@@ -434,6 +433,12 @@ class MinerFactory(metaclass=Singleton):
# if we have devdetails, we can get model data from there # if we have devdetails, we can get model data from there
if devdetails: if devdetails:
if devdetails == {"Msg": "Disconnected"}:
model = await self.__get_model_from_graphql(ip)
if model:
api = "BOSMiner+"
return model, api, ver
for _devdetails_key in ["Model", "Driver"]: for _devdetails_key in ["Model", "Driver"]:
try: try:
model = devdetails["DEVDETAILS"][0][_devdetails_key].upper() model = devdetails["DEVDETAILS"][0][_devdetails_key].upper()
@@ -541,6 +546,11 @@ class MinerFactory(metaclass=Singleton):
# validate success # validate success
validation = await self._validate_command(data) validation = await self._validate_command(data)
if not validation[0]: if not validation[0]:
try:
if data["version"][0]["STATUS"][0]["Msg"] == "Disconnected":
return {"Msg": "Disconnected"}, None
except KeyError:
pass
raise APIError(validation[1]) raise APIError(validation[1])
# copy each part of the main command to devdetails and version # copy each part of the main command to devdetails and version
devdetails = data["devdetails"][0] devdetails = data["devdetails"][0]
@@ -588,6 +598,16 @@ class MinerFactory(metaclass=Singleton):
model = "ANTMINER S17" model = "ANTMINER S17"
return model return model
@staticmethod
async def __get_model_from_graphql(ip: ipaddress.ip_address) -> Union[str, None]:
model = None
url = f"http://{ip}/graphql"
async with httpx.AsyncClient() as client:
d = await client.post(url, json={"query": "{bosminer {info{modelName}}}"})
if d.status_code == 200:
model = d.json()["data"]["bosminer"]["info"]["modelName"].upper()
return model
@staticmethod @staticmethod
async def __get_system_info_from_web(ip) -> dict: async def __get_system_info_from_web(ip) -> dict:
url = f"http://{ip}/cgi-bin/get_system_info.cgi" url = f"http://{ip}/cgi-bin/get_system_info.cgi"

View File

@@ -15,10 +15,10 @@
from typing import List from typing import List
from pyasic.API.unknown import UnknownAPI from pyasic.API.unknown import UnknownAPI
from pyasic.miners.base import BaseMiner
from pyasic.config import MinerConfig from pyasic.config import MinerConfig
from pyasic.data import MinerData from pyasic.data import MinerData
from pyasic.data.error_codes import MinerErrorData from pyasic.data.error_codes import MinerErrorData
from pyasic.miners.base import BaseMiner
class UnknownMiner(BaseMiner): class UnknownMiner(BaseMiner):
@@ -72,5 +72,5 @@ class UnknownMiner(BaseMiner):
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
return None return None
async def get_data(self) -> MinerData: async def get_data(self, allow_warning: bool = False) -> MinerData:
return MinerData(ip=str(self.ip)) return MinerData(ip=str(self.ip))

View File

@@ -13,10 +13,7 @@
# limitations under the License. # limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( # noqa - Ignore access to _module from pyasic.miners._types import M20, M20V10 # noqa - Ignore access to _module
M20,
M20V10,
)
class BTMinerM20(BTMiner, M20): class BTMinerM20(BTMiner, M20):

View File

@@ -13,11 +13,11 @@
# limitations under the License. # limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( from pyasic.miners._types import ( # noqa - Ignore access to _module
M21S, M21S,
M21SV20, M21SV20,
M21SV60, M21SV60,
) # noqa - Ignore access to _module )
class BTMinerM21S(BTMiner, M21S): class BTMinerM21S(BTMiner, M21S):

View File

@@ -15,7 +15,6 @@
from .M20 import BTMinerM20, BTMinerM20V10 from .M20 import BTMinerM20, BTMinerM20V10
from .M20S import BTMinerM20S, BTMinerM20SV10, BTMinerM20SV20 from .M20S import BTMinerM20S, BTMinerM20SV10, BTMinerM20SV20
from .M20S_Plus import BTMinerM20SPlus from .M20S_Plus import BTMinerM20SPlus
from .M21 import BTMinerM21 from .M21 import BTMinerM21
from .M21S import BTMinerM21S, BTMinerM21SV20, BTMinerM21SV60 from .M21S import BTMinerM21S, BTMinerM21SV20, BTMinerM21SV60
from .M21S_Plus import BTMinerM21SPlus from .M21S_Plus import BTMinerM21SPlus

View File

@@ -13,13 +13,13 @@
# limitations under the License. # limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( from pyasic.miners._types import ( # noqa - Ignore access to _module
M30S, M30S,
M30SV50, M30SV50,
M30SVG20,
M30SVE20,
M30SVE10, M30SVE10,
) # noqa - Ignore access to _module M30SVE20,
M30SVG20,
)
class BTMinerM30S(BTMiner, M30S): class BTMinerM30S(BTMiner, M30S):

View File

@@ -13,12 +13,12 @@
# limitations under the License. # limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( from pyasic.miners._types import ( # noqa - Ignore access to _module
M30SPlus, M30SPlus,
M30SPlusVE40, M30SPlusVE40,
M30SPlusVF20, M30SPlusVF20,
M30SPlusVG60, M30SPlusVG60,
) # noqa - Ignore access to _module )
class BTMinerM30SPlus(BTMiner, M30SPlus): class BTMinerM30SPlus(BTMiner, M30SPlus):

View File

@@ -15,8 +15,8 @@
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( # noqa - Ignore access to _module from pyasic.miners._types import ( # noqa - Ignore access to _module
M30SPlusPlus, M30SPlusPlus,
M30SPlusPlusVG40,
M30SPlusPlusVG30, M30SPlusPlusVG30,
M30SPlusPlusVG40,
M30SPlusPlusVH60, M30SPlusPlusVH60,
) )

View File

@@ -13,15 +13,15 @@
# limitations under the License. # limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( from pyasic.miners._types import ( # noqa - Ignore access to _module
M31SPlus, M31SPlus,
M31SPlusVE20,
M31SPlusV30, M31SPlusV30,
M31SPlusV40, M31SPlusV40,
M31SPlusV60, M31SPlusV60,
M31SPlusV80, M31SPlusV80,
M31SPlusV90, M31SPlusV90,
) # noqa - Ignore access to _module M31SPlusVE20,
)
class BTMinerM31SPlus(BTMiner, M31SPlus): class BTMinerM31SPlus(BTMiner, M31SPlus):

View File

@@ -13,9 +13,7 @@
# limitations under the License. # limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( from pyasic.miners._types import M32S # noqa - Ignore access to _module
M32S,
) # noqa - Ignore access to _module
class BTMinerM32S(BTMiner, M32S): class BTMinerM32S(BTMiner, M32S):

View File

@@ -0,0 +1,31 @@
# Copyright 2022 Upstream Data Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import ( # noqa - Ignore access to _module
M34SPlus,
M34SPlusVE10,
)
class BTMinerM34SPlus(BTMiner, M34SPlus):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.ip = ip
class BTMinerM34SPlusVE10(BTMiner, M34SPlusVE10):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.ip = ip

View File

@@ -14,34 +14,33 @@
from .M30S import ( from .M30S import (
BTMinerM30S, BTMinerM30S,
BTMinerM30SV50,
BTMinerM30SVE10, BTMinerM30SVE10,
BTMinerM30SVE20, BTMinerM30SVE20,
BTMinerM30SVG20, BTMinerM30SVG20,
BTMinerM30SV50,
) )
from .M30S_Plus import ( from .M30S_Plus import (
BTMinerM30SPlus, BTMinerM30SPlus,
BTMinerM30SPlusVF20,
BTMinerM30SPlusVE40, BTMinerM30SPlusVE40,
BTMinerM30SPlusVF20,
BTMinerM30SPlusVG60, BTMinerM30SPlusVG60,
) )
from .M30S_Plus_Plus import ( from .M30S_Plus_Plus import (
BTMinerM30SPlusPlus, BTMinerM30SPlusPlus,
BTMinerM30SPlusPlusVG40,
BTMinerM30SPlusPlusVG30, BTMinerM30SPlusPlusVG30,
BTMinerM30SPlusPlusVG40,
BTMinerM30SPlusPlusVH60, BTMinerM30SPlusPlusVH60,
) )
from .M31S import BTMinerM31S from .M31S import BTMinerM31S
from .M31S_Plus import ( from .M31S_Plus import (
BTMinerM31SPlus, BTMinerM31SPlus,
BTMinerM31SPlusVE20,
BTMinerM31SPlusV30, BTMinerM31SPlusV30,
BTMinerM31SPlusV40, BTMinerM31SPlusV40,
BTMinerM31SPlusV60, BTMinerM31SPlusV60,
BTMinerM31SPlusV80, BTMinerM31SPlusV80,
BTMinerM31SPlusV90, BTMinerM31SPlusV90,
BTMinerM31SPlusVE20,
) )
from .M32 import BTMinerM32, BTMinerM32V20 from .M32 import BTMinerM32, BTMinerM32V20
from .M32S import BTMinerM32S from .M32S import BTMinerM32S
from .M34S_Plus import BTMinerM34SPlus, BTMinerM34SPlusVE10

View File

@@ -12,7 +12,4 @@
# 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 .M50 import ( from .M50 import BTMinerM50, BTMinerM50VH50
BTMinerM50,
BTMinerM50VH50,
)

View File

@@ -14,4 +14,4 @@
from .M2X import * from .M2X import *
from .M3X import * from .M3X import *
from .M5X import * from .M5X import *

View File

@@ -12,13 +12,13 @@
# 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.
import ipaddress
import asyncio import asyncio
import ipaddress
import logging import logging
from typing import Union, List, AsyncIterator from typing import AsyncIterator, List, Union
from pyasic.miners.miner_factory import AnyMiner, MinerFactory
from pyasic.network.net_range import MinerNetworkRange from pyasic.network.net_range import MinerNetworkRange
from pyasic.miners.miner_factory import MinerFactory, AnyMiner
from pyasic.settings import PyasicSettings from pyasic.settings import PyasicSettings

View File

@@ -12,8 +12,8 @@
# 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 typing import Union
import ipaddress import ipaddress
from typing import Union
class MinerNetworkRange: class MinerNetworkRange:

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "pyasic" name = "pyasic"
version = "0.19.1" version = "0.21.3"
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH." description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
authors = ["UpstreamData <brett@upstreamdata.ca>"] authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic" repository = "https://github.com/UpstreamData/pyasic"
@@ -20,6 +20,7 @@ optional = true
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
pre-commit = "^2.20.0" pre-commit = "^2.20.0"
isort = "^5.10.1"
[tool.poetry.group.docs] [tool.poetry.group.docs]
optional = true optional = true
@@ -32,3 +33,6 @@ mkdocstrings = {extras = ["python"], version = "^0.19.0"}
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
[tool.isort]
profile = "black"

View File

@@ -13,9 +13,10 @@
# limitations under the License. # limitations under the License.
import unittest import unittest
from tests.miners_tests import MinersTest, MinerFactoryTest
from tests.network_tests import NetworkTest
from tests.config_tests import ConfigTest from tests.config_tests import ConfigTest
from tests.miners_tests import MinerFactoryTest, MinersTest
from tests.network_tests import NetworkTest
if __name__ == "__main__": if __name__ == "__main__":
# `coverage run --source pyasic -m unittest discover` will give code coverage data # `coverage run --source pyasic -m unittest discover` will give code coverage data

View File

@@ -13,14 +13,15 @@
# limitations under the License. # limitations under the License.
import unittest import unittest
from pyasic.config import MinerConfig, _PoolGroup, _Pool # noqa
from tests.test_data import ( from tests.test_data import (
bosminer_api_pools, bosminer_api_pools,
bosminer_config_pools,
x19_api_pools, x19_api_pools,
x19_web_pools, x19_web_pools,
bosminer_config_pools,
) )
from pyasic.config import MinerConfig, _Pool, _PoolGroup # noqa
class ConfigTest(unittest.TestCase): class ConfigTest(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:

View File

@@ -11,18 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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.
import unittest
from pyasic.miners.miner_factory import MINER_CLASSES
from pyasic.miners.base import BaseMiner
from pyasic.miners._backends import CGMiner
from pyasic.miners.miner_factory import MinerFactory
from pyasic.miners.miner_listener import MinerListener
import asyncio import asyncio
import inspect import inspect
import sys import sys
import unittest
from pyasic.miners._backends import CGMiner
from pyasic.miners.base import BaseMiner
from pyasic.miners.miner_factory import MINER_CLASSES, MinerFactory
from pyasic.miners.miner_listener import MinerListener
class MinersTest(unittest.TestCase): class MinersTest(unittest.TestCase):

View File

@@ -15,8 +15,8 @@
import ipaddress import ipaddress
import unittest import unittest
from pyasic.network.net_range import MinerNetworkRange
from pyasic.network import MinerNetwork from pyasic.network import MinerNetwork
from pyasic.network.net_range import MinerNetworkRange
class NetworkTest(unittest.TestCase): class NetworkTest(unittest.TestCase):