FSRW Trick?
JonnyMac
Posts: 9,194
At EFX-TEK we've added a uSD card option to our HC-8+ and our friend K.C. Oaks -- the author of Vixen (www.vixenlights.com) -- has created an export facility so that we can read and play files created by Vixen on the HC-8+ (or any other Propeller board with a uSD). Now we want to go the other way. The reason is that we have a customer who wants to do puppet animation in real-time from a VEX transmitter; this part is easy, I've already created a program that translates the VEX joystick data to servo outputs. What he'd like me to to now is save those movements to a file that can be imported to Vixen for modification.
Here's the rub: the Vixen data file has a 3-word header that holds the number of channels, the frame timing, and the number of frames. There is now way to know how many frames will be recorded so I wrote 0 to this. After recording the data I closed the file, re-opened it, then re-wrote the header with the frame count. The problem is that the file is now truncated just past the header -- I've lost the data.
Is there a solution (with FSRW -- not interested in any other SD card objects)?
Here's the rub: the Vixen data file has a 3-word header that holds the number of channels, the frame timing, and the number of frames. There is now way to know how many frames will be recorded so I wrote 0 to this. After recording the data I closed the file, re-opened it, then re-wrote the header with the frame count. The problem is that the file is now truncated just past the header -- I've lost the data.
Is there a solution (with FSRW -- not interested in any other SD card objects)?
Comments
Use pfillbuf as a model.
Too much of a hack?
Jonathan
Now you can just modify the first sector of the file to write your word. Something like that (assuming the 3 words in the header are 16bit values):
Andy
You could open the file you created then create a 2nd file with the new header and then rewrite the second file by reading back from the 1st. Kind of a kludge, but should work.
FSRW only allows one open file, otherwise this is what I would have done.
I tried append, seek to 0, rewrite the header. Seek doesn't work unless you're in the first sector of the file.
I've given up on this. My PC program will open the file and ignore the frames count in the header. It can determine frames in the file from the number of channels specified by the header and the number of bytes in file: (filebytes - 6) / channels.
Reopening the file in append mode causes seek to fail.
I don't want to do that when I can adapt my import program on the PC to deal with the problem. What I really want is a better SD object with the speed of FSRW and the ability to work with multiple files (two would make me happy). I'm kind of hoping that the SD support on the Propeller II will lead Chip down this path and he'll write such a beast (for the P1 and P2, of course).
Also here is a link to the seek-and-ye-shall-find thread corrected link where Tomas and Jonathan got the seek function working in version FSRW24, then came the date/time support. It is a very informative thread.
I think this is the correct link: http://forums.parallax.com/showthread.php?116391-FSRW-Walk-Right-Back-(seek-and-ye-shall-find)