📄 udisc.c
字号:
if(temp>10)
{
Uart_Printf("\n文件名过长,仅创建前11个字符的文件名\n");
break;
}
}
Command.CLass=0x04; //Create file
Command.len=0;
// Command.Parameter[0]=0x4c;Command.Parameter[1]=0x49;Command.Parameter[2]=0x20;Command.Parameter[3]=0x20;
// Command.Parameter[4]=0x20;Command.Parameter[5]=0x20;Command.Parameter[6]=0x20;Command.Parameter[7]=0x20;
// Command.Parameter[8]=0x54;Command.Parameter[9]=0x58;Command.Parameter[10]=0x54;
Command.Parameter[11]=0x20;Command.Parameter[12]=0x10;Command.Parameter[13]=0x62;
Command.Parameter[14]=0x57;Command.Parameter[15]=0x4C;Command.Parameter[16]=0xA7;
Command.Parameter[17]=0x30;Command.Parameter[18]=0xA7;Command.Parameter[19]=0x30;
Command.Parameter[20]=0x00;Command.Parameter[21]=0x00;Command.Parameter[22]=0x09;
Command.Parameter[23]=0x35;Command.Parameter[24]=0x32;Command.Parameter[25]=0x24;
Command.Parameter[26]=0x00;Command.Parameter[27]=0x00;Command.Parameter[28]=0x00;
Command.Parameter[29]=0x00;Command.Parameter[30]=0x00;Command.Parameter[31]=0x00;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
{
Uart_Printf("操作完毕\n");
end=findend(current_floder);
for(i=0;(filename[i]!='\0');i++)
current_floder[end+i]=filename[i];
//current_floder[end+i]='\\';
current_floder[end+i+1]='\0';
}
else
Uart_Printf("操作失败\n");
}
void check_space(void)
{
unsigned int temp;
Command.CLass=0x07; //check space
Command.len=0x00;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
{
Uart_Printf("操作完毕\n");
Uart_Printf("剩余空间为:%d%d%d%d 字节\n",UARTBUF[0],UARTBUF[1],UARTBUF[2],UARTBUF[3]);
}
else
Uart_Printf("操作失败\n");
}
/*
void write_file(void)
{unsigned int temp;
Command.CLass=0x05; //WriteFile
Command.len=0x0f;
UARTBUF[0]='C';UARTBUF[1]='S';UARTBUF[2]='U';UARTBUF[3]=' ';
UARTBUF[4]='L';UARTBUF[5]='i';UARTBUF[6]='u';UARTBUF[7]='X';UARTBUF[8]='i';
UARTBUF[9]='a';UARTBUF[10]='n';UARTBUF[11]='g';UARTBUF[12]='Y';UARTBUF[13]='u';UARTBUF[14]=' ';
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
Uart_Printf("操作完毕\n");
else
Uart_Printf("操作失败\n");
}
*/
void write_file(void)
{
unsigned int temp;
char *string;
Uart_Printf("\n请输入要写入的内容(可输入汉字): ");
Command.len=Uart_GetContent(string);
Command.len++;
Uart_Printf("\n%d\n",Command.len);
// Uart_Printf("\n%d",sizeof(content));
Command.CLass=0x05; //WriteFile
for(temp=0;temp<Command.len;temp++)
{
UARTBUF[temp]=content[temp];
// Uart_Printf(" %d:%c %c ",temp,content[temp],UARTBUF[temp]);
}
// Command.len=0x0f;
// UARTBUF[0]='C';UARTBUF[1]='S';UARTBUF[2]='U';UARTBUF[3]=' ';
// UARTBUF[4]='L';UARTBUF[5]='i';UARTBUF[6]='u';UARTBUF[7]='X';UARTBUF[8]='i';
// UARTBUF[9]='a';UARTBUF[10]='n';UARTBUF[11]='g';UARTBUF[12]='Y';UARTBUF[13]='u';UARTBUF[14]=' ';
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
Uart_Printf("操作完毕\n");
else
Uart_Printf("操作失败\n");
}
void read_file(void)
{unsigned int temp;
Command.CLass=0x02; //Read File
Command.len=0x0f;
Command.Parameter[0]=0x0;Command.Parameter[1]=0x0;Command.Parameter[2]=0x0;Command.Parameter[3]=0x0;
Command.Parameter[4]=0x0;Command.Parameter[5]=0x0;Command.Parameter[6]=0x0;Command.Parameter[7]=0x0;
Command.Parameter[8]=0x0;Command.Parameter[9]=0x0;Command.Parameter[10]=0x0;
Command.Parameter[11]=0x0;Command.Parameter[12]=0x0;Command.Parameter[13]=0x0;
Command.Parameter[14]=0x0;Command.Parameter[15]=0x0;Command.Parameter[16]=0x0;
Command.Parameter[17]=0x0;Command.Parameter[18]=0x0;Command.Parameter[19]=0x0;
Command.Parameter[20]=0x0;Command.Parameter[21]=0x0;Command.Parameter[22]=0x0;
Command.Parameter[23]=0x0;Command.Parameter[24]=0x0;Command.Parameter[25]=0x0;
Command.Parameter[26]=0x0;Command.Parameter[27]=0x00;Command.Parameter[28]=0x00;
Command.Parameter[29]=0x0;Command.Parameter[30]=0x00;Command.Parameter[31]=0x00;
UARTBUF[0]=' ';UARTBUF[1]=' ';UARTBUF[2]=' ';UARTBUF[3]=' ';
UARTBUF[4]=' ';UARTBUF[5]=' ';UARTBUF[6]=' ';UARTBUF[7]=' ';UARTBUF[8]=' ';
UARTBUF[9]=' ';UARTBUF[10]=' ';UARTBUF[11]=' ';UARTBUF[12]=' ';UARTBUF[13]=' ';UARTBUF[14]=' ';
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
Uart_Printf("操作完毕\n");
else
Uart_Printf("操作失败\n");
}
void open_file(void)
{
unsigned int temp;
Command.CLass=0x01; //Open file
Command.len=0;
Command.Parameter[0]='1';Command.Parameter[1]=' ';Command.Parameter[2]=' ';Command.Parameter[3]=' ';
Command.Parameter[4]=' ';Command.Parameter[5]=' ';Command.Parameter[6]=' ';Command.Parameter[7]=' ';
Command.Parameter[8]='T';Command.Parameter[9]='X';Command.Parameter[10]='T';
Command.Parameter[11]=0x0;Command.Parameter[12]=0x0;Command.Parameter[13]=0x0;
Command.Parameter[14]=0x0;Command.Parameter[15]=0x00;Command.Parameter[16]=0x0;
Command.Parameter[17]=0x0;Command.Parameter[18]=0x0;Command.Parameter[19]=0x0;
Command.Parameter[20]=0x00;Command.Parameter[21]=0x00;Command.Parameter[22]=0x0;
Command.Parameter[23]=0x00;Command.Parameter[24]=0x0;Command.Parameter[25]=0x0;
Command.Parameter[26]=0x00;Command.Parameter[27]=0x00;Command.Parameter[28]=0x00;
Command.Parameter[29]=0x00;Command.Parameter[30]=0x00;Command.Parameter[31]=0x00;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
Uart_Printf("操作完毕\n");
else
Uart_Printf("操作失败\n");
}
void del_f(void)
{
}
void turn_folder(void) //进入目录项
{
unsigned int temp;
Command.CLass=0x0a; //
Command.len=0;
Command.Parameter[0]=0x31;Command.Parameter[1]=0x32;Command.Parameter[2]=0x33;Command.Parameter[3]=0x34;
Command.Parameter[4]=0x35;Command.Parameter[5]=0x20;Command.Parameter[6]=0x20;Command.Parameter[7]=0x20;
Command.Parameter[8]=0x20;Command.Parameter[9]=0x20;Command.Parameter[10]=0x20;
Command.Parameter[11]=0x10;Command.Parameter[12]=0x00;Command.Parameter[13]=0xAD;
Command.Parameter[14]=0xE0;Command.Parameter[15]=0x14;Command.Parameter[16]=0xBD;
Command.Parameter[17]=0x2E;Command.Parameter[18]=0xBD;Command.Parameter[19]=0x2E;
Command.Parameter[20]=0x00;Command.Parameter[21]=0x00;Command.Parameter[22]=0xE1;
Command.Parameter[23]=0x14;Command.Parameter[24]=0xBD;Command.Parameter[25]=0x2E;
Command.Parameter[26]=0x00;Command.Parameter[27]=0x00;Command.Parameter[28]=0x00;
Command.Parameter[29]=0x00;Command.Parameter[30]=0x00;Command.Parameter[31]=0x00;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
{
Uart_Printf("操作完毕\n");
}
else
Uart_Printf("操作失败\n");
}
void return_up_folder(void) //返回上一级目录
{
unsigned int temp,end,end1,end2;
Command.CLass=0x0b; //
Command.len=0;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
{
Uart_Printf("操作完毕\n");
end=findend(current_floder);
if(current_floder[end-1]=='\\')
{
end=end-2;
}
else
{
end2=findright(current_floder,end);
end=--end2;
}
end1=findright(current_floder,end);
current_floder[++end1]='\0';
}
else
Uart_Printf("操作失败\n");
}
void return_root(void) //返回根目录
{
unsigned int temp;
Command.CLass=0x0c; //
Command.len=0;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
Uart_Printf("操作完毕\n");
else
Uart_Printf("操作失败\n");
}
void list(void)
{
unsigned int temp;
Command.CLass=0x0; //
Command.len=0;
if(DeviceInfo.FAT==0)
temp=UartHandler();
else
temp=UartHandler32();
if(1==temp)
Uart_Printf("操作完毕\n");
// Uart_Printf("根目录下共有 %d 个文件 \n",);
// Uart_Printf("剩余空间为:%d%d%d%d 字节\n",UARTBUF[0],UARTBUF[1],UARTBUF[2],UARTBUF[3]);
else
Uart_Printf("操作失败\n");
}
unsigned int Uart_Getfilename(char *string)
{
char *string2=string;
char c;
unsigned int i=0;
while((c=Uart_Getch())!='\r')
{
if(c=='\b')
{
if( (int)string2 < (int)string )
{
Uart_Printf("\b \b");
string--;
i--;
if((*string>0xb0)&&(*string<0xf7))
{
string--;
i--;
}
}
}
else
{
*string++=c;
filename[i]=c;
i++;
Uart_SendByte(c);
}
}
*string='\0';
filename[i]='\0';
Uart_SendByte('\n');
return i;
}
unsigned int Uart_GetContent(char *string)
{
char *string2=string;
char c;
unsigned int i=0;
while((c=Uart_Getch())!='\r')
{
if(c=='\b')
{
if( (int)string2 < (int)string )
{
Uart_Printf("\b \b");
string--;
i--;
if((*string>0xb0)&&(*string<0xf7))
{
string--;
i--;
}
}
}
else
{
*string++=c;
content[i]=c;
i++;
Uart_SendByte(c);
}
}
*string='\0';
content[i]='\0';
Uart_SendByte('\n');
return i;
}
unsigned int findright(char *str,unsigned int i) //寻找最右边的
{
while((str[i]!='\\')&&(i>=0))
{
i--;
}
return i;
}
unsigned int findend(char *str)
{
unsigned int temp;
for(temp=0;(str[temp]!='\0');temp++);
return temp;
}
void add_string(char *str1,char *str2) //str1=str1+str2;
{
unsigned int i,temp;
i=findend(str1);
for(temp=0;(str2[temp]!='\0');temp++)
str1[i+temp]=str2[temp];
str1[i+temp]='\0';
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -