DEBUG OBJECT..a simple one..
denno
Posts: 223
OK...for over and I mean OVER 10 years, I have been a loyal user of the Basic Stamp, especially the BS2sx, with it's 8 program slots, and most of my apps, use all eight. Anyways, since, it would appear that Parallax is coming out with a Propeller, for embedded apps, like the stamp (self contained, if you will), I have decided that I would try and learn SPIN. I have been doing alot of homework, with various books, and tutorials from Parallax and the web. Certainly isn't as easy as PBASIC...but....
I have been using the Parallax Serial Terminal for DEBUGGING...BTW...The DEBUG function in PBASIC is really...really helpful. Keeping that thought in mind, Here is my question. Is there a simpler OBJECT that someone has written that would mirror the way the DEBUG works in PBASIC. In other works, Show the OBJECT for DEBUGGING in the TOP FILE, load the OBJECT in the COG of choice, so one knows where it is, then when writing the program, one could 'insert' a "DEBUG" phrase, which would open up the Parallax Serial Terminal...AND...ENABLE it, just like PBASIC. (Big pain in the ***, to have to ENABLE it everytime)..
Any thoughts from you SPIN masters?
DenO
I have been using the Parallax Serial Terminal for DEBUGGING...BTW...The DEBUG function in PBASIC is really...really helpful. Keeping that thought in mind, Here is my question. Is there a simpler OBJECT that someone has written that would mirror the way the DEBUG works in PBASIC. In other works, Show the OBJECT for DEBUGGING in the TOP FILE, load the OBJECT in the COG of choice, so one knows where it is, then when writing the program, one could 'insert' a "DEBUG" phrase, which would open up the Parallax Serial Terminal...AND...ENABLE it, just like PBASIC. (Big pain in the ***, to have to ENABLE it everytime)..
Any thoughts from you SPIN masters?
DenO
Comments
this is my usual approach:
I use the Parallax serial terminal object. It's more complex than the DEBUG (there is an object emulating DEBUG) but more flexible and powerful.
You simply have to set the baud rate and you are done.
On some boards there is a problem with USB serial connection with no cable connected, that causes chip reset.
OBC wrote a dummy version of the Parallax serial terminal, that I use as an alternative (it's just chamging the object name, one line and debug is disabled.
http://forums.parallax.com/attachment.php?attachmentid=70219&d=1273608817
With the propeller tool there are little alternatives. But you can use BST. Not sure if PropellerIDE already implements it...
https://lamestation.atlassian.net/wiki/display/PI/Downloads
Massimo
Thanks..Denno
Having a statements inside the program open and enable the terminal window isn't possible from Spin alone. You'd need your editing software modified to do this.
You can turn off the feature that disables the terminal when you select a different window. The problem here is you need to remember to "Disable" the terminal window before loading a new program. Windows won't let two programs access the same (virtual) serial port.
The ease of adding debug statements was the main thing I missed when I switched to the Prop from the BS2. It didn't take long to get used to using the various serial objects and they're so much more powerful than anything the Stamp could do. The program doesn't have sit and wait for serial input when using the Prop. This opens up a lot of possibilities.
I would appreciate any and all help on this...
DennO
Now open serial terminal with F12 and...
what I am wanting to do is monitor a changing variable using PST.dec(value) while the program runs on the Scott Edwards LCD. This is why I want to use the LCD display, instead of the computer screen via Parallax Serial terminal. This way, I do not have to constantly hit F12 and ENABLE.
I would appreciate any expert help on this..
dennO
To use code tags start with [noparse] [/noparse]. Your code will then appear formatted correctly (similar to JDat's code in post #9).
Tell us the expected output from the code and what the actual output is.
JDat's code includes an example of using the "Dec" method to display variables. The "Parallax Serial Terminal" object is very similar to the "FullDuplexSerial" object JDat used and the Dec method in both objects have similar output.
Port 1 for Propeller IDE (programming) or Propeller Assembly Sourcecode Debugger (PASD).
Port 2 for debug. Parallax Terminal or RealTerm.
Sometimes it ir really handy when You can press F11 on Propeler Tools to upload latest code and don't need to enable/disable/whatever do on terminal.
Port3 This port will work when everything will be finishet (production or DUT port).
On port 3 I connect connected Basic stamp/Bluetooth/PC program/Android/ZigBee/serial LCD/DMX etc.
It's sometimes handy when I can redirect Port3 to Port2. I can see on debug terminal what going on on production port and send data to system directly from debug port.
Really flexible system.
I've attached a simple serial (no cog required) driver for the Parallax Serial LCD -- it could be modified for other serial LCDs. This object has decimal formatting which I like.
One thing to keep in mind: DEBUG takes time out of your BS2 program loop. So will this object. Once you get a handle on using Spin and multiple cogs, what you can do is start a debugging cog that spits important data out a serial port (serial LCD or terminal). I do this all the time. Now, this only works for global variables (but a global can be a pointer to a method local [getting a little adnvaced]). The great thing is that the debugging output, once you've set it up, just happens when you run the program and does not interfere with your main loop timing.
True story: I developed a DMX product for a customer that used my debugging cog strategy. One day the customer called me and asked if I could add the ability for him to see the raw DMX values coming into the device. I said, "Sure -- just connect a PropPlug to the board, open PST, set it to 115_200, and then reboot." I needed that information to track things during development, and I left it in the code.
Hehe. Sounds really similar to my approach. Use "original" serial (pins P30,P31) for debug/firmware upload and add another serial port, if it is necessary for costumer project.
Maybe if the code tags were shown on the editor page people would find it easier to use?