Commit 454607c30c12f6ddb80508839f098d9e95f04c9b

Con Kolivas 2012-07-02T21:52:58

Merge pull request #251 from kanoi/notifycomms Add API Notify counter 'Comms Error'

diff --git a/API-README b/API-README
index 9c633bd..df905ef 100644
--- a/API-README
+++ b/API-README
@@ -313,6 +313,7 @@ API V1.14
 
 Modified API commands:
  'stats' - more icarus timing stats added
+ 'notify' - include new device comms error counter
 
 The internal code for handling data was rewritten (~25% of the code)
 Completely backward compatible
diff --git a/api.c b/api.c
index 2622b16..06a10b6 100644
--- a/api.c
+++ b/api.c
@@ -2419,6 +2419,9 @@ void notifystatus(int device, struct cgpu_info *cgpu, bool isjson, __maybe_unuse
 			case REASON_DEV_THERMAL_CUTOFF:
 				reason = REASON_DEV_THERMAL_CUTOFF_STR;
 				break;
+			case REASON_DEV_COMMS_ERROR:
+				reason = REASON_DEV_COMMS_ERROR_STR;
+				break;
 			default:
 				reason = REASON_UNKNOWN_STR;
 				break;
@@ -2440,6 +2443,7 @@ void notifystatus(int device, struct cgpu_info *cgpu, bool isjson, __maybe_unuse
 	root = api_add_int(root, "*Dev Nostart", &(cgpu->dev_nostart_count), false);
 	root = api_add_int(root, "*Dev Over Heat", &(cgpu->dev_over_heat_count), false);
 	root = api_add_int(root, "*Dev Thermal Cutoff", &(cgpu->dev_thermal_cutoff_count), false);
+	root = api_add_int(root, "*Dev Comms Error", &(cgpu->dev_comms_error_count), false);
 
 	if (isjson && (device > 0))
 		strcat(io_buffer, COMMA);
diff --git a/driver-bitforce.c b/driver-bitforce.c
index ba23911..cf2d6ca 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -412,8 +412,8 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 		ret = 1;
 		applog(LOG_ERR, "BFL%i: Comms error", bitforce->device_id);
 		bitforce->device_last_not_well = time(NULL);
-		bitforce->device_not_well_reason = REASON_DEV_NOSTART;
-		bitforce->dev_nostart_count++;
+		bitforce->device_not_well_reason = REASON_DEV_COMMS_ERROR;
+		bitforce->dev_comms_error_count++;
 		/* empty read buffer */
 		biforce_clear_buffer(bitforce);
 	}
diff --git a/miner.h b/miner.h
index c50fa3e..d3fa209 100644
--- a/miner.h
+++ b/miner.h
@@ -272,6 +272,7 @@ enum dev_reason {
 	REASON_DEV_NOSTART,
 	REASON_DEV_OVER_HEAT,
 	REASON_DEV_THERMAL_CUTOFF,
+	REASON_DEV_COMMS_ERROR,
 };
 
 #define REASON_NONE			"None"
@@ -283,6 +284,7 @@ enum dev_reason {
 #define REASON_DEV_NOSTART_STR		"Device failed to start"
 #define REASON_DEV_OVER_HEAT_STR	"Device over heated"
 #define REASON_DEV_THERMAL_CUTOFF_STR	"Device reached thermal cutoff"
+#define REASON_DEV_COMMS_ERROR_STR	"Device comms error"
 #define REASON_UNKNOWN_STR		"Unknown reason - code bug"
 
 #define MIN_SEC_UNSET 99999999
@@ -386,6 +388,7 @@ struct cgpu_info {
 	int dev_nostart_count;
 	int dev_over_heat_count;	// It's a warning but worth knowing
 	int dev_thermal_cutoff_count;
+	int dev_comms_error_count;
 
 	struct cgminer_stats cgminer_stats;
 };