Netherlands
Asked

Isconnected Becomes True While EZ-B Is Not Connected?

I am experiencing an issue with my script that runs a loop while the EZ-B is not connected. Here is the code snippet I am using:

if (IsConnected(0) = true)
  print("ping")
  ToggleDigital(0.23)
endif

According to my understanding, the script should never print "ping" or toggle the digital port 23 because the EZ-B is not connected. However, I am still receiving a "ping" message followed by an error: "Unknown Digital Port: 0.23."

Could someone help me understand why this is happening and what I might be doing wrong?


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

PRO
Canada
#1  

It seems like there might be a misunderstanding in the script logic or the way the IsConnected function is being used. Let's break down the issue and provide a solution.

Understanding the Issue

  1. Function Usage: The IsConnected function checks if the EZ-B at a specified index is connected. The function should be used with the correct syntax and logic.

  2. Script Logic: The script is intended to execute certain actions only if the EZ-B is connected. However, the logic might be flawed, leading to unexpected behavior.

  3. Error Message: The error message "Unknown Digital Port: 0.23" suggests that the port is being referenced incorrectly. Digital ports on the EZ-B v4 are labeled as D0 to D23, not 0.23.

Solution

Let's correct the script and ensure it functions as intended. Here's a revised version using JavaScript, which is preferred over EZ-Script:

if (EZB.isConnected(0)) {
    print("ping");
    Digital.toggle("D23");
} else {
    print("EZ-B is not connected.");
}

Key Points

  • Correct Function Call: Use EZB.isConnected(0) to check if the EZ-B at index 0 is connected.
  • Correct Port Reference: Use "D23" to reference digital port 23 correctly.
  • Logic Flow: The script now checks if the EZ-B is connected before executing the actions. If not connected, it prints a message indicating the EZ-B is not connected.

Additional Tips

  • Debugging: Add additional print() statements to debug and understand the flow of your script.
  • Error Handling: Consider adding error handling to manage unexpected scenarios gracefully.

If you have any further questions or need additional assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Netherlands
#2  

you just wrote the same code but now in Javascript. What is different?

#3  

Athena was incorrect with her guidance.

The javascript manual for digital toggle is here: https://synthiam.com/Support/javascript-api/Digital/toggle A port for JavaScript is not in quotes.

if (EZB.isConnected(0)) {
  print("ping");
  Digital.toggle(d23);
} else {
  print("EZ-B is not connected.");
}

The ezscript you posted syntax is incorrect. The port is not 0.23, it is 0.d23. The manual for ezscript is here: https://synthiam.com/Support/ez-script-api/ezscript

*Side note: It is essential to know that ezscript has bugs and is deprecated, as announced several years ago. Its existence in Synthiam ARC software is for backward capability. Learning Python or JavaScript is a good suggestion. Trust me when I say JavaScript is easier to read and understand than EZScript. Plus, there are several more resources. The manuals on this website in the support section for JavaScript are also necessary. By running the above code, when there is NO connection to an ezb, the following message states there is no EZB connected.

User-inserted image

The EZB.isConnected() method is documented here: https://synthiam.com/Support/javascript-api/EZB/isConnected

Also, note that the EZB.isConnected() method does not connect to an EZB but merely returns its connection status.

PRO
Netherlands
#4  

Thank you, and good catch on the missing "D". It did not yet register with me that ezscript is EOL, and I could expect issues like IsConnected buggy. Plenty lines of code to recode, bummer. I will switch to python.

PRO
Synthiam
#5  

I think what happened is ezscript was meant for quick easy scripting back in the early days when ARC was ezbuilder. But since then, ARC implemented Python and JavaScript which are incredibly fast in comparison to ezscript. Those languages quickly outgrew ezscript - specifically in performance. We’re talking a 10x or more performance improvement over ezscript.

plus ezscript is too much like basic but also trying to be something else. It kind of is similar to JavaScript but not really. Learning ezscript doesn’t benefit anyone because it’s not a transferable skill either.

so several years ago we just sort of left it alone. We won’t kill it but it isn’t getting new features.:)