void timedAlarmCheck(void) { for (uint8_t alarm=1; alarm<=4; alarm++) { uint16_t pos = 400 + ((alarm-1)*15); //400 415 430 445 if (eepromReadByte(pos+0) == 1) { uint8_t sensorpos = findSensor( eepromReadByte(pos+1), eepromReadByte(pos+2), eepromReadByte(pos+3), eepromReadByte(pos+4), eepromReadByte(pos+5), eepromReadByte(pos+6), eepromReadByte(pos+7), eepromReadByte(pos+8)); int8_t value = (int8_t)sensorValues[(sensorpos*SENSORSIZE)+VALUE1]; char sign = sensorValues[(sensorpos*SENSORSIZE)+SIGN]; if (sign == '-') value *= -1; int8_t target = eepromReadByteSigned(pos+10); if ( (eepromReadByte(pos+9) == 1 && value < target) || (eepromReadByte(pos+9) == 2 && value == target) || (eepromReadByte(pos+9) == 3 && value > target) ) { //ALARM //DDR=in/out PIN=value/pullup PORT=state uint8_t pin = eepromReadByte(pos+11); if (pin >= 1 && pin <= 4) { if (eepromReadByte(pos+12) == 1) { SETBIT(PORTC, (1+pin)); } else CLEARBIT(PORTC, (1+pin)); } } else if (eepromReadByte(pos+13) == 1) { //REVERSE uint8_t pin = eepromReadByte(pos+11); if (pin >= 1 && pin <= 4) { if (eepromReadByte(pos+12) == 1) CLEARBIT(PORTC, (1+pin)); else SETBIT(PORTC, (1+pin)); } } } } }
ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request, ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context) { sensor_data_t *reqptr = (sensor_data_t*)request; ipmi_ret_t rc = IPMI_CC_OK; printf("IPMI GET_SENSOR_TYPE [0x%02X]\n",reqptr->sennum); // TODO Not sure what the System-event-sensor is suppose to return // need to ask Hostboot team unsigned char buf[] = {0x00,0x6F}; buf[0] = findSensor(reqptr->sennum); *data_len = sizeof(buf); memcpy(response, &buf, *data_len); return rc; }
void updateOWSensors() { #ifdef OW_DEBUG printf_P(PSTR("Update onewire \r\n")); #endif uint8_t subzero, cel, cel_frac_bits; uint16_t maalt; if (!DS18B20Conv) { DS18B20Conv = true; for (uint8_t active_OW_channel = 1; active_OW_channel <= 3; active_OW_channel++) { OW_selectPort(active_OW_channel); DS18X20_start_meas(DS18X20_POWER_PARASITE, NULL); } } else { DS18B20Conv = false; for (uint8_t active_OW_channel = 1; active_OW_channel <= 3; active_OW_channel++) { OW_selectPort(active_OW_channel); #ifdef OW_DEBUG printf_P(PSTR("Scanner for onewire sensore paa %d\r\n"), active_OW_channel); #endif int nSensors = search_sensors(MAXSENSORS); //Finder alle sensore (op til max) #ifdef OW_DEBUG printf("Found %d sensors \r\n", nSensors); #endif for (int i = 0; i < nSensors; i++) { if (sensorScan[i * OW_ROMCODE_SIZE + 0] == 0x10 || sensorScan[i * OW_ROMCODE_SIZE + 0] == 0x28) { uint8_t sensorID[OW_ROMCODE_SIZE]; for (uint8_t o = 0; o < OW_ROMCODE_SIZE; o++) sensorID[o] = sensorScan[i * OW_ROMCODE_SIZE + o]; if (DS18X20_read_meas(sensorID, &subzero, &cel, &cel_frac_bits, &maalt) == DS18X20_OK) { #ifdef OW_DEBUG int frac = cel_frac_bits * DS18X20_FRACCONV; //Ganger de sidste par bits, med det step DS18B20 bruger #endif char sign = (subzero) ? '-' : '+'; uint16_t pos = findSensor( sensorScan[i * OW_ROMCODE_SIZE + FAMILY], sensorScan[i * OW_ROMCODE_SIZE + ID1], sensorScan[i * OW_ROMCODE_SIZE + ID2], sensorScan[i * OW_ROMCODE_SIZE + ID3], sensorScan[i * OW_ROMCODE_SIZE + ID4], sensorScan[i * OW_ROMCODE_SIZE + ID5], sensorScan[i * OW_ROMCODE_SIZE + ID6], sensorScan[i * OW_ROMCODE_SIZE + CRC] ); sensorValues[(pos * SENSORSIZE) + VALUE1] = cel; sensorValues[(pos * SENSORSIZE) + VALUE2] = cel_frac_bits; sensorValues[(pos * SENSORSIZE) + SIGN] = sign; #ifdef OW_DEBUG printf_P(PSTR("Sensor# %d (%02X%02X%02X%02X%02X%02X%02X%02X) = : %c%d.%04d\r\n"), i + 1, sensorValues[(pos * SENSORSIZE) + FAMILY], sensorValues[(pos * SENSORSIZE) + ID1], sensorValues[(pos * SENSORSIZE) + ID2], sensorValues[(pos * SENSORSIZE) + ID3], sensorValues[(pos * SENSORSIZE) + ID4], sensorValues[(pos * SENSORSIZE) + ID5], sensorValues[(pos * SENSORSIZE) + ID6], sensorValues[(pos * SENSORSIZE) + CRC], sensorValues[(pos * SENSORSIZE) + SIGN], sensorValues[(pos * SENSORSIZE) + VALUE1], frac ); #endif } else printf_P(PSTR("CRC Error (lost connection?)")); } } } } }