How to self replace a program in BS2 ?
dinocog
Posts: 3
Hello all, i've read the Application Note #16 of BS1 about self replacing program. I know that the BSAVE command is no more supported by the 1.33 editor and i can create an obj file from the editor. I think that the file created by the editor cannot be used from a program language that read the bytes from the file and send them to BS2. So, how can overvrite a runnig program with another from the PC ?
Thank in advance, Dino
Thank in advance, Dino
Comments
·· The new editor supports creating a Stand-Alone module that can re-program any of our BASIC Stamp modules, as long as properly connected to the PC.· That is, you will need a serial connection, with the BS1 adapter connected to the host PC to run the module.· Simply select Generate Stand Alone EXE from the Generate Object Code... window.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I imagine a bs2 program that run and under certain occurrences talks with a PC program (in my case a LabView program) that reads a BS2 object file from disk and sends the tokens to bs2 in such a way that the second program overwrite the first.
This is how the #16 Application Note seems to function (if i correctly understand).
I don't know how to use the object file created by the editor with Generate Object Code..., with my Labview program. I see that the dimension of the file is more large of what the BS2 can use. I suppose that inside the obj file created by the editor there are a lot of informations that are not directly connected to the BS2 tokens.
Thank very much for the answer.
Dino
·· I see now that you are trying to do a trick from the BS1 on the BS2.· The fact is, at the time the App Note was written, the BASIC Stamp 1 could only be programmed through the LPT port, so this trick was a neat way to get data to the BS1 through the Serial Port without a loader.· However, if you notice the start code on both programs had to be the same.· With only 256 bytes of EEPROM this would also seriously bite into an already small program space.
·· Now, on the BS2, you could probably do something similar, but what I would recommend instead would be to use a Stamp Module, such as the BS2sx or BS2p which have 8 different program slots.· You could write the different programs in different slots, and use serial data to help transfer program control from one slot to another.· This would probably be the easiest way to go about getting similar results.
·· If there's a need to alter DATA within the program, that's much easier to do via serial than changing the entire program without the Stamp loader.· One more thing to consider about the original idea...The Stamp still needs to be connected to a PC, and so in that case you really could still just use a stand-alone Stamp Loader, unless there's something else specific you're trying to accomplish.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Another approach would insert a little loop in your programs, invoked with a special pin state or secret RS232 command, that READs the tokens from the 2k of memory and transmits them back to your PC, where you capture them in a file. Then go the other way, like app note #16, to overWRITE a running program with a new one.
It is especially easy with the BS2p, pe, or px, which have the STORE command that allows you to READ and WRITE data into one bank from a program running in a different bank. So a program running in bank zero can READ and transmit back all the program bytes in bank 1 to labview, or vice versa, it can WRITE them and then RUN the new code. I've used that technique over a modem link.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Many thank, dino