
通过在开发板中输入命令 mount -t nfs 192.168.1.2:/nfsroot /mnt -o nolock
将开发板/mnt挂载到linux主机nfsroot目录下 实现文件传输共享!
在nfsroot目录下新建文件flash.c Makefile
Makefile 用交叉编译器实现编译
# this makefile is to compile the light flashing!
EXE =flash
SRC =flash.c
CC = arm-none-linux-gnueabi-gcc
.PHONY:all clean
all:
$(CC) $(SRC) $^
clean:
-rm -v $(EXE)
flash.c文件内容
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
void delaytime();
int main()
{
int time;
int t_fd,b_fd;
int t_ret,b_ret;
const char t_path[]="/sys/class/leds/led-err/trigger";
const char b_path[]="/sys/class/leds/led-err/brightness";
const char t_none[]="none";
const char b_true[1]="1"; //只写入一个字符'1'进入缓冲区
const char b_false[1]="0"; //同上
t_fd =open(t_path,O_RDWR);
printf("%s file describer is %d \n",t_path,t_fd);
b_fd =open(b_path,O_RDWR);
printf("%s file describer is %d \n",b_path,b_fd);
t_ret=write(t_fd,t_none,sizeof(t_none));
printf("write to trigger fd %d\n",t_ret);
while(1)
{
for(time=2;time>0;time--)
{
if(2 == time)
{
b_ret=write(b_fd,b_true,1);
delaytime();
printf("%d\n",b_ret);
printf("write the 1 to b\n");
}
else
{
b_ret=write(b_fd,b_false,1);
delaytime();
printf("%d\n",b_ret);
printf("write the 0 to b\n");
}
}
}
return 0;
}
void delaytime() //延时函数
{
int i,j;
for(i=1000;i>0;i--)
for(j=10000;j>0;j--);
}



本文地址:http://www.rainfly.cn/?post=172
版权声明:若无注明,本文皆为“雨夜轩”原创,转载请保留文章出处。

还有小板凳哦!