Asked
— Edited
Resolved by Redzone!
Upon manually connecting to Board 0, I would like to establish a connection to Board 1 using EZ-Script, process some initialization there (ie: 1.D0 do thus and such) Can I and if yes, how do I connect to Board 1 from script?
Thanks!
Servo(1.D2, 180)
0.d1 = EZB board 0 digital port 1 1.D2 = ARC board 1 digital port 2 And so on
@merne Yeah - My question is not how to address the port on the board (once it is running). That's simple.
Can I CONNECT to Board 1 with CODE?
Can you give an example. are you asking if you can use ControlCommand to connect to board 1 if you have not manually push the connect button?
Controlcommand("connection", Connect1)
This is listed on the tab " cheat Sheet" when you open a script
Hope this is what you are asking
Cheers
BRAVO! (partly)
Interesting... Board 1 connected, executed it's Init Script, and when finished, the Init Script for Board 0 did NOT continue executing.
Bad Dog. Is there a way to get the rest of the InitScript for Board 0 to complete?
#Board 0 Script: SayEZB("Initializing Board Zero") Sleep(2000) ControlCommand( "Connection", "Connect1" )
#do the rest of my init routines for Board 0 here (is not happening...)
You need to increase the sleep command longer, thats what the sounds like. I believe you can also use a wait command to. Can you post a sample script?
First, use the [ code ] formatters if you wish to display code
second, use the SayEZBWait() command if you want to wait for it to speak.
The EZ-Script manual is along the right when editing scripts. Here's a screenshot
When you see something BLUE in someones reply, you can click on it. For example the Cheat Sheet is in blue. Click on it so you can read about it. Also, ControlCommand is in blue, click on it so you can read about it.
Here is the InitScript running on Board 1 (ps Thank you for your help with this!)
I edited your post and put [ code ] [/ code ] tags around the code so people can read it
@DJ Thanks DJ, am using my phone to replay it's harder to reply using just my phone.
@mayaway, us the SayEZBWait() command Like DJ said.
At a quick look you script looks ok, nice init script too.
Thank you both:
"First, use the [ code ] formatters if you wish to display code" I am not quite sure what this means or how to do it, though I think there must be a way to indicate that a block of my post is code - so I'll see if I can figure out how to do that...
"second, use the SayEZBWait() command if you want to wait for it to speak." This sounds good because it may solve my problem, and you are also simply 'giving me a fish' and I want to learn HOW to fish... So I'll go lookup this command and maybe it will explain WHY I should use it...
@mayaway
edited
If you scroll to the bottom of your reply you'll see a list of many of these commands use for new when replying.
aha! Thanks! Got it... There's a learning curve here...
OK - Problem is NOT SOLVED
SayEZBWait("some text") is explicitly for completing the text to speech before moving on. Good tip but not the solution for my problem, which is:
Would the command
at the end of the Init Script for Board 1 solve this?
The init script is runs once to set your parameters if that is the correct word.
You might want to post your full init script so we can see exactly what you're trying to do thanks.
I think I understand what you're saying now. Are you using 2 init scripts or the same one?
If I am understanding what you are trying to do, the issue is that ARC is multi-threaded. multiple scripts can run simultaneously, so when you issue a command that starts a new script, the original one continues to process. What I think you are asking to do is pause the board 0 init script until board one completes its initialization.
There are probably multiple ways to do this, and I may be missing a simpler way, but one way you can do this is in your board 0 init script, initialize a variable. example
then, after the ControlCommand() that starts board 1, you use waitforchange command to look for the value of $script0 to change
this will pause the script until the value of the variable changes.
Now, in your second script, after it has done all of its activity, the last command in the init script for board 1 would change the value of the variable, which triggers the waitforchange to take action and continue the script for board 0.
Alan
I understand the logic, and tested it's implementation, but it also failed. This leads me to believe that control is never passed back to the InitScript for Board 0. Perhaps I need to call a regular script from the Board 0 Init Script and have that script connect Board 1, wait for the change... Any ideas why control won't pass back to the first script? If vars are GLOBAL then perhaps I can do a ControlCommand("Connection","Connect0") at the end of the script for Board 1, and use if($script!=0) { ControlCommand("Connection","Connect1") }
I worked it out: At the beginning of Init Script for Board 0 I have
and at the end of the Init Script for Board 1 I have
whereupon the Board 0 Init Script executes and skips the initialization of board 1 which has already been done.
Sorry about the slight wild goose chase. Didn't realize that setting to 0 would not work. I usually do this kind of thing using text variables ("yes/no" "right/left"). Big thought it would be easier to explain using integers, but didn't actually test before posting (again, since I have had success with similar scripting).
Glad you got it working.
Alan
I'm currently running 4 EZB's in my robot with lots of scripts running and devices attached to all 4 EZB's. I found that you should be starting all your EZB's and oher devices along with setting all your perimeters in only one INT script. Start all your EZB's first near the top of your "only" INT script. Start and set things like all EZB's, servo min, max, speeds and poisons in this one INT script. Also set most all global variables in this one int script. EZ Script "steps" through your commands one line at a time. Once everything is setup and ready to run in this script only then should you start calling other scripts from this INT script (Multi-Threading) to move or run devices and motors. Watch what is running at any given time. If you try to call the same device or motor to run at the same time or before it's done with what is is doing, something you expect to happen will not work or even lock up or disconnect the EZB.
Also make sure to place Sleep() commands where needed to give devices time to move into place or finish their function. The script will fly by time sensitive commands without letting them complete. If something is not working look at this as a possible issue.
One more tip; If you try to send an improper command through any of the UART ports the EZB will disconnect. You'll also lock up an EZB if you try to send a command through these UART ports before you initialize the one you want to use. If used, Uarts should also be initialized in your "only" INT script. You only need to do this once per EZB boot up.
I'm no shining example of an EZ script code writer but below is my INT script that will explain what I'm talking about:
One last tip. In the future try not to be so quick to mark a help thread resolved until your sure your problem is actually fixed. You run the rick of not getting the help you really need. There are lots of people here willing to lend a hand.
Thanks Dave, these are great tips for mayaway and others. I too was wondering if mayaway had more than one init script. And you're right about not marking solution solved until it's fully solved.
Cheers
Hey thanks guys! These are very helpful tips. I'll consolidate to one Init. I think @DJ said with SendSerial() you don't need the UARTinit. It's probably two dif. ways of doing the same thing. I think I also saw that the ServoSpeed() command needs to be preceded by a Servo() position command. Maybe it used to be... maybe it still is!
No problem Merne. I also had to work through these same issues when I started using more the one EZB. One of the hardest things for me to wrap my mind around was the concepts of multi-threading scripts and how they interact with each other. I still find this challenging at times when complex things are going on. I hope I helped in some way.
After reading through the OP's posts in this thread it sure sounds like he was trying to use separate scripts to start up and set up each EZB. Then run start up routines for devices attached to it's EZB that it's starting.
@mayaway, That's not correct. You always need to start a UART port (Need to do this only once) before you use it. Use the UARTinit() command for the port your going to use in your INT script. If you send a command through the UART port without starting it first you will lock up your EZB.
EDIT: Actually if your sending a Sendserial command through a digital port then your are correct. You dont need to use a UARTinit() command. Only use the UARTinit() command if you're sending through a UART port.
Servo Speed commands are hard to understand (for me at least). Here's a few notes from the Script help section in ARC:
@mayaway
That's correct... before you set servo speed you need to set an initial servo position so....