index:
leds.cgi:部分程序
led_fd=open("/dev/tiny6410-led",O_RDWR);
if(led_fd==-1)
{
perror("open tiny6410-led device failed\n");
printf("open tiny6410-led device failed\n");
exit(1);
}
else
{
//printf("open tiny6410-led device success!\n");
}
/*LED1*/
if(fifo_value[0]==0)
{
if(ioctl(led_fd,1,00)==0)
printf("CGI ioctl is ok\n");
else
printf("CGI ioctl is wrong\n");
printf("my led1 off!\n");
}
if(fifo_value[0]==1)
{
if(ioctl(led_fd,1,01)==0)
printf("CGI ioctl is ok\n");
else
printf("CGI ioctl is wrong\n");
printf("my led1 on!\n");
}
if(fifo_value[0]==10)
{
ioctl(led_fd,0,&arg);
_itoa(arg,s,2);
//printf("s=%s\n",s);
n=strlen(s);
//printf("n=%d\n",n);
//printf("s[0]=%c",s[0]);
if(s[0]=='0')
printf("led 1: ON\n");
else if(s[0]=='1')
printf("led 1: OFF\n");
}
效果图:
阅读(2166) | 评论(0) | 转发(2) |