Serial Communication - Receiving a String
Snyggis
Posts: 14
This seems like a basic question, but I cannot find information in the documentation about how to receive a string through fullduplexserial. Anyone know how this is done, I was thinking of using Debug.getstr. I am also trying to read in decimal values, when using Debug.getdec - when I try to type in 9.8 on the terminal the propeller reads in 98. Thanks for the help, though I know rather basic.
Comments
exchange and it wasn't there, although there was another one called Extended Serial.
I'll have a look on my laptop later if no one else responds.
The PUB getstr(stringptr)
Gets zero terminated string and stores it, starting at the stringptr memory address
How do I determine where the stringptr memory address should be? As I am reading this new string in, should I look at my available memory in the Stack/Free and just address it to an opened spot?
Something like
byte mystrptr[noparse][[/noparse]80]
repeat
Debug.getstr(400)
if String(400) == "CPU10"
Debug.Str(String("CPU","10 ","Ready", 13))
Motor := Debug.getDec
if Motor == 1
First declare in the VAR section a byte array as I said above.
Then, you pass the address of that variable to getstr . Ex: getstr(@mystrptr)
then do a string compare; Ex: strcomp(@mystrptr,string("CPU10") ) Can't remember if strcomp is standard or requires a string object of some kind.
I'm not at my development computer so I'm just going from memory, but the above will get you closer than you already are.
For future reference, there's a how-to for getting started with the FullDuplexSerialPlus object in the textbook that comes with the Propeller Education Kit (Propeller Education Kit Labs: Fundamentals).··A .pdf of this book is included in·the Propeller Tool software's Help menu (v1.2.6 and newer), just click Help and select Propeller Education Kit.· Instructions and examples for using FullDuplexSerialPlus start in the Propeller Chip - PC Terminal Communication section starting on page 95 in the v1.1 textbook.· There's also a quick start example at forums.parallax.com· -> Propeller Chip·-> Propeller Education Kit Labs, Tools, and Applications·->·Propeller·<-> PC Terminal Communication.
On the next revision of the textbook, we'll be switching from FullDuplexSerialPlus to the Parallax Serial Terminal object.· I use it a lot.· In fact, when I start developing code, I just about always begin with a stripped down version of Parallax Serial Terminal Quick Start.spin.· It makes it really easy to display variable values at certain points during development.·
You can find the Parallax Serial Terminal Quick Start·object in the Propeller Tool software using File -> Open From -> Propeller Library - Demos.· There's also an object in the same folder named Parallax Serial Terminal Demo that shows how to use more of the Parallax Serial Terminal object's features.
Andy
P.S. @Snyggis, here's a link to a paper that might have some useful information.· It uses MATLAB and the Propeller control a robotic arm with a Wii Nunchuck.· .spin and .m code examples are in the appendices.
http://www.aaronklapheck.com/Downloads/MiniMover5/Final_Report_MiniMover5.pdf·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 11/29/2009 8:57:13 PM GMT