Fseek query

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Fseek query

Post by Francis » Tue Jul 07, 2009 2:33 pm

I'm just trying Steve's excellent SD utilities. I've downloaded latest version from Wiki.

I'm using an 1825K20 @ 10MHz on a home made PCB with SD card socket.

I've been reading files on an SD without any problem until I come to use Fseek.

If I open a file using SD.OpenFileRW(...) then I can set pointer and read absolutely fine.
But if I open using SD.OpenFile(..) I get problems.

The .pdf Help file suggests that using OpenFile(..) is OK but if use Fseek and try and read a byte I get strange error.
e.g.
If I Fseek to, say, position 1 (no error from Fseek) and then read a byte it returns an EOF error number.
or
If I Fseek to,say, pos 1 (no error from Fseek) and then Fseek again I get errRWError returned from Fseek function.

THEN, I have to initialise the SD again to do any more open / reads from the File.

It only happens if using OpenFile, using OpenFileRW is fine.

Summary.
OpenFile for normal reading is fine.
OpenFileRW for normal reading is fine.
OpenFile and then using Fseek gives problems.
OpenFileRW and then using Fseek is fine.

Obv I can use OpenFileRW and I notice the .pdf help file looks a bit out of date.

Is there something different I should do if using OpenFile() and using Fseek? (it would be nice to open as read only and be able to do Fseek).

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Supplemental

Post by Francis » Tue Jul 07, 2009 2:56 pm

Odd.
If I first open with OpenFileRW then close and then re-open with OpenFile all Fseek operations a re fine.

But if the first operation is OpenFile() then it does its funny thing.

Is something Fseek-related set by OpenFileRW which makes it function OK with subsequent OpenFile() ?

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Tue Jul 07, 2009 4:14 pm

I'll have to look at this one - thanks for spotting it.

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Post by Francis » Tue Jul 07, 2009 5:57 pm

Thanks.

Post Reply