Open file for read/write?
PaulF
Posts: 62
Hi,
I am trying to develop my first propellor application. The app needs to send upwards of 1 million 'commands' to a controller on a packaging line. The propellor needs to send the commands to the controller at a rate of at least 10 commands (each command is 11 bytes) per sec. I had originally planned to use a thumb drive via the VDrive unit. A text file containing the commands would reside in the thumb drive. I can get the propellor to easily achieve 20 codes per sec, however my problem is that I also need to keep track of the last code sent to the controller to enable the propellor to restart from the correct location in the file.
My solution to keep track of the last command was to either have a second file to which I write the index of the last command printed or else append the data to the file containing the commands. Either of these solutions introduces a considerable delay into the app., allowing me to send only 5 commands per sec. This delay is due to opening the file for read to get the command, then closing the file and reopening for write to write the index etc etc.
Another possibility is to write the index to the eeprom but this I believe would very quickly burn out the eeprom.
Is there any way to open a file for read and write?
Sorry for the long post, but I felt it would be helpful to present the whole scenario.
I am trying to develop my first propellor application. The app needs to send upwards of 1 million 'commands' to a controller on a packaging line. The propellor needs to send the commands to the controller at a rate of at least 10 commands (each command is 11 bytes) per sec. I had originally planned to use a thumb drive via the VDrive unit. A text file containing the commands would reside in the thumb drive. I can get the propellor to easily achieve 20 codes per sec, however my problem is that I also need to keep track of the last code sent to the controller to enable the propellor to restart from the correct location in the file.
My solution to keep track of the last command was to either have a second file to which I write the index of the last command printed or else append the data to the file containing the commands. Either of these solutions introduces a considerable delay into the app., allowing me to send only 5 commands per sec. This delay is due to opening the file for read to get the command, then closing the file and reopening for write to write the index etc etc.
Another possibility is to write the index to the eeprom but this I believe would very quickly burn out the eeprom.
Is there any way to open a file for read and write?
Sorry for the long post, but I felt it would be helpful to present the whole scenario.
Comments
Another easier option is to add a DS1307 or DS1302 real time clock to the unit. These have provisions for battery backup and have a small battery backed RAM included. You could just store the address of the restart point in this RAM. It's quick to do and it won't wear out.
Post Edited (Mike Green) : 3/28/2008 6:03:18 PM GMT
I will probably go with the DS1307 for the moment.