Reading Serial
Chuck Minton
Posts: 45
I am trying to read a serial (rx) string. The string will be an occasional 7 char ASCII being sent over satellite that I will be receiving over pp13 .
Can't get past first base... Using FullDuplesSerial sending you give a value and that works, but receiving I can not compile if a variable follows FullDuplexSerial.rx (variable). So... I don't fully understand the function of a return variable as I read under PUB in the prop manual page 182: As FSD.rx:rxbyte is the actual format.
My question is how do we use "PUB Name : RValue " concerning :RValue. And, How do we access this information when it has been called by an object (the Return Value).
Appreciating any help,
Chuck
Can't get past first base... Using FullDuplesSerial sending you give a value and that works, but receiving I can not compile if a variable follows FullDuplexSerial.rx (variable). So... I don't fully understand the function of a return variable as I read under PUB in the prop manual page 182: As FSD.rx:rxbyte is the actual format.
My question is how do we use "PUB Name : RValue " concerning :RValue. And, How do we access this information when it has been called by an object (the Return Value).
Appreciating any help,
Chuck
Comments
· Mike B.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
I made the same mistake when I first used FullDuplexSerial.
wrong way:· FullDuplexSerial.rx(variable)
correct way:· variable := FullDuplexSerial.rx
Duane
Thanks Duane! you got it.
On the phone with my son and he just led me through the same thing....It works... I get streaming ASCII through my prop and onto parallax serial terminal!
Thanks so much , I just didn't get that an objects variable could be on the right hand side of the :=.
So Fun!
Glad I could help.· I find the checkrx method very useful.· Since FullDuplexSerial is running in its own cog, you don't need to sit and wait for data in your main loop, you can just check it every now and then (as long as its buffer doesn't fill up).
I use code like this a lot:
There is also and object called SimpleSerial·that doen't run in its own cog and so doesn't have a checkrx method.· I often use SimpleSerial in a dedicated cog·to listen to a serial port and set a flag indicating new data and have the main program loop check to see if the new data flag is set.· I'm still tring to figure out which of these two methods (no pun intended) work best.
Duane
Tnx. I am running this serial manipulation in a separate cog so this was not a problem, however, I can see it very valuable in some occasion. Plus it sounds like it buffers the string!?
I ran into a stumbling point yesterday: Read in a wanted set of ASCII> Each Character in a separate variable. Then wanted to compress into a single Word or Long....But could not figure that one out. Then I remembered seeing somewhere....(i.e. 3 letter word) : Take the first letters value multiply by 1M, then multiply the second letters value by 1K, and don't multiply the last.... then add them all together . After that I could do a single compare against predetermined value. I suppose if I use hex value I would only need to multiply by 100 each step.
My question .. is there a better way to stack ascii into a block so I could work with comparing "word" values??? I have gotten notice that I could not have more than 8 stacked "if" statements.
I posted some code in this thread that sets longs equal to the ASCII string.· I use two global variables leftDecimalMass and rightDecimalMass.· The method watches for a decimal to know when to start increasing the rightDecimalMass and stop increasing the leftDecimalMass.· Normally I'd use the pseudoreal number trick of having my decimal number multiplied by some power of 10 (in this case I'd use 10000 since I have four possible digits after the decimal), but I needed to keep track of the two sides of the decimal so they would display correctlly on my setup.
I decide to copy the code here.· I think I messed up the html tags in this post.
Make sure you look at FullDuplexSerial's dec method.· I use something like that method a lot when I need to transform a variable in to an ASCII string.
Duane
So, then I wanted to do some more experimenting with Parallax Serial Terminal (both object and program).
I set up this simple code... and I get what starts out to be normal characters reflected to the screen but then turn in to gibberish.
The strange thing is I have code I wrote 2 days ago and the PST works fine. Very confused!!! input a "g" and reflect a( "c"+a squiggly line under it )followed by a("Y"+ two dots over it). Tried different baud settings for naught.
Perplexed!!!!!
VAR
word SERDAT
OBJ
BUG:"PARALLAX SERIAL TERMINAL"
PUB TESTING
BUG.STARTRXTX (31,30,0,4800)
REPEAT
serdat := bug.charin 'waiting to grab byte of serdat from keyboard
bug.char(serdat) 'send var serdat to Parallax Serial Terminal program to view on monitor.
I've had the same thing happen to me many times.
One of the first things I try is closing PST and reopening it.· I also try reloading the program (F11) and then click "Enable" in PST.· If I'm still getting gibberish (and I've double check my baud settings) I reboot my PC.· I don't what can go wrong with a PC to mess it up but this often works (I had to do it today and it work fine afterwards).· This can be really frustrating sometimes.
Duane
did not get the Pll and cyrstal constants in ! Daaah~
eventually I hope to learn