Address unknown password issue on Whatsminers
When a whatsminer had an unknown password (not the default one), it would result in a timeout error. By moving the password check to before the data pull step, the timeout issue can be caught and addressed efficiently.
This commit is contained in:
@@ -207,16 +207,18 @@ If you are sure you want to use this command please use API.send_command("{comma
|
|||||||
logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining")
|
logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining")
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
try:
|
try:
|
||||||
ret_data = await asyncio.wait_for(reader.read(4096), timeout=timeout)
|
# TO address a situation where a whatsminer has an unknown PW -AND-
|
||||||
except ConnectionAbortedError:
|
|
||||||
return b"{}"
|
|
||||||
try:
|
|
||||||
# Fix for stupid whatsminer bug, reboot/restart seem to not load properly in the loop
|
# 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
|
# 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.
|
# append that data if there is more, and then onto the main loop.
|
||||||
ret_data += await asyncio.wait_for(reader.read(1), timeout=1)
|
# the password timeout might need to be longer than 1, but it seems to work for now.
|
||||||
except asyncio.TimeoutError:
|
ret_data = await asyncio.wait_for(reader.read(1), timeout=1)
|
||||||
return ret_data
|
except (asyncio.TimeoutError):
|
||||||
|
return b"{}"
|
||||||
|
try:
|
||||||
|
ret_data += await asyncio.wait_for(reader.read(4096), timeout=timeout)
|
||||||
|
except (ConnectionAbortedError):
|
||||||
|
return b"{}"
|
||||||
|
|
||||||
# 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")
|
||||||
|
|||||||
Reference in New Issue
Block a user