Minor changes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/driver-avalon2.c b/driver-avalon2.c
index 02468b6..1a318ab 100644
--- a/driver-avalon2.c
+++ b/driver-avalon2.c
@@ -780,47 +780,44 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
{
struct api_data *root = NULL;
struct avalon2_info *info = cgpu->device_data;
- int i, a, b;
+ int i, j, a, b;
char buf[24];
double hwp;
int devtype[AVA2_DEFAULT_MODULARS];
- int minerindex = 0;
+ int minerindex, minercount;
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
devtype[i] = AVA2_ID_AVAX;
- if(strncmp((char*)&(info->mm_version[i]), AVA2_FW2_PREFIXSTR, 2) == 0){
+ if (!strncmp((char *)&(info->mm_version[i]), AVA2_MM_VERNULL, 4))
+ continue;
+ if (!strncmp((char *)&(info->mm_version[i]), AVA2_FW2_PREFIXSTR, 2))
devtype[i] = AVA2_ID_AVA2;
- }
- else if(strncmp((char*)&(info->mm_version[i]), AVA2_FW3_PREFIXSTR, 2) == 0){
+ if (!strncmp((char *)&(info->mm_version[i]), AVA2_FW3_PREFIXSTR, 2))
devtype[i] = AVA2_ID_AVA3;
- }
- else if(strncmp((char*)&(info->mm_version[i]), AVA2_MM_VERNULL, 4) == 0){
- continue;
- }
sprintf(buf, "ID%d MM Version", i + 1);
root = api_add_string(root, buf, &(info->mm_version[i]), false);
}
minerindex = 0;
- for (i = 0; i < AVA2_DEFAULT_MODULARS; i++){
- if(devtype[i] == AVA2_ID_AVA2){
- for (i = minerindex; i < (minerindex + AVA2_DEFAULT_MINERS); i++) {
- sprintf(buf, "Match work count%02d", i+1);
- root = api_add_int(root, buf, &(info->matching_work[i]), false);
- }
+ minercount = 0;
+ for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if (devtype[i] == AVA2_ID_AVAX) {
minerindex += AVA2_DEFAULT_MINERS;
- }else
- if(devtype[i] == AVA2_ID_AVA3){
- for (i = minerindex; i < (minerindex + AVA2_AVA3_MINERS); i++) {
- sprintf(buf, "Match work count%02d", i+1);
- root = api_add_int(root, buf, &(info->matching_work[i]), false);
- }
- minerindex += AVA2_AVA3_MINERS;
+ continue;
}
- else{
- minerindex += AVA2_DEFAULT_MINERS;
+
+ if (devtype[i] == AVA2_ID_AVA2)
+ minercount = AVA2_DEFAULT_MINERS;
+
+ if (devtype[i] == AVA2_ID_AVA3)
+ minercount = AVA2_AVA3_MINERS;
+
+ for (j = minerindex; j < (minerindex + minercount); j++) {
+ sprintf(buf, "Match work count%02d", j+1);
+ root = api_add_int(root, buf, &(info->matching_work[j]), false);
}
+ minerindex += AVA2_DEFAULT_MINERS;
}
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
diff --git a/driver-avalon2.h b/driver-avalon2.h
index ee0f74c..ee1fb61 100644
--- a/driver-avalon2.h
+++ b/driver-avalon2.h
@@ -70,15 +70,15 @@
#define AVA2_P_TEST_RET 26
/* Avalon2 protocol package type */
-/* Avalon2/3 prefix */
+/* Avalon2/3 firmware prefix */
#define AVA2_FW2_PREFIXSTR "20"
#define AVA2_FW3_PREFIXSTR "33"
#define AVA2_MM_VERNULL "NONE"
-#define AVA2_ID_AVA2 (0x3255)
-#define AVA2_ID_AVA3 (0x3233)
-#define AVA2_ID_AVAX (0x3200)
+#define AVA2_ID_AVA2 3255
+#define AVA2_ID_AVA3 3233
+#define AVA2_ID_AVAX 3200
struct avalon2_pkg {
uint8_t head[2];