Parallax Serial Terminal - Disable If Not Connected?
Mahonroy
Posts: 175
in Propeller 1
Hey guys,
I have a device that communicates with the Parallax Serial Terminal (PST) for debugging purposes. Most of the program executes sequentially, so when there is a lot of data/traffic occurring, the PST creates extra delay in various functions.
It got me thinking... if I don't have the USB prop plug connected, its still creating this same delay in my program isn't it?
If this is the case, would I have to have 2 separate programs (one for debugging, and one for production that has all of the PST stuff stripped out?)
How are you guys handling this?
Thanks and any help/advice is greatly appreciated!
I have a device that communicates with the Parallax Serial Terminal (PST) for debugging purposes. Most of the program executes sequentially, so when there is a lot of data/traffic occurring, the PST creates extra delay in various functions.
It got me thinking... if I don't have the USB prop plug connected, its still creating this same delay in my program isn't it?
If this is the case, would I have to have 2 separate programs (one for debugging, and one for production that has all of the PST stuff stripped out?)
How are you guys handling this?
Thanks and any help/advice is greatly appreciated!
Comments
Basically yes.
One alternative is to use a dummy serial driver. I've attached my version of "Parallax Serial Terminal.spin" which has all the methods but the methods don't do anything (except the "RxCount" method).
I use this as the RxCount:
This allow my "Press any key to start." beginning to keep the program from stopping.
The dummy methods still slow the program down a bit but not nearly as much as the original serial methods.
The Propeller Tool doesn't support conditional compilation but you can kind of fake it by using code like the code below.
In the above code all the serial calls would be executed but if I use "search and replace" and replace all the "{Start Debug CheckLogTimer}" text with "{{Start Debug CheckLogTimer}" and all the "{Debug CheckLogTimer End}" text with "{Debug CheckLogTimer End}}", then the serial calls are commented out.
This has the benefit of not only increasing the speed of the program but it also frees up the memory used by the code.
I have a list of these "Start" and "End" indicators listed at the bottom of my program. Here are a few examples:
I use this list with search and replace to either enable or disable debugging code. I can disable all the debugging code by replacing all instances of "{Start Debug" with "{{Start Debug" and replacing "End}" with "End}}". (I then have to replace some instances of "{{{" with "{{" and replace "}}}" with "}}".)
I'm not trilled with my techniques of enabling and disabling debugging code but I don't know of a better way of doing this using the Propeller Tool. I'd be very interested to learn what other techniques people use.
BTW, the serial object my examples use includes a lock. This is why there are calls to "Serial.Strs" and the like. "Strs" is method which both sets the lock and calls the normal "Str" method. Using locks like this allows me to use the serial driver from multiple cogs (and since all the variables are in the DAT section, I can use it from multiple objects).
-- Test that 5 volts is present, easy to do with an on-board FT chip but not with a Prop plug.
-- With a 4.99kΩ pulldown resistor on the rx line, test Prop pin p31. It will be low if the FTchip or Prop plug are not connected, and high when connected. A relatively low resistance pulldown (like 5k) is necessary.
-- By user input at reset
The serial interface and debug should be funneled through relatively few methods so that there need be only a few tests of the USB-present flag.
If the USB is not present the code can even shut down the serial port cog to save power. One has to be sure that there are no uncovered calls to certain serial methods that will lock up if the pasm is not running.
You'll also need to modify RxCount like so, to make it not return 0 every BUFFER_LENGTH-th byte:
Tracy,
With an on-board FTDI chip you can also (at the cost of an I/O pin) monitor the link status GPIO pin from the FTDI chip for connect status. I think I would do this is my program was more based on availability of the connection for more than just debugging.
Correct. CBUS3 defaults to PWREN#.
@Mahoney, on focus, I agree that substituting the dummy PST like Duane suggested in the first post could be the most carefree option. That is, so long as there aren't weird timing or other issues introduced by that very debugging or lack thereof!
Also, if there is no pull-up on Rx, connecting a 10K resistor between Tx and Rx will allow you to check for an echo on Rx. If there's an echo when you activate Tx, no PropPlug. Of course, without any pull-ups or Tx or Rx, the phantom reset becomes a problem.
-Phil
PhiPi phantom reset exposé
http://forums.parallax.com/discussion/comment/847328/#Comment_847328
I've always liked pull-ups on P30 and P31, since that's the default marking condition, and it cures the phantom reset -- but not in a very nice way. However, in the case of detecting the presence of a USB-powered FTDI device, a pull-down on P31 (and no pull-up on P30) is a clever way to do it. Thanks, Tracy! If you use that circuit, though, you have to be diligent not to activate P30 unless you detect the FTDI chip on P31, else the phantom reset will occur.
-Phil
I could be wrong, but I don't think the FT231X has that reset issue when energizing the RX line.