Browse Source

RPC: Remove devdetail method, and rework newer devdetails to use its code

Luke Dashjr 12 years ago
parent
commit
0dfb8db139
2 changed files with 14 additions and 47 deletions
  1. 8 4
      README.RPC
  2. 6 43
      api.c

+ 8 - 4
README.RPC

@@ -155,9 +155,6 @@ The list of requests - a (*) means it requires privileged access - and replies:
                               the same format as the --scan-serial command line
                               the same format as the --scan-serial command line
                               option
                               option
 
 
- devdetail     DEVS           Each available device with their fixed details
-                              e.g. GPU=0,Driver=opencl,Kernel=diablo,Model=...|
-
  gpu|N         GPU            The details of a single GPU number N in the same
  gpu|N         GPU            The details of a single GPU number N in the same
                               format and details as for DEVS
                               format and details as for DEVS
 
 
@@ -313,7 +310,7 @@ The list of requests - a (*) means it requires privileged access - and replies:
  devdetails    DEVDETAILS     Each device with a list of their static details
  devdetails    DEVDETAILS     Each device with a list of their static details
                               This lists all devices including those not
                               This lists all devices including those not
                               supported by the 'devs' command
                               supported by the 'devs' command
-                              e.g. DEVDETAILS=0,Name=PGA,ID=0,ProcID=0,Driver=bitforce,...|
+                              e.g. DEVDETAILS=0,Name=BFL,ID=0,ProcID=0,Driver=bitforce,...|
 
 
  restart (*)   none           There is no status section but just a single
  restart (*)   none           There is no status section but just a single
                               "RESTART" reply before BFGMiner restarts
                               "RESTART" reply before BFGMiner restarts
@@ -445,6 +442,13 @@ api-example.py - a Python script to access the API
 Feature Changelog for external applications using the API:
 Feature Changelog for external applications using the API:
 
 
 
 
+API V2.0
+
+Removed API commands:
+ 'devdetail' - Use newer 'devdetails' for same information.
+
+----------
+
 API V1.25.3 (BFGMiner v3.2.0)
 API V1.25.3 (BFGMiner v3.2.0)
 
 
 Modified API commands:
 Modified API commands:

+ 6 - 43
api.c

@@ -1429,7 +1429,7 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	}
 	}
 	rd_unlock(&devices_lock);
 	rd_unlock(&devices_lock);
 
 
-	root = api_add_int(root, (char*)cgpu->devtype, &n, true);
+	root = api_add_int(root, "DEVDETAILS", &n, true);
 	root = api_add_device_identifier(root, cgpu);
 	root = api_add_device_identifier(root, cgpu);
 	root = api_add_string(root, "Driver", cgpu->drv->dname, false);
 	root = api_add_string(root, "Driver", cgpu->drv->dname, false);
 	if (cgpu->kname)
 	if (cgpu->kname)
@@ -1531,7 +1531,7 @@ static void cpustatus(struct io_data *io_data, int cpu, bool isjson, bool precom
 #endif
 #endif
 
 
 static void
 static void
-devinfo_internal(void (*func)(struct io_data *, struct cgpu_info*, bool, bool), struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
+devinfo_internal(void (*func)(struct io_data *, struct cgpu_info*, bool, bool), int msg, struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
 {
 {
 	bool io_open = false;
 	bool io_open = false;
 	int i;
 	int i;
@@ -1542,7 +1542,7 @@ devinfo_internal(void (*func)(struct io_data *, struct cgpu_info*, bool, bool),
 	}
 	}
 
 
 
 
-	message(io_data, MSG_DEVS, 0, NULL, isjson);
+	message(io_data, msg, 0, NULL, isjson);
 	if (isjson)
 	if (isjson)
 		io_open = io_add(io_data, COMSTR JSON_DEVS);
 		io_open = io_add(io_data, COMSTR JSON_DEVS);
 
 
@@ -1556,12 +1556,12 @@ devinfo_internal(void (*func)(struct io_data *, struct cgpu_info*, bool, bool),
 
 
 static void devdetail(struct io_data *io_data, SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 static void devdetail(struct io_data *io_data, SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 {
 {
-	return devinfo_internal(devdetail_an, io_data, c, param, isjson, group);
+	return devinfo_internal(devdetail_an, MSG_DEVDETAILS, io_data, c, param, isjson, group);
 }
 }
 
 
 static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
 static void devstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
 {
 {
-	return devinfo_internal(devstatus_an, io_data, c, param, isjson, group);
+	return devinfo_internal(devstatus_an, MSG_DEVS, io_data, c, param, isjson, group);
 }
 }
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
@@ -2777,42 +2777,6 @@ static void notify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe
 		io_close(io_data);
 		io_close(io_data);
 }
 }
 
 
-static void devdetails(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
-{
-	struct api_data *root = NULL;
-	char buf[TMPBUFSIZ];
-	bool io_open = false;
-	struct cgpu_info *cgpu;
-	int i;
-
-	if (total_devices == 0) {
-		message(io_data, MSG_NODEVS, 0, NULL, isjson);
-		return;
-	}
-
-	message(io_data, MSG_DEVDETAILS, 0, NULL, isjson);
-
-	if (isjson)
-		io_open = io_add(io_data, COMSTR JSON_DEVDETAILS);
-
-	for (i = 0; i < total_devices; i++) {
-		cgpu = get_devices(i);
-
-		root = api_add_int(root, "DEVDETAILS", &i, false);
-		root = api_add_device_identifier(root, cgpu);
-		root = api_add_string(root, "Driver", cgpu->drv->dname, false);
-		root = api_add_const(root, "Kernel", cgpu->kname ? : BLANK, false);
-		root = api_add_const(root, "Model", cgpu->name ? : BLANK, false);
-		root = api_add_const(root, "Device Path", cgpu->device_path ? : BLANK, false);
-
-		root = print_data(root, buf, isjson, isjson && (i > 0));
-		io_add(io_data, buf);
-	}
-
-	if (isjson && io_open)
-		io_close(io_data);
-}
-
 void dosave(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 void dosave(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 {
 {
 	char filename[PATH_MAX];
 	char filename[PATH_MAX];
@@ -3241,7 +3205,6 @@ struct CMDS {
 	{ "config",		minerconfig,	false },
 	{ "config",		minerconfig,	false },
 	{ "devscan",		devscan,	false },
 	{ "devscan",		devscan,	false },
 	{ "devs",		devstatus,	false },
 	{ "devs",		devstatus,	false },
-	{ "devdetail",	devdetail,	false },
 	{ "pools",		poolstatus,	false },
 	{ "pools",		poolstatus,	false },
 	{ "summary",		summary,	false },
 	{ "summary",		summary,	false },
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
@@ -3282,7 +3245,7 @@ struct CMDS {
 	{ "quit",		doquit,		true },
 	{ "quit",		doquit,		true },
 	{ "privileged",		privileged,	true },
 	{ "privileged",		privileged,	true },
 	{ "notify",		notify,		false },
 	{ "notify",		notify,		false },
-	{ "devdetails",		devdetails,	false },
+	{ "devdetails",		devdetail,	false },
 	{ "restart",		dorestart,	true },
 	{ "restart",		dorestart,	true },
 	{ "stats",		minerstats,	false },
 	{ "stats",		minerstats,	false },
 	{ "check",		checkcommand,	false },
 	{ "check",		checkcommand,	false },