void Main_Task(uint_32 data)
{
uchar data_test[] = "K40!";
uchar data_error[] = "error";
uchar data_ok[] = "OK";
MQX_FILE_PTR dispfd;
uint_32 param,size,i=0;
uchar data_recv_buf[10];
uchar_ptr data_recv_ptr;
uchar_ptr data_write_ptr;
size = 0;
data_recv_ptr = data_recv_buf;
data_write_ptr = data_test;
dispfd = fopen("ttyf:",NULL);
if(NULL == dispfd){
printf("uart1 driver fault
");
} else {
printf("uart1 driver open sucess
");
}
fclose(dispfd);
if(i==0)
printf("关闭成功
");
else
printf("fault
");
while(TRUE){
size = 0;
size = disp_com_send_data(dispfd, "K40!", sizeof(data_test));
if(size){
printf("the send data is %s
","K40!");
#if 0
size = disp_com_recv_data(dispfd, data_recv_ptr, sizeof(data_test));
if(0 != size){
printf("the receive data is %s
",data_recv_ptr);
if(!strcmp("K40!",data_recv_ptr)){
disp_com_send_data(dispfd, data_ok, sizeof(data_ok));
} else {
disp_com_send_data(dispfd, data_error, sizeof(data_error));
}
}
#endif
}
_time_delay(200);
}
}
uint_32 disp_com_send_data(MQX_FILE_PTR spifd, uchar_ptr data, uint_32 size)
{
uint_32 result = 0;
result = fwrite(data,1,size,spifd);
return result;
}
uint_32 disp_com_recv_data(MQX_FILE_PTR spifd, uchar_ptr data, uint_32 size)
{
uint_32 result = 0;
result = fread(data, 1, size, spifd);
return result;
}
正常的话我用fopen打开以后 再用fclose关闭就不能写文件了吧,文件的指针也被清空了吧,但为什么我关闭之后,还能写文件,指针也没被清空呢,也没有报错啊。调用的也没错啊。。。。请高手赐教。。。。。。
此帖出自
小平头技术问答
一周热门 更多>