diff --git a/API/__init__.py b/API/__init__.py index 61aaad60..6c8b8f55 100644 --- a/API/__init__.py +++ b/API/__init__.py @@ -21,14 +21,14 @@ class BaseMinerAPI: self.port = port self.ip = ip - async def send_command(self, command, parameters=None): + async def send_command(self, command, parameters: dict = None): # get reader and writer streams reader, writer = await asyncio.open_connection(self.ip, self.port) # create the command cmd = {"command": command} - if parameters: - cmd["parameters"] = parameters + if parameters is not None: + cmd["parameter"] = parameters # send the command writer.write(json.dumps(cmd).encode('utf-8')) @@ -53,6 +53,8 @@ class BaseMinerAPI: # check if the data returned is correct or an error if not data["STATUS"][0]["STATUS"] in ("S", "I"): # this is an error + print(cmd) + print(data) raise APIError(data["STATUS"][0]["Msg"]) # return the data diff --git a/API/bmminer.py b/API/bmminer.py index 8ffa72f3..78efa101 100644 --- a/API/bmminer.py +++ b/API/bmminer.py @@ -39,7 +39,7 @@ class BMMinerAPI(BaseMinerAPI): return await self.send_command("enablepool", parameters=n) async def addpool(self, url: str, username: str, password: str): - return await self.send_command("enablepool", parameters=f"{url}, {username}, {password}") + return await self.send_command("addpool", parameters=f"{url}, {username}, {password}") async def poolpriority(self, *n: int): return await self.send_command("poolpriority", parameters=f"{','.join(n)}") diff --git a/API/bosminer.py b/API/bosminer.py index a3ed76a7..9c8a8def 100644 --- a/API/bosminer.py +++ b/API/bosminer.py @@ -57,7 +57,7 @@ class BOSMinerAPI(BaseMinerAPI): return await self.send_command("disablepool", parameters=n) async def addpool(self, url: str, username: str, password: str): - return await self.send_command("enablepool", parameters=f"{url}, {username}, {password}") + return await self.send_command("addpool", parameters=f"{url}, {username}, {password}") async def removepool(self, n: int): return await self.send_command("removepool", parameters=n) diff --git a/main.py b/main.py index dcd2d784..e0939417 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ import asyncio async def main(): bosminer = BOSMinerAPI("172.16.1.199") - data = await bosminer.stats() + data = await bosminer.edevs(old=True) print(data)