static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *attr, char *buf) { struct imanager_hwmon_data *data = imanager_hwmon_update_device(dev); int index = to_sensor_dev_attr(attr)->index; struct hwm_smartfan *fan = &data->hwm.fan[index - 1]; return sprintf(buf, "%u\n", fan->valid ? is_alarm(fan) : 0); }
/* dismiss the alarm and unblock the thread */ static void dismiss_alarm (struct alarm *alrm) { enum intr_level old_level; ASSERT (is_alarm (alrm)); /* remove from alarm_list, critical section */ old_level = intr_disable (); list_remove (&alrm->elem); thread_unblock (alrm->thrd); /* unblock the thread */ intr_set_level (old_level); }
/*********************************************************************//*! * @brief The main program * * Opens the camera and reads pictures as fast as possible * Makes a debayering of the image * Writes the debayered image to a buffer which can be read by * TCP clients on Port 8111. Several concurrent clients are allowed. * The simplest streaming video client looks like this: * * nc 192.168.1.10 8111 | mplayer - -demuxer rawvideo -rawvideo w=376:h=240:format=bgr24:fps=100 * * Writes every 10th picture to a .jpg file in the Web Server Directory *//*********************************************************************/ int main(const int argc, const char * argv[]) { struct OSC_PICTURE calcPic; struct OSC_PICTURE rawPic; unsigned char *tmpbuf; int loops=0; int numalarm=0; char filename[100]; initSystem(&sys); ip_start_server(); /* setup variables */ rawPic.width = OSC_CAM_MAX_IMAGE_WIDTH; rawPic.height = OSC_CAM_MAX_IMAGE_HEIGHT; rawPic.type = OSC_PICTURE_GREYSCALE; /* calcPic width, height etc. are set in the debayering algos */ calcPic.data = malloc(3 * OSC_CAM_MAX_IMAGE_WIDTH * OSC_CAM_MAX_IMAGE_HEIGHT); if (calcPic.data == 0) fatalerror("Did not get memory\n"); tmpbuf = malloc(500000); if (tmpbuf == 0) fatalerror("Did not get memory\n"); #if defined(OSC_TARGET) /* Take a picture, first time slower ;-) */ usleep(10000); OscGpioTriggerImage(); usleep(10000); OscLog(DEBUG,"Triggered CAM "); #endif while(true) { OscCamReadPicture(OSC_CAM_MULTI_BUFFER, (void *) &rawPic.data, 0, 0); /* Take a picture */ usleep(2000); OscCamSetupCapture(OSC_CAM_MULTI_BUFFER); #if defined(OSC_TARGET) OscGpioTriggerImage(); #else usleep(10000); #endif if (is_alarm(&rawPic)) { OscGpioSetTestLed(TRUE); printf("alarm\n"); sprintf(filename, "/home/httpd/alarm_pic%02i.jpg", numalarm%16); writeJPG(&calcPic, tmpbuf, filename); numalarm++; } else { OscGpioSetTestLed(FALSE); } fastdebayerBGR(rawPic, &calcPic, NULL); ip_send_all((char *)calcPic.data, calcPic.width*calcPic.height* OSC_PICTURE_TYPE_COLOR_DEPTH(calcPic.type)/8); loops+=1; if (loops%20 == 0) { writeJPG(&calcPic, tmpbuf, "/home/httpd/liveimage.jpg"); } ip_do_work(); } ip_stop_server(); cleanupSystem(&sys); return 0; } /* main */