Full Duplex Serial
172heavy
Posts: 55
I am new to the prop so please excuse this basic question, I have been experimenting with the full duplex serial and I have figured out how to send data to a terminal program, my question is this, How is this object designed to recieve and store data? If I want to receive a string or dec or whatever what needs to be done? Where do I store it? I am assuming I need a variable but how do I point the received byte(s) to the variable?
Thanks in Advance
Josh
Thanks in Advance
Josh
Comments
You might take a look at the pages starting around pp. 95-100, 103, etc, of the free downloadable PE Labs Fun book:
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PELabsFunBook-v1.1.pdf
hope that helps,
variables in SPIN are bytes (8bit), words (16bit) or longs (32bit).
FullDuplexSerial (short FDX) works with bytes
So for receiving a single byte you have to declare a bytevariable
If you want to receive strings you have to declare an array of bytes
ATTENTION! Your bytearray has to be one byte longer than your maximum
stringlength you want to receive. In the last byte a zero is stored to indicate the end of the string
So called zero-terminated strings.
If you want to access single bytes of this string the index starts at zero
for receiving strings you should use FullDuplexSerialPlus
which provides a method "getstr"
that alreday does the details of receiving the bytes
The parameter is a long that points to bytearray
@the forum:
I don't have example-code for receiving strings handy
can someone post a working example?
best regards
Stefan
Nevermind, I found it........
For Example if I have a string if data coming in like this,
$GMRMC,1234.555,N,1234,5555,W Etc........ If I only want to save the first "1234" how can I do this if I want to count 7 characters and then capture 4
PUB rx : rxbyte
'' Receives byte (may wait for byte)
'' rxbyte returns $00..$FF
repeat while (rxbyte := rxcheck) < 0
I can do this using my BS2, but I wanted to try to move up to the PROP.........
First off, I love the name... But I guess only pilots would get it. ;-)
Second, there is another object in the OBEX that does exactly what you are looking for. It's called GPS_IO. It uses FullDuplexSerial and adds specific parsing functions for handling NMEA strings.
I've modified it for several other string parsers, which is quite easy to do once you see how it works.
Bill
Thank you, I appreciate the compliment and the advice. I like your picture by the way, what are you flying?
I have checked the OBEX and I cannot find the GPS_IO do you have a copy you could email to me or do you know where it is? It looks like there are several other Objects that will help though.
Thanks
Dave, that is exactly what I was looking for! You and Bill have been a great help!
Is that a tail number I spot on your sig line?
I believe that is a ham (amateur radio) callsign. You'll find many hams hanging around in this forum.
Steve