Use PST from more than one module?
realjoshfreeman
Posts: 2
in Propeller 1
Hello all,
Fairly new to SPIN here, trying to improve an old project. I'm using Parallax Serial Terminal for program-flow debug, but I really need to be able to get debug out of a couple of modules used by the main program.
Clearly, I can't start multiple PST objects pointing to the same physical pins, and I can't call the parent object's methods that use the PST from within a sub-module. Any suggestions how best to proceed? Is there some way to extract a pointer to the started terminal object's TX buffer that can then be passed to a sub-module and used, or .... ?
Thanks for any help you may have to offer.
Fairly new to SPIN here, trying to improve an old project. I'm using Parallax Serial Terminal for program-flow debug, but I really need to be able to get debug out of a couple of modules used by the main program.
Clearly, I can't start multiple PST objects pointing to the same physical pins, and I can't call the parent object's methods that use the PST from within a sub-module. Any suggestions how best to proceed? Is there some way to extract a pointer to the started terminal object's TX buffer that can then be passed to a sub-module and used, or .... ?
Thanks for any help you may have to offer.
Comments
One way of debugging several cog modules is to use a background cog as a debugger.
JonnyMac has posted some examples of this strategy;
http://forums.parallax.com/discussion/comment/1483675/#Comment_1483675
It will take me a bit to find it. I'll get back to you later this evening.
I generally only use this version of PST while a program is in development. As macrobeak suggests, it's generally a better strategy to use a single cog for serial output.
But the top-level object also instantiates another original module in a separate .spin file, and the code in that module has timing problems needing some debug. I need that code to be able to access the same serial terminal in real time (A solution like having the sub-module store a string that the top-level main loop checks for and prints to the terminal won't help).
It's probably also worth mentioning that the project as it stands uses all eight cogs. So a debugging solution that requires an extra free cog won't help either.
I'm definitely interested in what Duane is describing. At the moment, I'm wondering if simply converting the sub-module code to another embedded cog might be a quicker way forward.
You only start this object once but you can include it in multiple objects and call it from multiple objects.
I noticed in this version I had commented out the normal Start method since I was likely using this with pins other than 30 and 31.
You'll want to uncomment out methods you need and you might want to comment out some of the added methods like PressToContinue and ReadableBin.
I added ReadableBin since it makes it easier for me to read binary numbers. The method displays the bits in groups of four.
SafeStr will output hex values for non-printable characters.
I noticed this version doesn't include any locks. If you have multiple cogs calling this method at once, the output can become gabbled. If you want to see a version with locks let me know.
I would...
I'll make a small demo program to illustrate how the various methods are used.
I'd like to include a child object and an ADC object would make a good example.
Do you have a Propeller Activity Board or a Propeller Board of Education? Or some other Propeller board I can use for the example program?
The demo shows how this version of the Parallax Serial Terminal object can be used from multiple objects and from multiple cogs.
I merged a couple different serial objects I use to make this version. One version used "Tx" to transmit individual characters while the other used "Char". I'm afraid the method names are not very consistent. You are of course encouraged to change the names of methods to suit your needs.
I used a QuickStart board when testing this program. It blinks the LEDs connected to pins 16, 17 and 18. You might need to change pin numbers if you use it with a different board.
Thank you, Duane. I got busy and didn't check back on the forum until today. I have numerous propeller boards, that I will try your example/demo on...