I am trying to redirect the output stream to media (SD card). The manual describes the command to(MDA), which should do this operation, but I can't make it work.
My idea is to redirect the output of the file_Dir function to SD card and then read it back, one filename after the other. This is useful, if there are a lot of filenames and redirecting to a memory buffer would require a very large buffer. I was able to redirect the output to a file:
#platform "uLCD-32PT_GFX2"
func main()
var hFile;
while(!file_Mount()) putstr("SD?");
hFile:=file_Open("DIRRESUL.TXT",'w');
to(DSK);file_Dir("*.LOG");
file_Close(hFile);
endfunc
Redirecting to file works as expected, but it is rather slow and cumbersome. I tried redirecting to RAW:
#platform "uLCD-32PT_GFX2"
func main()
media_Init();
while(!file_Mount()) putstr("SD?");
media_SetSector(40,0);
to(MDA);file_Dir("*.LOG");
media_Flush();
repeat forever
endfunc
It appear that to(MDA) is simply ignored, as the output from file_Dir is displayed on the screen. The sector on SD card is unchanged. I have also tried the example for the to() function. The example correctly stores the data using media_WriteByte, but ignores the to(MDA);putstr().
Is to(MDA) redirection functional?
My idea is to redirect the output of the file_Dir function to SD card and then read it back, one filename after the other. This is useful, if there are a lot of filenames and redirecting to a memory buffer would require a very large buffer. I was able to redirect the output to a file:
#platform "uLCD-32PT_GFX2"
func main()
var hFile;
while(!file_Mount()) putstr("SD?");
hFile:=file_Open("DIRRESUL.TXT",'w');
to(DSK);file_Dir("*.LOG");
file_Close(hFile);
endfunc
Redirecting to file works as expected, but it is rather slow and cumbersome. I tried redirecting to RAW:
#platform "uLCD-32PT_GFX2"
func main()
media_Init();
while(!file_Mount()) putstr("SD?");
media_SetSector(40,0);
to(MDA);file_Dir("*.LOG");
media_Flush();
repeat forever
endfunc
It appear that to(MDA) is simply ignored, as the output from file_Dir is displayed on the screen. The sector on SD card is unchanged. I have also tried the example for the to() function. The example correctly stores the data using media_WriteByte, but ignores the to(MDA);putstr().
Is to(MDA) redirection functional?
Comment