Hello Merlin, I'm desperate. Nothing works anymore
I'll show you everything I have now
1.MicroSD freshly formatted
My code on the computer, I get
1.EmpfStr = 'FileAssign'
2.EmpfStr = 'FileRewrite'
back, so everyone ok.
On the computer I step through all the lines from
the RichEdit that are sent and get 'ok' back every time
In my RichEdit I have 3 lines to send.
After writing, I immediately get an error while reading.
Error inserting a line in RichEdit
Procedure MMC_Write_File;
var
i : integer;
begin
MMC_Sende_Assign;
//warte bis 'open file' kommt
if EmpfStr = 'FileAssign' then
begin
MMC_Sende_ReWrite; //MMC_Sende_Append;
//warte auf FileRewrite
if EmpfStr = 'FileRewrite' then //antwort FileRewrite oder FileAppend
begin
//Jetzt sende die Zeilen
for I:= 1 to Form1.RichEdit1.Lines.Count do
begin //460=MMC_Block_Write
SendeStr:= '460' + Form1.RichEdit1.Lines[i-1]; //sende Daten
Form1.TCPClient.IOHandler.Write(SendeStr , IndyTextEncoding_ASCII);
EmpfStr:= Form1.TCPClient.IOHandler.ReadLn(IndyTextEncoding_ASCII);
//Stop ->EmpfStr 3 x 'ok' //<======= Stop check EmpfStr
end;
MMC_Sende_FileClose; //'ok'
ShowMessage('Fertig');
end;
end;
end;
From here the code in the Xmega 256A3U
//==============================
// Block Write
Procedure MMC_Block_Write; //460
Begin
EmpfStr:= EmpfStr + #13+#10;
www:= word(length(EmpfStr));
ptr:= @EmpfStr;
Inc(ptr);
if F16_BlockWrite(F, ptr, www, Res) then
if Res = www then
SendeStr:= 'ok'; Sende_an_Host;
else
SendeStr:= 'www no Res'; Sende_an_Host;
endif;
else
SendeStr:= 'Block Write ERROR'; Sende_an_Host;
endif;
end;
//=============================
//...Function F16_FileRewrite (f : File; [], aTime, aDate); >417<
Procedure MMC_File_Rewrite;
Begin
F16_FileRewrite(F,[], 0, 0);
SendeStr:= 'FileRewrite'; Sende_an_Host;
end;
//=============================
//...F16_FileAssign + F16_FileReset >413<
Procedure MMC_Open_File;
Begin
Fn:= EmpfStr; //FileName übergabe
if F16_FileAssign(F, '', Fn) then //
SendeStr:= 'FileAssign'; Sende_an_Host;
else
SendeStr:= 'ERROR open file'; Sende_an_Host;
endif;
end;
//=============================
//...MMC_Close_File >414<
Procedure MMC_Close_File;
begin
F16_FileClose(F);
SendeStr:= 'file close'; Sende_an_Host;
end;
I can read a 330KByte file without problems,
which I wrote on the micro SD on the computer.
Gruß Frank
I'll show you everything I have now
1.MicroSD freshly formatted
My code on the computer, I get
1.EmpfStr = 'FileAssign'
2.EmpfStr = 'FileRewrite'
back, so everyone ok.
On the computer I step through all the lines from
the RichEdit that are sent and get 'ok' back every time
In my RichEdit I have 3 lines to send.
After writing, I immediately get an error while reading.
Error inserting a line in RichEdit
Code
Procedure MMC_Write_File;
var
i : integer;
begin
MMC_Sende_Assign;
//warte bis 'open file' kommt
if EmpfStr = 'FileAssign' then
begin
MMC_Sende_ReWrite; //MMC_Sende_Append;
//warte auf FileRewrite
if EmpfStr = 'FileRewrite' then //antwort FileRewrite oder FileAppend
begin
//Jetzt sende die Zeilen
for I:= 1 to Form1.RichEdit1.Lines.Count do
begin //460=MMC_Block_Write
SendeStr:= '460' + Form1.RichEdit1.Lines[i-1]; //sende Daten
Form1.TCPClient.IOHandler.Write(SendeStr , IndyTextEncoding_ASCII);
EmpfStr:= Form1.TCPClient.IOHandler.ReadLn(IndyTextEncoding_ASCII);
//Stop ->EmpfStr 3 x 'ok' //<======= Stop check EmpfStr
end;
MMC_Sende_FileClose; //'ok'
ShowMessage('Fertig');
end;
end;
end;
From here the code in the Xmega 256A3U
Code
//==============================
// Block Write
Procedure MMC_Block_Write; //460
Begin
EmpfStr:= EmpfStr + #13+#10;
www:= word(length(EmpfStr));
ptr:= @EmpfStr;
Inc(ptr);
if F16_BlockWrite(F, ptr, www, Res) then
if Res = www then
SendeStr:= 'ok'; Sende_an_Host;
else
SendeStr:= 'www no Res'; Sende_an_Host;
endif;
else
SendeStr:= 'Block Write ERROR'; Sende_an_Host;
endif;
end;
//=============================
//...Function F16_FileRewrite (f : File; [], aTime, aDate); >417<
Procedure MMC_File_Rewrite;
Begin
F16_FileRewrite(F,[], 0, 0);
SendeStr:= 'FileRewrite'; Sende_an_Host;
end;
//=============================
//...F16_FileAssign + F16_FileReset >413<
Procedure MMC_Open_File;
Begin
Fn:= EmpfStr; //FileName übergabe
if F16_FileAssign(F, '', Fn) then //
SendeStr:= 'FileAssign'; Sende_an_Host;
else
SendeStr:= 'ERROR open file'; Sende_an_Host;
endif;
end;
//=============================
//...MMC_Close_File >414<
Procedure MMC_Close_File;
begin
F16_FileClose(F);
SendeStr:= 'file close'; Sende_an_Host;
end;
I can read a 330KByte file without problems,
which I wrote on the micro SD on the computer.
Gruß Frank