Show
Ignore:
Timestamp:
04/28/04 20:10:47 (10 years ago)
Author:
khali
Message:

Use the correct alarm bits for pc87366 temperatures and voltages.

Refactor pc87366 temperatures and voltages code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/sensors/chips.c

    r2484 r2487  
    40754075  char *label = NULL; 
    40764076  double cur, min, max; 
    4077   int alarms, valid; 
    4078  
    4079   if (!sensors_get_feature(*name, SENSORS_PC87360_ALARMS_IN, &cur))  
    4080     alarms = cur + 0.5; 
    4081   else { 
    4082     printf("ERROR: Can't get IN alarms data!\n"); 
    4083     alarms = 0; 
    4084   } 
    4085  
    4086   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN0, &label, &valid) 
    4087    && !sensors_get_feature(*name, SENSORS_PC87360_IN0, &cur) 
    4088    && !sensors_get_feature(*name, SENSORS_PC87360_IN0_MIN, &min) 
    4089    && !sensors_get_feature(*name, SENSORS_PC87360_IN0_MAX, &max)) { 
    4090     if (valid) { 
    4091       print_label(label, 10); 
    4092       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4093              cur, min, max, 
    4094              alarms&(1<<0)?"ALARM":""); 
    4095     } 
    4096   } else 
    4097     printf("ERROR: Can't get IN0 data!\n"); 
    4098   free_the_label(&label); 
    4099  
    4100   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN1, &label, &valid) 
    4101    && !sensors_get_feature(*name, SENSORS_PC87360_IN1, &cur) 
    4102    && !sensors_get_feature(*name, SENSORS_PC87360_IN1_MIN, &min) 
    4103    && !sensors_get_feature(*name, SENSORS_PC87360_IN1_MAX, &max)) { 
    4104     if (valid) { 
    4105       print_label(label, 10); 
    4106       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4107              cur, min, max, 
    4108              alarms&(1<<1)?"ALARM":""); 
    4109     } 
    4110   } else 
    4111     printf("ERROR: Can't get IN1 data!\n"); 
    4112   free_the_label(&label); 
    4113  
    4114   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN2, &label, &valid) 
    4115    && !sensors_get_feature(*name, SENSORS_PC87360_IN2, &cur) 
    4116    && !sensors_get_feature(*name, SENSORS_PC87360_IN2_MIN, &min) 
    4117    && !sensors_get_feature(*name, SENSORS_PC87360_IN2_MAX, &max)) { 
    4118     if (valid) { 
    4119       print_label(label, 10); 
    4120       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4121              cur, min, max, 
    4122              alarms&(1<<2)?"ALARM":""); 
    4123     } 
    4124   } else 
    4125     printf("ERROR: Can't get IN2 data!\n"); 
    4126   free_the_label(&label); 
    4127  
    4128   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN3, &label, &valid) 
    4129    && !sensors_get_feature(*name, SENSORS_PC87360_IN3, &cur) 
    4130    && !sensors_get_feature(*name, SENSORS_PC87360_IN3_MIN, &min) 
    4131    && !sensors_get_feature(*name, SENSORS_PC87360_IN3_MAX, &max)) { 
    4132     if (valid) { 
    4133       print_label(label, 10); 
    4134       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4135              cur, min, max, 
    4136              alarms&(1<<3)?"ALARM":""); 
    4137     } 
    4138   } else 
    4139     printf("ERROR: Can't get IN3 data!\n"); 
    4140   free_the_label(&label); 
    4141  
    4142   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN4, &label, &valid) 
    4143    && !sensors_get_feature(*name, SENSORS_PC87360_IN4, &cur) 
    4144    && !sensors_get_feature(*name, SENSORS_PC87360_IN4_MIN, &min) 
    4145    && !sensors_get_feature(*name, SENSORS_PC87360_IN4_MAX, &max)) { 
    4146     if (valid) { 
    4147       print_label(label, 10); 
    4148       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4149              cur, min, max, 
    4150              alarms&(1<<4)?"ALARM":""); 
    4151     } 
    4152   } else 
    4153     printf("ERROR: Can't get IN4 data!\n"); 
    4154   free_the_label(&label); 
    4155  
    4156   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN4, &label, &valid) 
    4157    && !sensors_get_feature(*name, SENSORS_PC87360_IN4, &cur) 
    4158    && !sensors_get_feature(*name, SENSORS_PC87360_IN4_MIN, &min) 
    4159    && !sensors_get_feature(*name, SENSORS_PC87360_IN4_MAX, &max)) { 
    4160     if (valid) { 
    4161       print_label(label, 10); 
    4162       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4163              cur, min, max, 
    4164              alarms&(1<<4)?"ALARM":""); 
    4165     } 
    4166   } else 
    4167     printf("ERROR: Can't get IN4 data!\n"); 
    4168   free_the_label(&label); 
    4169  
    4170   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN5, &label, &valid) 
    4171    && !sensors_get_feature(*name, SENSORS_PC87360_IN5, &cur) 
    4172    && !sensors_get_feature(*name, SENSORS_PC87360_IN5_MIN, &min) 
    4173    && !sensors_get_feature(*name, SENSORS_PC87360_IN5_MAX, &max)) { 
    4174     if (valid) { 
    4175       print_label(label, 10); 
    4176       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4177              cur, min, max, 
    4178              alarms&(1<<5)?"ALARM":""); 
    4179     } 
    4180   } else 
    4181     printf("ERROR: Can't get IN5 data!\n"); 
    4182   free_the_label(&label); 
    4183  
    4184   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN6, &label, &valid) 
    4185    && !sensors_get_feature(*name, SENSORS_PC87360_IN6, &cur) 
    4186    && !sensors_get_feature(*name, SENSORS_PC87360_IN6_MIN, &min) 
    4187    && !sensors_get_feature(*name, SENSORS_PC87360_IN6_MAX, &max)) { 
    4188     if (valid) { 
    4189       print_label(label, 10); 
    4190       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4191              cur, min, max, 
    4192              alarms&(1<<6)?"ALARM":""); 
    4193     } 
    4194   } else 
    4195     printf("ERROR: Can't get IN6 data!\n"); 
    4196   free_the_label(&label); 
    4197  
    4198   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN7, &label, &valid) 
    4199    && !sensors_get_feature(*name, SENSORS_PC87360_IN7, &cur) 
    4200    && !sensors_get_feature(*name, SENSORS_PC87360_IN7_MIN, &min) 
    4201    && !sensors_get_feature(*name, SENSORS_PC87360_IN7_MAX, &max)) { 
    4202     if (valid) { 
    4203       print_label(label, 10); 
    4204       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4205              cur, min, max, 
    4206              alarms&(1<<7)?"ALARM":""); 
    4207     } 
    4208   } else 
    4209     printf("ERROR: Can't get IN7 data!\n"); 
    4210   free_the_label(&label); 
    4211  
    4212   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN8, &label, &valid) 
    4213    && !sensors_get_feature(*name, SENSORS_PC87360_IN8, &cur) 
    4214    && !sensors_get_feature(*name, SENSORS_PC87360_IN8_MIN, &min) 
    4215    && !sensors_get_feature(*name, SENSORS_PC87360_IN8_MAX, &max)) { 
    4216     if (valid) { 
    4217       print_label(label, 10); 
    4218       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4219              cur, min, max, 
    4220              alarms&(1<<8)?"ALARM":""); 
    4221     } 
    4222   } else 
    4223     printf("ERROR: Can't get IN8 data!\n"); 
    4224   free_the_label(&label); 
    4225  
    4226   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN9, &label, &valid) 
    4227    && !sensors_get_feature(*name, SENSORS_PC87360_IN9, &cur) 
    4228    && !sensors_get_feature(*name, SENSORS_PC87360_IN9_MIN, &min) 
    4229    && !sensors_get_feature(*name, SENSORS_PC87360_IN9_MAX, &max)) { 
    4230     if (valid) { 
    4231       print_label(label, 10); 
    4232       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4233              cur, min, max, 
    4234              alarms&(1<<9)?"ALARM":""); 
    4235     } 
    4236   } else 
    4237     printf("ERROR: Can't get IN9 data!\n"); 
    4238   free_the_label(&label); 
    4239  
    4240   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN10, &label, &valid) 
    4241    && !sensors_get_feature(*name, SENSORS_PC87360_IN10, &cur) 
    4242    && !sensors_get_feature(*name, SENSORS_PC87360_IN10_MIN, &min) 
    4243    && !sensors_get_feature(*name, SENSORS_PC87360_IN10_MAX, &max)) { 
    4244     if (valid) { 
    4245       print_label(label, 10); 
    4246       printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
    4247              cur, min, max, 
    4248              alarms&(1<<10)?"ALARM":""); 
    4249     } 
    4250   } else 
    4251     printf("ERROR: Can't get IN10 data!\n"); 
    4252   free_the_label(&label); 
     4077  int status, valid, i, tempnr = 2; 
     4078 
     4079  for (i = 0; i < 11; i++) { 
     4080    if (!sensors_get_feature(*name, SENSORS_PC87360_IN0_STATUS + i, &cur)) 
     4081      status = cur + 0.5; 
     4082    else { 
     4083      printf("ERROR: Can't get IN%d status data!\n", i); 
     4084      status = 0; 
     4085    } 
     4086 
     4087    if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_IN0 + i, &label, &valid) 
     4088     && !sensors_get_feature(*name, SENSORS_PC87360_IN0 + i, &cur) 
     4089     && !sensors_get_feature(*name, SENSORS_PC87360_IN0_MIN + i, &min) 
     4090     && !sensors_get_feature(*name, SENSORS_PC87360_IN0_MAX + i, &max)) { 
     4091      if (valid) { 
     4092        print_label(label, 10); 
     4093        printf("%+6.2f V  (min = %+6.2f V, max = %6.2f V)       %s\n", 
     4094               cur, min, max, 
     4095               status&(PC87365_STATUS_IN_MIN 
     4096                      |PC87365_STATUS_IN_MAX)?"ALARM":""); 
     4097      } 
     4098    } else 
     4099      printf("ERROR: Can't get IN%d data!\n", i); 
     4100    free_the_label(&label); 
     4101  } 
    42534102 
    42544103  print_pc87364(name); 
    42554104 
    4256   if (!sensors_get_feature(*name, SENSORS_PC87360_ALARMS_TEMP, &cur))  
    4257     alarms = cur + 0.5; 
    4258   else { 
    4259     printf("ERROR: Can't get TEMP alarms data!\n"); 
    4260     alarms = 0; 
    4261   } 
    4262  
    4263   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP1, &label, &valid) 
    4264    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1, &cur) 
    4265    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1_MIN, &min) 
    4266    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1_MAX, &max)) { 
    4267     if (valid) { 
    4268       print_label(label, 10); 
    4269       print_temp_info(cur, max, min, MINMAX, 0, 0); 
    4270       if (alarms&(1<<0)) 
    4271         printf("ALARM"); 
    4272       printf("\n"); 
    4273     } 
    4274   } else 
    4275     printf("ERROR: Can't get TEMP1 data!\n"); 
    4276   free_the_label(&label); 
    4277  
    4278   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP1_CRIT, &label, &valid) 
    4279    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1_CRIT, &cur)) { 
    4280     if (valid) { 
    4281       print_label(label, 10); 
    4282       print_temp_info(cur, 0, 0, SINGLE, 0, 0); 
    4283       if (alarms&(1<<1)) 
    4284         printf("ALARM"); 
    4285       printf("\n"); 
    4286     } 
    4287   } else 
    4288     printf("ERROR: Can't get TEMP1 overtemperature data!\n"); 
    4289   free_the_label(&label); 
    4290  
    4291   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP2, &label, &valid) 
    4292    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP2, &cur) 
    4293    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP2_MIN, &min) 
    4294    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP2_MAX, &max)) { 
    4295     if (valid) { 
    4296       print_label(label, 10); 
    4297       print_temp_info(cur, max, min, MINMAX, 0, 0); 
    4298       if (alarms&(1<<2)) 
    4299         printf("ALARM"); 
    4300       printf("\n"); 
    4301     } 
    4302   } else 
    4303     printf("ERROR: Can't get TEMP2 data!\n"); 
    4304   free_the_label(&label); 
    4305  
    4306   if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP2_CRIT, &label, &valid) 
    4307    && !sensors_get_feature(*name, SENSORS_PC87360_TEMP2_CRIT, &cur)) { 
    4308     if (valid) { 
    4309       print_label(label, 10); 
    4310       print_temp_info(cur, 0, 0, SINGLE, 0, 0); 
    4311       if (alarms&(1<<3)) 
    4312         printf("ALARM"); 
    4313       printf("\n"); 
    4314     } 
    4315   } else 
    4316     printf("ERROR: Can't get TEMP2 overtemperature data!\n"); 
    4317   free_the_label(&label); 
    4318  
    4319   if (!strcmp(name->prefix, "pc87366")) { 
    4320     if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP3, &label, &valid) 
    4321      && !sensors_get_feature(*name, SENSORS_PC87360_TEMP3, &cur) 
    4322      && !sensors_get_feature(*name, SENSORS_PC87360_TEMP3_MIN, &min) 
    4323      && !sensors_get_feature(*name, SENSORS_PC87360_TEMP3_MAX, &max)) { 
     4105  if (!strcmp(name->prefix, "pc87366")) 
     4106    tempnr = 3; 
     4107 
     4108  for (i = 0; i < tempnr; i++) { 
     4109    if (!sensors_get_feature(*name, SENSORS_PC87360_TEMP1_STATUS + i, &cur)) 
     4110      status = cur + 0.5; 
     4111    else { 
     4112      printf("ERROR: Can't get IN%d status data!\n", i + 1); 
     4113      status = 0; 
     4114    } 
     4115 
     4116    if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP1 + i, &label, &valid) 
     4117     && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1 + i, &cur) 
     4118     && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1_MIN + i, &min) 
     4119     && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1_MAX + i, &max)) { 
    43244120      if (valid) { 
    43254121        print_label(label, 10); 
    43264122        print_temp_info(cur, max, min, MINMAX, 0, 0); 
    4327         if (alarms&(1<<4)) 
     4123        if (status&PC87365_STATUS_TEMP_OPEN) 
     4124          printf("OPEN"); 
     4125        else if (status&(PC87365_STATUS_TEMP_MIN|PC87365_STATUS_TEMP_MAX)) 
    43284126          printf("ALARM"); 
    43294127        printf("\n"); 
    43304128      } 
    43314129    } else 
    4332       printf("ERROR: Can't get TEMP3 data!\n"); 
     4130      printf("ERROR: Can't get TEMP%d data!\n", i + 1); 
    43334131    free_the_label(&label); 
    43344132 
    4335     if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP3_CRIT, &label, &valid) 
    4336      && !sensors_get_feature(*name, SENSORS_PC87360_TEMP3_CRIT, &cur)) { 
     4133    if (!sensors_get_label_and_valid(*name, SENSORS_PC87360_TEMP1_CRIT + i, &label, &valid) 
     4134     && !sensors_get_feature(*name, SENSORS_PC87360_TEMP1_CRIT + i, &cur)) { 
    43374135      if (valid) { 
    43384136        print_label(label, 10); 
    43394137        print_temp_info(cur, 0, 0, SINGLE, 0, 0); 
    4340         if (alarms&(1<<5)) 
     4138        if (status&PC87365_STATUS_TEMP_CRIT) 
    43414139          printf("ALARM"); 
    43424140        printf("\n"); 
    43434141      } 
    43444142    } else 
    4345       printf("ERROR: Can't get TEMP3 overtemperature data!\n"); 
     4143      printf("ERROR: Can't get TEMP%d overtemperature data!\n", i + 1); 
    43464144    free_the_label(&label); 
    43474145  }