前面把boa移植好了現在就來用web控制led 見 Ttiny6410移植boa服務器 http://www.linuxidc.com/Linux/2012-07/65706.htm
index:
<p align="center" class="STYLE4"> 控制燈1測試:</p>
<div align="center">
<form id="form1" name="form1" method="get" action="/cgi-bin/leds.cgi">
<p>
<label>
<input type="radio" name="type" value="1" />
開燈 </label>
<br />
<label>
<input type="radio" name="type" value="0" checked/>
關燈</label>
<br />
<label>
<input type="radio" name="type" value="10" />
查看LED1狀態 </label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="OK!" />
</label>
</p>
</form>
</div>
<label>
</label>
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");
}
效果圖: