Shop OBEX P1 Docs P2 Docs Learn Events
FAT16/32 Full File System Driver help — Parallax Forums

FAT16/32 Full File System Driver help

FXFX Posts: 4
edited 2014-07-05 14:22 in Propeller 1
Hi, all

I have a problem with FAT16/32 Full File System Driver

this is the code

OBJ

sdfat : "SD-MMC_FATEngine.spin"
term : "FullDuplexSerial"

PUB main

' "fatEngineStart" is only called once. Either driver object can call it.
sdfat.fatEngineStart( _dopin, _clkpin, _dipin, _cspin, _wppin, _cdpin, {
} _rtcres1, _rtcres2, _rtcres3)


sdfat.mountPartition(0)

' Open serial to USB
term.start(31,30,0,115200)

term.str(string("Open file ..."))
term.tx(13)

sdfat.openFile(string("TEST.TXT"),"r")

repeat sdfat.filesize
r := sdfat.readByte
usb.tx(r)
FCV:=1
term.tx(13)

term.str(string("ok"))

repeat


if I try print in terminal a existing file in SD "TEXT.TXT" not have problem in terminal appear Open file ... OK and related contet

but if open a not existing file in SD example "AAAA.TXT" the code stops, in terminal appears only Open file ...

some suggestions?

Many Thanks in advance

Francesco

Comments

  • Heater.Heater. Posts: 21,230
    edited 2014-07-05 06:22
    FX,

    I am not sure because I have never used the FATEngine but I think it is possible that some methods in there are exiting with ABORT rather than RETURN. Quite likely openFile does this as it has no return value but must indicate failure in some way.

    If this is the case you will have to use it something like:
    if not \sdfat.openFile(string("TEST.TXT"),"r")
        term.str(string("Open failed!"))
    
    Do check the section on ABORT in the Propeller manual to see how this all works.
  • FXFX Posts: 4
    edited 2014-07-05 11:03
    Heater. wrote: »
    FX,

    I am not sure because I have never used the FATEngine but I think it is possible that some methods in there are exiting with ABORT rather than RETURN. Quite likely openFile does this as it has no return value but must indicate failure in some way.

    If this is the case you will have to use it something like:
    if not \sdfat.openFile(string("TEST.TXT"),"r")
        term.str(string("Open failed!"))
    
    Do check the section on ABORT in the Propeller manual to see how this all works.


    Hi, Heater

    Many Thanks

    I worked on your suggestion and I solved the problem, FatEngine pass result, so:


    OBJ

    sdfat : "SD-MMC_FATEngine.spin"


    PUB main | ErrorString

    ' "fatEngineStart" is only called once. Either driver object can call it.
    sdfat.fatEngineStart( _dopin, _clkpin, _dipin, _cspin, _wppin, _cdpin, {
    } _rtcres1, _rtcres2, _rtcres3)


    sdfat.mountPartition(0)


    ' Try to open file "TEST.DAT" (exsist)
    errorString := \sdfat.openFile(string("TEST.DAT"),"r")


    in errorString code return <TEST.DAT>


    ' Try to open file "AAAA.DAT" (not exsist)
    errorString := \sdfat.openFile(string("AAAA.DAT"),"r")

    in errorString code return <Entry Not Found>

    (this error message is present on SD-MMC_FATEngine.spin)


    Heater, again many many thanks

    Francesco
  • msrobotsmsrobots Posts: 3,709
    edited 2014-07-05 11:54
    if the file is not there you have to open it for write or append. (w or a not r)

    Enjoy!

    Mike
  • FXFX Posts: 4
    edited 2014-07-05 14:22
    msrobots wrote: »
    if the file is not there you have to open it for write or append. (w or a not r)

    Enjoy!

    Mike

    Mike,

    but I am writing code interactive with terminal, at the prompt the request to read also can be made to a not existing file, that was the question

    bye

    Francesco
Sign In or Register to comment.