Author Topic: uFileWrite  (Read 11649 times)

Offline hervé

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
uFileWrite
« on: October 07, 2009, 10:16:34 AM »
Does there is any way to have a fseek function on uFileWrite ?
like SubFile with SUB_FILE_SIZE = 1 ....

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: uFileWrite
« Reply #1 on: October 07, 2009, 03:41:20 PM »
Hi Hervé

There is no fseek() function.

MEMORY_RANGE_POINTER ptrThisFile = uOpenFile(cFile); The open returns a pointer to the start of the file (this is actually pointing to the header of the file and so the data starts at an offset of FILE_HEADER bytes from it).

uGetFileLength(ptrThisFile) returns the content length, so the end of the file is at (ptrThisFile + uGetFileLength(ptrThisFile) + FILE_HEADER)

When a write is in progress (only one file can be written at a time) there is an internal variable counting the number of bytes saved but this is not accessible from outside the file.

Could you explain why you would like to have an fseek() type function?

Regards

Mark


Offline hervé

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: uFileWrite
« Reply #2 on: October 07, 2009, 04:27:56 PM »
Hello Mark,
I planned using some database code source with SPI eeprom using µfileSystem.
It look quite good with the simulator, but I got problems with writing to file.
The code reads from a file using fseek (in a tempory buffer) then performs some write with fseek too....
Here  is some debug value : at the end the dump shows the data were written but sequentially...

Seek<>length:value
         from here reading with seek
@0000<=0200:
@0200<=0200:
@0400<=0200:
@0600<=0200:
@0800<=0200:
@0a00<=0200:
@0c00<=0200:
@0e00<=0200:
         from here writing with seek
@0028=>0008:€
@0000=>0008:JL
@0028=>0008:€
@0008=>0002:€€
@000a=>001e:€™address[name:S,country:S]‚ˆ
@0030=>0008:€
@0000=>0008:JL
         Commit 1
@0085=>0008:€
@0000=>0008:JL
@0085=>0008:€
@0038=>0018:John Williams
@0050=>0001:®
@0051=>0009:UK
@005a=>0001:c
@005b=>000c:€‚˜¸Ð€‰ÑÚ€
@0067=>001e:€™address[name:S,country:S]ŒÛ
@008d=>0008:€
@0000=>0008:JL
         Commit 2

#dump
 DUMP myfile.dat
00000000:80 00 00 00 00 00 00 28 4a 4c 1a ff ff ff ff ff    €
00000010:80 00 00 00 00 00 00 28 80 80 80 99 61 64 64 72    €
00000020:65 73 73 5b 6e 61 6d 65 3a 53 2c 63 6f 75 6e 74    ess[name:S,count
00000030:72 79 3a 53 5d 81 82 88 80 00 00 1e 00 00 00 0a    ry:S]‚ˆ€
00000040:4a 4c 1a 00 00 00 00 38 80 00 00 00 00 00 00 85    JL
00000050:4a 4c 1a 00 00 00 00 95 80 00 00 00 00 00 00 85    JL
00000060:4a 6f 68 6e 20 57 69 6c 6c 69 61 6d 73 00 50 61    John Williams
00000070:63 6f 20 50 65 6e 61 00 ae 55 4b 00 53 70 61 69    co Pena
00000080:6e 00 63 80 82 98 b8 81 d0 80 89 d1 81 da 80 80    n
00000090:99 61 64 64 72 65 73 73 5b 6e 61 6d 65 3a 53 2c    ™address[name:S,
000000a0:63 6f 75 6e 74 72 79 3a 53 5d 81 8c db 80 00 00    country:S]ŒÛ€
000000b0:1e 00 00 00 67 4a 4c 1a 00 00 00 00 95

#

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: uFileWrite
« Reply #3 on: October 08, 2009, 06:07:59 PM »
Hi Hervé

I don't understand exactly the problem but it may be best to work with low level FLASH commands, rather than uFileSystem routines. See page 11/18 of the following document: http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF

With these routines you may be able to control the writing better in your application.

Regards

Mark