Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
996ab58252 | ||
|
|
04974d5287 |
@@ -173,9 +173,14 @@ If you are sure you want to use this command please use API.send_command("{comma
|
|||||||
writer.write(data)
|
writer.write(data)
|
||||||
logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining")
|
logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
ret_data = await asyncio.wait_for(reader.read(4096), timeout=timeout)
|
||||||
# instantiate data
|
try:
|
||||||
ret_data = b""
|
# Fix for stupid whatsminer bug, reboot/restart seem to not load properly in the loop
|
||||||
|
# have to receive, save the data, check if there is more data by reading with a short timeout
|
||||||
|
# append that data if there is more, and then onto the main loop.
|
||||||
|
ret_data += await asyncio.wait_for(reader.read(1), timeout=1)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
return ret_data
|
||||||
|
|
||||||
# loop to receive all the data
|
# loop to receive all the data
|
||||||
logging.debug(f"{self} - ([Hidden] Send Bytes) - Receiving")
|
logging.debug(f"{self} - ([Hidden] Send Bytes) - Receiving")
|
||||||
@@ -185,6 +190,7 @@ If you are sure you want to use this command please use API.send_command("{comma
|
|||||||
d = await asyncio.wait_for(reader.read(4096), timeout=timeout)
|
d = await asyncio.wait_for(reader.read(4096), timeout=timeout)
|
||||||
if not d:
|
if not d:
|
||||||
break
|
break
|
||||||
|
print("hello", d)
|
||||||
ret_data += d
|
ret_data += d
|
||||||
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
||||||
raise e
|
raise e
|
||||||
@@ -244,6 +250,8 @@ If you are sure you want to use this command please use API.send_command("{comma
|
|||||||
str_data = str_data.replace("}{", "},{")
|
str_data = str_data.replace("}{", "},{")
|
||||||
# fix an error with a bmminer return having a specific comma that breaks json.loads()
|
# fix an error with a bmminer return having a specific comma that breaks json.loads()
|
||||||
str_data = str_data.replace("[,{", "[{")
|
str_data = str_data.replace("[,{", "[{")
|
||||||
|
# fix an error with a btminer return having a missing comma. (2023-01-06 version)
|
||||||
|
str_data = str_data.replace('""temp0', '","temp0')
|
||||||
# fix an error with Avalonminers returning inf and nan
|
# fix an error with Avalonminers returning inf and nan
|
||||||
str_data = str_data.replace("info", "1nfo")
|
str_data = str_data.replace("info", "1nfo")
|
||||||
str_data = str_data.replace("inf", "0")
|
str_data = str_data.replace("inf", "0")
|
||||||
|
|||||||
@@ -247,21 +247,9 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
try:
|
try:
|
||||||
data = await self._send_bytes(enc_command, timeout)
|
data = await self._send_bytes(enc_command, timeout)
|
||||||
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
except (asyncio.CancelledError, asyncio.TimeoutError) as e:
|
||||||
if command["cmd"] in ["reboot", "restart_btminer", "power_on", "power_off"]:
|
if ignore_errors:
|
||||||
logging.info(
|
return {}
|
||||||
f"{self} - (reboot/restart_btminer/power_on/power_off) - Whatsminers currently break this. "
|
raise APIError("No data was returned from the API.")
|
||||||
f"Ignoring exception. Command probably worked."
|
|
||||||
)
|
|
||||||
# FAKING IT HERE
|
|
||||||
data = (
|
|
||||||
b'{"STATUS": "S", "When": 1670966423, "Code": 131, "Msg": "API command OK", "Description": "'
|
|
||||||
+ command["cmd"].encode("utf-8")
|
|
||||||
+ b'"}'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if ignore_errors:
|
|
||||||
return {}
|
|
||||||
raise APIError("No data was returned from the API.")
|
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
if ignore_errors:
|
if ignore_errors:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pyasic"
|
name = "pyasic"
|
||||||
version = "0.28.2"
|
version = "0.28.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"
|
||||||
|
|||||||
Reference in New Issue
Block a user