Help with code running in 2 cogs
MacGeek117
Posts: 747
I'm trying to figure out what's wrong with my serial protocol, and I've narrowed the first problem to a recieve function. When I have it in the main program (see Comm Test 1) it works fine, but when I try to put it in a separate cog (see Comm Test 2), it malfunctions, spitting out garbage characters.
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
Technologically challenged individual, Please have pity.
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
JMLStamp2p
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
When I try to open your sample code it fails. It sounds like we are trying to accomplish the same thing and could probally help each other.
JMLStamp2p
PS: I am using two props and two trancievers to communicate between each other for a timer circuit at our industrial plant. Could use some help :>)
I have posted the most recent code.
The green LED is there to let me know if the receive cogs detects the slave. It never lights up!
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
For some reason I cannot open your code, could you save it as a text file and send it to
JMLStamp2p@aol.com
Thanks,
John.
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
·
Let me run over your code to begin with to make sure I understand it correctly.
CommTestRX:
I see that you are starting your serial set-up through Full_Duplex_Serial "Which starts a new cog in itself". Then you are starting another new cog to handle the Check_For_ID Method and your leaving the return result as is without adjusting it. The next line "repeat until ops:= true" is handled by original startup cog and the New "Check_For_ID" cog is running in a loop checking to see if its return result is == to ID. If it does let byte varible ops := True. When ops is True then the original cog calls Full_Duplex_Serial which transmits "master".
Before we go on please let me know if I am interperting your code correctly and tell me how you have your Hardware set up.
1) Did you mean to declare your varible Char as "Char" or "_Char" ?
2) You may want to install a "Stop" Method before comm.Start to prevent your Stack from overflow "until" you get your code completed, may prevent garbage.
3)I have found that keeping things simple to begin with untill the code works is best and therefore giving your cognew command a Alias for the Result varible might be better.
Success := (Cog := cognew (Check_For-ID(own), @Stack) + 1
Therfore making your boolean result value "Success" either "0" no cog has been started or "1-8" if a cog was started.
1. ignore 'Char'. I didn't know if I was going to use it
2. I will try this
3. Will try this also
Thanks for your help!
RoboGeek
P.S. Also, I know the slave code works, It's just the master code that's not working.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
Post Edited (RoboGeek) : 1/29/2008 2:58:45 AM GMT