Shop OBEX P1 Docs P2 Docs Learn Events
fsrw problems reading long file — Parallax Forums

fsrw problems reading long file

Paul_DlkPaul_Dlk Posts: 19
edited 2010-05-06 17:29 in Propeller 1
Hi,
I am using fsrw 26.I have declared an array of upto 3 fsrw objects.

One instance [noparse][[/noparse]0] is used to read 13 consecutive bytes at a time from a relatively large file (6.5MB). the first 12 bytes is the data and the 13th byte is a checksum. It works fine until it crosses a 32K boundary whereby it misreads the code and produces an incorrect checksum.
The second instance of fsrw is used to open one of three 'pointer' files in rotation in write mode, write a 32 bit number to it, close it and then open the next pointer file.
The third instance of fsrw is used to maintain a log file of any errors.

Any ideas on what I may be doing wrong or what may be causing the error on reading?

I have been able to read the same file using a single instance of fsrw.

Paul

Comments

  • rokickirokicki Posts: 1,000
    edited 2010-05-06 00:39
    This could well be a bug. Can you build a test scenario (that creates the files, then starts your test code that sees the incorrect data)
    that I can run to test from here? Ideally it would use only serial I/O and the SD card.

    Are you making all calls to fsrw from the same cog? (FSRW does not protect itself against calls from separate cogs and that
    could cause symptoms like this.)
  • Paul_DlkPaul_Dlk Posts: 19
    edited 2010-05-06 07:46
    OK, I'll throw together a test program and send to you, thanks for taking the interest.
  • Paul_DlkPaul_Dlk Posts: 19
    edited 2010-05-06 10:01
    @ Rokicki,

    The problem occurs if I open the large file (for read always), seek to a particular point and then continue to read from that point in 13 byte chunks without closing the file. Meanwhile the other small pointer files are being continuously opened, written to and closed in rotation.

    The problem disappears if I continuously open the large file, seek to the correct location, read the 13 bytes then close the file.

    I tried declaring a single instance of fsrw, opening the large file, seeking to the correct location and continue reading in 13 byte chunks from that location without closing the file. Withou using the other files.

    This ran without any problems which suggests to me that there is a bug in keeping a file open and reading past the 32k boundary whilst using multiple instances of fsrw. I assume this is due to the allocation used when formatting the card.

    I'll try to prepare a test program, but I'm under pressure to get a working solution as soon as possible. So I'll probably continue using the single instance for now.

    Regards and thanks

    Paul

    Post Edited (Paul_Dlk) : 5/6/2010 10:56:32 AM GMT
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-05-06 17:29
    Hi Paul,

    you could try the vMem addon I wrote for the FSRW. Then you'd only need 2 instances of FSRW, as it's possible to use the FSRW functions in parallel to the vMem functions without interference. The only precondition is that the big file you have has to be stored with all clusters being in a row. You simply have to format the SD card and copy that file as first file.

    You can find the vMem in this thread:
    http://forums.parallax.com/forums/default.aspx?f=25&m=401244&g=401357#m401357
Sign In or Register to comment.