Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by Dunning-Kruger!

Looking For A Way To Ping_Wait Command Timeout

Good Afternoon,

I know there is a ping wait command. I want the ping wait command to time out in 5 seconds.Thoughts on this are most welcomed.

AI Support Bot
Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#1  
Set up a RepeatUntil loop instead... It will poll the ping (as fast as you set the sleep for) for the amount of time (or number of checks set in a variable) that you specify and then exit the loop....
United Kingdom
#2  
use a GetPing If nest to check the ping for the required value wrapped inside another IF nest which cycles for 5 seconds or a repeat until command.

Code:


# Get the current seconds and store it
$oldsecond = $second

# A quick check to avoid errors if the second is about to loop back to 0
IF($oldsecond > 55)
# subtract 60 from it to make a negative number
$oldsecond = $oldsecond-60
EndIf

# Start the repeat until 5 seconds time
RepeatUntil($second = $oldsecond + 5)

# Check the ping and exit if ping is met
IF(GetPing(D0,D1) = 200)
# Escape the loop
Goto(escape)
EndIf

# Reduce processor load
Sleep(100)

# End of repeat
EndRepeatUntil

:escape
Print("escaped")


Note: Script not tested nor written in ARC. Check the commands and use as a base for your script.

It's not idea and wont give exactly 5 seconds (it'll be at least 4 seconds but less than 5)
#3  
Something like this... (I just hacked this so I haven't checked the syntax)

This will loop for approx. 60 seconds

Code:



$check=0
$ping=0

repeatUntil($check=600)

$ping=getping()

if($ping)<20 # or whatever value you want

# then do something

endif

$check=$check+1

sleep(100)

endrepeatuntil

#4  
Do you need to have the Ping to restart once you stop it? If not how about a Sleep(5000) Command then a StopScript Command or Halt()? if you want to have it restart how about using a StartScript?

Code:


Ping_Wait(D3, D4, HIGHER, 50)
Sleep(5000)
Halt()


Or you could use two scripts; one starts the Ping, starts the second script and then pauses after 5 seconds. There would be a 5 second sleep in the second script then a Resume command. Like this:

"HoldPing script"

Code:


Ping_Wait(D3, D4, HIGHER, 50)
Example: ControlCommand( "Script Manager", ScriptStart, "PingStart" )
Sleep(5000)
Pause()


"PingStart script"

Code:


Sleep(5000)
ControlCommand("HoldPing", Resume)


You may have to adjust the sleep time to your liking.

EDIT: @Rich 7 @Richard, you guys slay me. Why do I even try? :D
#5  
Ha, ha... And the funny thing is I learned most of this stuff from Rich....:P Dave, you have a good idea... Stopping and starting a WaitforPing script via another timed script is not a bad idea...
#6  
Woah!

Thanks Guys! On a different note, Could you please explain to me the ControlCommand() script start. I would like to run several scripts upon the connection of the EZB V4.
United Kingdom
#7  
The easy way is to click on the Cheat Sheet tab in the EZ-Script dialogue. This brings up all ControlCommands available in your project. clicking on one will add it to the script for you.


User-inserted image

Image courtesy of DJ in a different topic

ScriptStart basically starts the script specified.
ScriptStartWait does the same but the main script which calls it will hold at that line until the script started with ControlCommand has finished.
#8  
Thank You all for your quick help and feed back!