more pic codes

This commit is contained in:
Olaf Rempel 2012-02-20 20:41:55 +01:00
parent 8c1a84a011
commit 49c5325cd1
2 changed files with 54 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
build
qnapd
*.log
*.pid

53
pic.c
View File

@ -38,6 +38,8 @@
#define PIC_CMD_FANSPEED_4 0x34
#define PIC_CMD_FANSPEED_5 0x35
#define PIC_CMD_POWER_OFF 0x41
#define PIC_CMD_AUTOPOWER_ON 0x48
#define PIC_CMD_AUTOPOWER_OFF 0x49
@ -63,6 +65,23 @@
#define PIC_CMD_USBLED_8HZ 0x61
#define PIC_CMD_USBLED_OFF 0x62
#define PIC_EVENT_POWER_BUTTON 0x40
#define PIC_EVENT_FAN1_ERR 0x73
#define PIC_EVENT_FAN1_OK 0x74
#define PIC_EVENT_FAN2_ERR 0x75
#define PIC_EVENT_FAN2_OK 0x76
#define PIC_EVENT_FAN3_ERR 0x77
#define PIC_EVENT_FAN3_OK 0x78
#define PIC_EVENT_FAN4_ERR 0x79
#define PIC_EVENT_FAN4_OK 0x7A
#define PIC_EVENT_TEMP_RANGE_MIN 0x80 /* 0°C */
#define PIC_EVENT_TEMP_RANGE_MAX 0xC6 /* 70°C */
#define PIC_EVENT_TEMP_WARN 0x38 /* 71-79°C */
#define PIC_EVENT_TEMP_CRIT 0x39 /* >= 80°C */
struct picdev {
int fd;
struct termios oldtio;
@ -116,7 +135,39 @@ static int pic_read_cb(int fd, void *privdata)
if (len < 0)
return -1;
log_print(LOG_DEBUG, "%s(): 0x%02x", __FUNCTION__, event);
switch (event)
{
case PIC_EVENT_POWER_BUTTON:
log_print(LOG_DEBUG, "%s(): POWER BUTTON", __FUNCTION__);
break;
case PIC_EVENT_FAN1_ERR:
case PIC_EVENT_FAN1_OK:
log_print(LOG_DEBUG, "%s(): FAN1 %s", __FUNCTION__, (event & 0x01) ? "fail" : "ok");
break;
case PIC_EVENT_FAN2_ERR:
case PIC_EVENT_FAN2_OK:
log_print(LOG_DEBUG, "%s(): FAN2 %s", __FUNCTION__, (event & 0x01) ? "fail" : "ok");
break;
case PIC_EVENT_TEMP_RANGE_MIN ... PIC_EVENT_TEMP_RANGE_MAX:
log_print(LOG_DEBUG, "%s(): TEMP %d°C", __FUNCTION__, event - 128);
break;
case PIC_EVENT_TEMP_WARN:
log_print(LOG_DEBUG, "%s(): TEMP WARNING", __FUNCTION__);
break;
case PIC_EVENT_TEMP_CRIT:
log_print(LOG_DEBUG, "%s(): TEMP CRITICAL", __FUNCTION__);
break;
default:
log_print(LOG_DEBUG, "%s(): unknown event 0x%02x", __FUNCTION__, event);
break;
}
return 0;
}