Shop OBEX P1 Docs P2 Docs Learn Events
How to read/load a program FROM the BS2 controller TO the editor. — Parallax Forums

How to read/load a program FROM the BS2 controller TO the editor.

Tom HoweTom Howe GuestPosts: 9
edited 2011-08-07 15:01 in BASIC Stamp
This question may have been asked before, if so, please link me to the sovled answer if there is one.

How do I know what program is already in my BS2 controller? Is there a special read or load program I need to write to recall what is already in the BS2? I have not found a way to do this in PBasic 2.5.2 yet.

From what I have been reading, it is just a matter of keeping track yourself or re-complying what you want done. I do keep good backups of the code I have already written, I just curious how someone could do what I am asking. Thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-01 15:34
    You haven't been able to find a way to read a program from a BS2 to the editor because you can't do it in any realistic way. The program is stored in compiled form in the BS2's EEPROM. Although it's possible to read the EEPROM using the READ statement, it requires that you have a program running in the BS2 that will do it. Any program you send to the BS2 to READ the rest of the EEPROM will overstore part of the existing program, thus making it impossible to read the entirety of what's there. If you're willing to possibly destroy the BS2, you could remove the EEPROM from the module and read its contents using some other controller or commercial EEPROM programmer/reader since the the EEPROM is a standard one.

    If you were to read the program from the EEPROM, it still wouldn't help you since the program is in compiled form and all of the labels and variable names are gone. Some of the statements, like those in PBasic 2.5, have been translated into simpler operations, so some of the structure is gone. You would also need to decode the compiled program and there is no documentation available that describes how to do this.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-08-01 15:39
    If it's critical to know, from now on, add a DEBUG "Ver. xx.xx" statement at the start of the program.
    That'll keep you on your toes.
  • Tom HoweTom Howe Guest Posts: 9
    edited 2011-08-01 20:15
    To Mike Green: I had suspected this the case but was not sure. Thank you for clarifying for me. I am new to the BS2, not at all like the other controllers (Allen Bradley MicroLogix and Johnson Control DX-9100s) I program at work. They are a great little chip but not all that robust. I figured if the BASIC Stamp Syntax and Reference Manual didn't discuss this in the Windows Editor portion it either couldn't read/load or it was so incredibly easy that once I discovered how I would face palm myself. :)

    To PJ Allen: If there was more memory available, I would have a debug statement reflect what the program was. I see the "What's a Microcontroller?" manual does this but am a touch resistant to this with just the BS2 chip. Thank you for your idea though!!
  • Jimmy LiebJimmy Lieb Posts: 46
    edited 2011-08-02 18:55
    Tom Howe wrote: »
    To PJ Allen: If there was more memory available, I would have a debug statement reflect what the program was. I see the "What's a Microcontroller?" manual does this but am a touch resistant to this with just the BS2 chip. Thank you for your idea though!!

    That is a very simple command, it really wont take up very much memory. If you haven't, maybe check out the memory map in the editor. it could give you some good perspective.

    ~Jimmy
  • Tom HoweTom Howe Guest Posts: 9
    edited 2011-08-03 10:31
    Jimmy Lieb wrote: »
    That is a very simple command, it really wont take up very much memory. If you haven't, maybe check out the memory map in the editor. it could give you some good perspective.

    ~Jimmy

    I'll take your suggestion up this weekend when I have some time to experiment with different sized debug statements, thanks!!
  • Jimmy LiebJimmy Lieb Posts: 46
    edited 2011-08-03 15:21
    Tom Howe wrote: »
    I'll take your suggestion up this weekend when I have some time to experiment with different sized debug statements, thanks!!

    Alright, I hope it works out! If you have any more questions just let me know!
  • ercoerco Posts: 20,256
    edited 2011-08-04 17:08
    PJ Allen wrote: »
    If it's critical to know, from now on, add a DEBUG "Ver. xx.xx" statement at the start of the program.
    That'll keep you on your toes.

    Good call, PJ. For that matter, if you have lots of extra EEPROM space, your program could initially send (via DEBUG) a text listing of every single line of your BASIC program, or just the tokenized version if you don't want people reading your code. That would allow anyone to duplicate the program. And they'll tell two friends, and so on...
  • Jimmy LiebJimmy Lieb Posts: 46
    edited 2011-08-04 18:11
    wow, I never thought about that! I might try that too, for simpler programs. As long as everything is saved in one central location, and you don't change names around, I think this could be overkill. I might still try that though. Good idea, Erco!
  • ercoerco Posts: 20,256
    edited 2011-08-05 08:44
    Another thread here lamented the fact that the Stamp fills up alarmingly fast when a lot of DEBUG statements with text are used, since there's no compressing the text. If so, that technique I suggested may only work with a very small program, as the DEBUG listing will consume far more space than the program will.
  • RDL2004RDL2004 Posts: 2,554
    edited 2011-08-05 14:33
    I do something similar to what PJ Allen suggests. I use DEBUG with the actual file name, such as DEBUG "gadget1v51211B.bs2". It really won't use that much program space in the Stamp.
  • Tom HoweTom Howe Guest Posts: 9
    edited 2011-08-07 15:01
    After playing with the memory map and reading some more on the BS2 chip specs, this is what I found. Using a debug command is a great way to remind yourself what is already loaded in the BS2. Provided you stay on top of your documentation and your programs are not so large to consume most or all of your EEPROM memory, I would recommend this method.

    I would like to thank all who replied, it helped steer me in the right direction!!

    As a side note. Most of the debug statements I used testing amounts of EEPROM memory use, I average about 30-35 bytes. Since the BS2 has 2K bytes of EEPROM, that's not really a large amount. The RAM of the BS2 is unaffected of course. It is used solely for I/O and variables.

    Finally, if someone could please tell me how to change the UNSOLVED to SOLVED in the title to this threat, I would greatly appreciate it! :cool:

    Tom
Sign In or Register to comment.