Hugh
07-11-2009, 10:49 PM
Folks,
I'm trying to write to an SD card using the excellent fsrw object, but am having some problems.
OBJ
sdfat : "fsrw"
lcd : "LCD"
VAR
Byte mode, index, fast, tRef, recData[100] , AnsaA [25], tbuf[20], r, sta
long txDisp, units , AnsaB, Ansa, stack1[20], stack2[20], stack3[20]
pub main
waitcnt(80_000_000 + cnt)
sdfat.mount(00)
AnsaA:=string("Test") ' What I am trying to write to the SD card
lcd.cls
if r ==0
lcd.str(string("Mounted."))
waitcnt(240_000_000 + cnt)
sdfat.opendir
repeat while 0 == sdfat.nextfile(@tbuf)
sta := cnt
else
lcd.str(string("Failed!"))
sdfat.popen(string("Data1.csv"), "a")
repeat 500
ct :=0
' repeat 20
' sdfat.pputc(AnsaA[ct++]) This didn't work
sdfat.pwrite(@AnsaA,25)
sdfat.pputc(13) 'Carriage Return
sdfat.pclose
What I get is a file with 500 "œ" characters, each with 25 spaces before them. I'm obviously making a fundamental mistake here, but can't see the wood for the trees.
Any suggestions / pointers would be gratefully received - I have been through the 'insert SD card - turn on Prop - upload code - wait for it to mount / write - turn off Prop - remove SD card - insert SD card in PC - open file - close file - alt-tab to Prop tool - change code' loop so many times now!
Many thanks,
Hugh
P.S. Its an OBD code reader for my Saab that shows live data on an LCD display - I want to log one or two parameters to SD every couple of seconds.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
I'm trying to write to an SD card using the excellent fsrw object, but am having some problems.
OBJ
sdfat : "fsrw"
lcd : "LCD"
VAR
Byte mode, index, fast, tRef, recData[100] , AnsaA [25], tbuf[20], r, sta
long txDisp, units , AnsaB, Ansa, stack1[20], stack2[20], stack3[20]
pub main
waitcnt(80_000_000 + cnt)
sdfat.mount(00)
AnsaA:=string("Test") ' What I am trying to write to the SD card
lcd.cls
if r ==0
lcd.str(string("Mounted."))
waitcnt(240_000_000 + cnt)
sdfat.opendir
repeat while 0 == sdfat.nextfile(@tbuf)
sta := cnt
else
lcd.str(string("Failed!"))
sdfat.popen(string("Data1.csv"), "a")
repeat 500
ct :=0
' repeat 20
' sdfat.pputc(AnsaA[ct++]) This didn't work
sdfat.pwrite(@AnsaA,25)
sdfat.pputc(13) 'Carriage Return
sdfat.pclose
What I get is a file with 500 "œ" characters, each with 25 spaces before them. I'm obviously making a fundamental mistake here, but can't see the wood for the trees.
Any suggestions / pointers would be gratefully received - I have been through the 'insert SD card - turn on Prop - upload code - wait for it to mount / write - turn off Prop - remove SD card - insert SD card in PC - open file - close file - alt-tab to Prop tool - change code' loop so many times now!
Many thanks,
Hugh
P.S. Its an OBD code reader for my Saab that shows live data on an LCD display - I want to log one or two parameters to SD every couple of seconds.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.