Serout command
leshea2
Posts: 83
How would I make sure that the serout command was putting out the text message that I wanted it to put out, could I use the debug command to check it ?
Thanks !
Thanks !
Comments
Sure, you might want to do this, during testing:
'SEROUT pin_port, baudmode, [noparse][[/noparse]"data = ", datum]
DEBUG "data = ", datum
When you're done, just comment out the DEBUG statement, and UN-comment the SEROUT.
Regards,
Bruce Bates
· #DEFINE TestMode = 1
And in your pin definitions do this:
· #IF TestMode #THEN
··· Sout··· CON··· 16
··· Baud··· CON··· T9600 + Inverted
· #ELSE
··· Sout··· CON··· 0
··· Baud··· CON··· T19K2
· #ENDIF
This will set the serial output to the programming port when TestMode = 1 (change to zero to set Sout to P0), and use the standard Debug baud rate of 9600 (inverted fro programming port).· The T19K2 constant is derived from a previous conditional-compilation structure that is included in my standard template·(posted several times).
When you use TestMode you'll need to manually open the Debug Terminal window and set the comm port.· By using this technique there is no possibility that duplicating your SEROUT parameters in DEBUG will introduce an error.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Kira DATA "Call Dave at 1-800-465-8563 at 4:30 on Tuesday", 0
Athrun VAR Word
ML VAR Word
Athrun = Kira
Main:
DO
READ Athrun, ML
Athrun = Athrun + 1
IF (ML = 0) THEN EXIT
SEROUT 3/4, 17405, [noparse][[/noparse]ML]
LOOP
END
Thanks !
·"My code" doesn't test anything. I only suggested an easy way to use EITHER SEROUT or DEBUG, as you were testing your program. For that matter, you can use SEROUT AND DEBUG if you wish. The example below shows that. If you don't want both, just comment out the one you wish not to use.
Kira DATA "Call Dave at 1-800-465-8563 at 4:30 on Tuesday", 0
Athrun VAR Word
ML VAR Word
Athrun = Kira
Main:
DO
READ Athrun, ML
Athrun = Athrun + 1
IF (ML = 0) THEN EXIT
SEROUT 3/4, 17405, [noparse][[/noparse]ML]
DEBUG ML
LOOP
END
Regards,
Bruce Bates
If you are looking for an example of how to send serial data, then you might be in interested in a project that I posted in "Projects":
http://forums.parallax.com/showpost.php?p=0
There·you find·Attached·a program called host_prj.bs1, it just reads some inputs and transmits a message, in ASCII (in an "endless loop".)
What are you sending your text message to (another STAMP, a lap-top)?· How are you doing it (direct connection TTL, via a RS-232 converter)?
Post Edited (PJ Allen) : 1/2/2006 11:10:44 PM GMT
Thanks !
As I see it, having "Christmas"·result on your Debug window is proof·only that the program got to a point in execution where the line was: DEBUG "CHRISTMAS".
You have this line in one of your previous posts: SEROUT 3/4, 17405, [noparse][[/noparse]ML]· The Slash ( / ) is wrong.· SEROUT 3, 17405, [noparse][[/noparse]ML] would send the value contained in the variable ML out of P3, serially,·at 2400, 8N1.· Similarly, SEROUT 3, 17405, [noparse][[/noparse]"Christmas"] would send the word Christmas out of P3, serially, (2400, 8N1).
***·I'll re-ask my questions·from my last post -- What are you sending your text message to (another STAMP, a lap-top)?· How are you doing it (direct connection TTL, via a RS-232 converter)? ***· It would really help for me to know.
[noparse][[/noparse] Does "Syntax Check" in the STAMP Editor allow a Forward Slash ( / )? ]
· Ordinarily, I don't use flow control of any sort, but sometimes RTS (Request to Send) is useful, i.e.·when I use a certain radio modem, it turns of its transmitter, saving power, when there is no RTS present.· [noparse][[/noparse] So, I turn on my RTS pin, then I SEROUT my data, and then turn the RTS off. ]
So, No, you don't "need" flow control.
Put this software on your PC, and you can see all communication to your comport.· I generally test my BS2 by doing a SEROUT to my PC, and making sure the signal is there with Comport toolkit.
You can also send signals from your PC to the BS2 to verify that your SERIN commands work.