Can someone give m a pointer re SD

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

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

Can someone give m a pointer re SD

Post by Francis » Sun Apr 15, 2007 9:52 am

Hi,

Is it possible to set a pointer (on an SD card) before a readbyte/word command or do I have to do X Readbytes to get to my target byte?

I was hoping to use an SD file as a sort of DataBase and would like to get to the target byte as rapidly as possible.

Thanks.

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

Post by Steven » Sun Apr 15, 2007 2:07 pm

Francis,

At present, you cannot set a pointer and must read the required number of bytes from the start. However, your requirement is a good one and it shouldn't be too difficult for me to implement and add to the library for you.

Would the following be OK in outline:

i) a command to skip a certain number of bytes (performed much faster than reading this many bytes directly),
ii) a further command to set the pointer at a specific position - if this is past the current position, it will perform a skip as above, but if it is before the current position, it will have to start again at the beginning of the file and skip to the right position from there.

How urgently do you need this?

Regards,

Steven

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

Post by Francis » Sun Apr 15, 2007 2:18 pm

Steven you are approaching deity status rapidly. :D

No super hurry and your proposed ideas are spot on.

Many thanks in advance.

Francis.

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

Post by Steven » Sun Apr 15, 2007 3:03 pm

OK. Do you just read from the file, or is there a need to update info that is already in the file?

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

Post by Francis » Sun Apr 15, 2007 6:35 pm

Steven,

Yes, sorry, well spotted. It would be preferable to write and/or read byte after setting pointer. And probably read and write word too.

As I didn't know anything about the nitty-gritty I simply assumed you could set the pointer then read/write next byte/word.

Kind Regards,

Francis.

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

Post by Steven » Sun Apr 15, 2007 6:40 pm

I'll have to think about this one carefully. It's something I have thought about doing before, but cried shy of it. Currently you can read OR write, but not both - you open a file for one or the other. Adding the ability to do both is possible, but will require some careful coding so that the file is extended properly if writing occurs at the end etc... I'll have to streamline some of the existing code first, which will be no bad thing, but it will then need careful testing. I'll give it some thought...

Steven

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

Post by Francis » Sun Apr 15, 2007 8:11 pm

Sorry Steven,
I (through ignorance) hadn't appreciated the complexity.

Something like:-

Open for reading
Set pointer
Read Byte/Word
Close
Open for writing
Set pointer
Write Byte/Word
Close


is fine, no need for both at once.

And yes (I know) its easy for me to say.
As it sounds like a big job then put it in the suggestion box for a rainy day. No hurry and no worry.

Regards.

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

Post by Steven » Sun Apr 15, 2007 8:21 pm

No appologies necessary. For completness of the library, it's something that I was hoping to do anyway. It just needs someone with a need for such a option to spur me into action. I'll make no promises on how fast I get it done, but definitely consider it in the suggestion box.

Steven

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Tue Apr 17, 2007 3:03 pm

Steven, I have a couple of apps that could use this feature if you need extra incentive.
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

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

Post by Steven » Tue Apr 17, 2007 5:11 pm

I had been thinking about your app already where you update a config file on an SD card. I am unlikely to make the changes to the PDS version, since it's quite complex, but conceivable in the Swordfish procedural language. If this is of use to you, then great. I'll consider it extra incentive. I've not started re-writing it yet, but I am now working through some ideas.

Regards,

Steven

Post Reply