void exit_app(int signo)
{
fprintf(stderr,"\n exit the GPIO_INT appliaction,Good bye\n");
_exit(0);
}
unsigned short get_alarm_io(void)
{
int alarm_inode=-1;
unsigned short val =0;
unsigned short *pval=&val;
if((alarm_inode=open("/dev/ala"rm,O_RDWR))<0)
{
printf("open alarm error\n");
return -1;
}
ioctl(alarm_inode, alm_read, pval);
close(alarm_inode);
return val;
}
void open_alarm(void)
{
int alarm_inode=-1;
if((alarm_inode=open("/dev/alarm",O_RDWR))<0)
{
printf("open alarm error\n"); }
else
printf("open al**\n");
ioctl(alarm_inode,alm_set_almsvrpid,getpid());
close(alarm_inode);
}
void Smokesensor_alarm(int sig)
{ char *psmoke;
int ret,i; int j = 0;
#if !USE_ALM
intflag=get_alarm_io();
#else if
intflag = (1<<6); //set intflag use alarm happen
printf("intflag in smokesensor_alarm is %d\n", intflag);
alarm(10);
#endif
}
void sig_init()
sensor // signal(SIGPIPE, alarm_handler);
// signal(SIGINT, exit_app);
sigact_smokesensor.sa_handler = Smokesensor_alarm;
sigemptyset(&sigact_smokesensor.sa_mask);
sigaddset(&sigact_smokesensor.sa_mask,SIGUSR2);
sigact_smokesensor.sa_flags=0;
if(sigaction(SIGUSR2,&sigact_smokesensor,NULL)<0)
printf("Install smokesensor_alarm Signal Action Error");
#if USE_ALM
signal (SIGALRM, Smokesensor_alarm);
alarm (5);
#endif
}
static void initdevice()
{
jpeginit();//初始化codec
printf("initialize Ipipe");
InitIpipe(CAP_WIDTH, CAP_HEIGHT, &ipipebuffer);
printf("initializing capture device\n");
InitCaptureDevice(CAP_FORMAT, CAP_WIDTH, CAP_HEIGHT);
printf("initializing display device\n");
InitDisplayDevice();
printf("starting streaming\n");
StartStreaming();
}
static void jpeginit(void)
{
// init Codec Engine
CERuntime_init();
// init trace
GT_init();
// create a mask to allow a trace-print welcome message below
GT_create(&curMask, MOD_NAME);
// Enable all trace for this module
GT_set(MOD_NAME "=01234567");
GT_0trace(curMask, GT_2CLASS, "main> " MOD_NAME "\n");
}
int StartCameraCapture(void)
{
int capbuf_phyaddr;
unsigned short *addr;
unsigned char *addr8;
int previewOnce = 1;
int max;
int i=0,j;
int frame=0;
int cnt = 0; //the times count of photo caption
// for(i=0;i<500;i++)
while (1)
{
CaptureFrame(&capbuf_phyaddr);
DoIPIPING(CAP_WIDTH, CAP_HEIGHT, capbuf_phyaddr);
#if 1
//printf("intflag in startCamerCap is %d\n", intflag);
if(intflag!=0)
{
smain((XDAS_Int8 *)ipipebuffer.start);
cnt ++;
if (cnt == CAP_TIMES ) {
intflag=0;//清空标识位
cnt =0;
}
}
#endif
DisplayFrame(ipipebuffer.start,640,480);//设置显示的大小
frame++;
//printf ( "\nhave captured and sent %d frames\n",frame );
}
}
int main(int argc, char *argv[])
{
sig_init();
open_alarm();
initdevice();
StartCameraCapture();
CloseCaptureDevice();
CloseIpipe(&ipipebuffer);
//restore_display_config();
return 0;
} |