Confimation on sending strings
John Board
Posts: 371
G'day,
I'm in a bit of a hurry getting a robot ready for some comps, I would just like a quick confirmation that this is how you send a string from one prop to another using the FullDuplexSerialPlus (or extended FullDuplexSerial) object:
Sender:
Receiver:
I have tried this code on my platform, not appearing to work, I would appreciate if anyone could confirm that this is right,
John
[EDIT] I know that the 2-way props communication is secure as I have been able to send dec values easily.
I'm in a bit of a hurry getting a robot ready for some comps, I would just like a quick confirmation that this is how you send a string from one prop to another using the FullDuplexSerialPlus (or extended FullDuplexSerial) object:
Sender:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ Serial: "FullDuplexSerialPlus" PUB Main Serial.Start(rx, tx, 0, 115200) Serial.Str(String("This is a test")) Serial.tx(13) repeat
Receiver:
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ Serial: "FullDuplexSerialPlus" VAR long recv PUB Main Serial.Start(rx, tx, 0, 115200) Serial.RxStr(@recv) 'Do whatever with the string now repeat
I have tried this code on my platform, not appearing to work, I would appreciate if anyone could confirm that this is right,
John
[EDIT] I know that the 2-way props communication is secure as I have been able to send dec values easily.
Comments
a long (recv) to receive a string is a little short.
try a byte-array aka
VAR
byre recv[42]
so you have more space
Enjoy!
Mike
(Or however much, not necisarily 5)
?
Thanks for the response!
-John
you need a buffer to store the transmitted string.
on the sending side the String()-Function in Spin is doing this behind your back.
Enjoy!
Mike
Anyway, thanks again
Tried a few things, no prevail, I've attached master and slave code, the Master code is really in SlaveInterface.spin, you should see the Serial setup code and sending of the string at the top, and the code for the slave is in Slave.Spin
When I have the Recv var set to "long" (even if I have an array) it shows nothing on the LCD. If I have a byte array, it shows stuff, but it's purely random gibberish. Any help would be appreeciated. I am using the Parallax 4x20 backlit LCD, you can find the code in LCD.spin which is in the slave's archive.
Sorry for the lack of information, I'm on a tight schedule.
-John
Also, in the SlaveInterface start method you use a local variable temp which is evaluated (once) while uninitialised.
I think your refering to:
But I'm not sure if I understand. Although I haven't previously defined temp, it should start as "0", which is what I want. Then it continually recieves decs off the serial until it is "1", or the "Init Bit". Am I doing something wrong?
Thanks again,
Ohh, I also got it working! Would I be able to treat "@recv" like a variable string now? So, would I be able to do: strcomp(@recv, String("Test."))?
Thanks,
John