Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi

Anyone has a suggestion why:
nRet = IFILE_Write(pWa->pIFile, pWa->m_pChunk, pWa->m_nbLen);returns nRet != pWa->m_nbLen; but different from zero (indicating a success). I cannot find in the docs, but does this mean I should repeat IFILE_Write() operation until whole buffer is written? Right after that writing, IFILEMGR_GetLastError() returns zero, too.

Thanks.

yes, you need to repeat IFILE_Write() until it is all written. The return value of the function is "Number of bytes written, if successful. 0 (zero), if unsuccessful.".. So you will need to write the rest of the buffer.
If it is a large file, you will probably have use a timer or some other type of callback to loop writing until the write is complete.. because of the watchdog on the device.
-Tyndal

yes, you need to repeat IFILE_Write() until it is all written. The return value of the function is "Number of bytes written, if successful. 0 (zero), if unsuccessful.".. So you will need to write the rest of the buffer.
If it is a large file, you will probably have use a timer or some other type of callback to loop writing until the write is complete.. because of the watchdog on the device.
-Tyndal

When you do IFILE_Write, if you do file I/O frequently then
1. Don't use too small or too big buffer.
2. It is best to use buffer size in the range of 2-4K to get optimal performance
ruben

When you do IFILE_Write, if you do file I/O frequently then
1. Don't use too small or too big buffer.
2. It is best to use buffer size in the range of 2-4K to get optimal performance
ruben

Thank you very much for this hints. I'm now using writing in chunks of 4KB.
There is a followup question:
At some point File Manager returns 262 error (0x106 = EFSFULL). I don't quite undrestand why is that, because after that, I still can upload (copy) several binary files to the phone using BREW AppLoader, and they get copied into subdirectories of the app, without any warnings/issues.
Related to this: once when created, File Manager saysdwFree = IFILEMGR_GetFreeSpace(pWa->pIFileMgr, &dwTotal);
DBGPRINTF("FREE FS: %lu TOTAL FS: %lu", dwFree, dwTotal); FREE FS: 23242 TOTAL FS: 3081082, which means that I have 3MB free, and 23KB "currently available." I don't quite understand this. Does anyone know how to explain this? It's a real device (VX6000), already activated on the Verizon's network.
Thank you again.

Thank you very much for this hints. I'm now using writing in chunks of 4KB.
There is a followup question:
At some point File Manager returns 262 error (0x106 = EFSFULL). I don't quite undrestand why is that, because after that, I still can upload (copy) several binary files to the phone using BREW AppLoader, and they get copied into subdirectories of the app, without any warnings/issues.
Related to this: once when created, File Manager saysdwFree = IFILEMGR_GetFreeSpace(pWa->pIFileMgr, &dwTotal);
DBGPRINTF("FREE FS: %lu TOTAL FS: %lu", dwFree, dwTotal); FREE FS: 23242 TOTAL FS: 3081082, which means that I have 3MB free, and 23KB "currently available." I don't quite understand this. Does anyone know how to explain this? It's a real device (VX6000), already activated on the Verizon's network.
Thank you again.

BREW tries to maintain pool of free space in the file system by erasing the older deleted files. Whenever you try to write file in the filesystem, it checks the free pool, if the pool is empty then BREW will try to initialize/erase any free space available and try to write file. This is also the reason why file write of same sized buffer may take different time duration.
Please note that till BREW 2.1 file write is synchronous, whereas in BREW 3.0 file write is asynchronous.
ruben

BREW tries to maintain pool of free space in the file system by erasing the older deleted files. Whenever you try to write file in the filesystem, it checks the free pool, if the pool is empty then BREW will try to initialize/erase any free space available and try to write file. This is also the reason why file write of same sized buffer may take different time duration.
Please note that till BREW 2.1 file write is synchronous, whereas in BREW 3.0 file write is asynchronous.
ruben