Asked
— Edited

I'm getting an error message in one of my scripts that is giving me some trouble. It's a random error meaning that it will happen every few times the command is run. It's set in a loop so it will repeat. Sometimes it will even cause the connection between the EZB and computer to cut off. Here'e the error:
Error on line 25: Missing String Quotes or Invalid Expression at index 14: "
and
Error on line 25: Missing String Quotes or Invalid Expression at index 15: "
Here's the script to happens in. Seems to center around the print commands. Once I removed the print command at line 25 and the error skipped to the next one. I've also expanded the sleep() commands thinking it was running too fast but it does not help. Thanks for looking :
# This Script will return the actual position number of the left catrrage
# #from the Kangaroo withough the 1,p in the begining.
# #Returning feedback with the 1,p causes problems.
# #Do Not Delete. Other scripts depend on this script!
# -------------------------------------
# Get Roo position
uartWrite(2, 2, "2, Getp", 0x0d)
:waitForData
Sleep(30)
$y_lft = UartAvailable(2, 2)
Sleep(30)
print("Bytes in buffer:" + $y_lft)
if ($y_lft < 6)
# Go back and wait for data again because we did not receive the least number of expected bytes.
goto(waitForData)
endif
Sleep(30)
$Get_Lft_Carrage_P = UARTRead(2, 2, $y_lft)
Sleep(30)
print("Received: " + $Get_Lft_Carrage_P)
Sleep( 50 )
# -------------------------------
# Find out and print if the P is upper or lower case.
# Upper case means motor has finished move ans stoped.
# Lower Case means that motor is still moving.
$P_lft_or_p_lft = GetCharAt($Get_Lft_Carrage_P, 2) #Assign a variable to either a capitol P or Small case p returned by Kangaroo.
Print("P_lft_or_p_lft:" + $P_lft_or_p_lft)
# -----------------------------
# Defeat the P_lft_or_p_lft
if ($P_lft_or_p_lft = "p")
Goto(Lower_p_Split)
ELSEif ($P_lft_or_p_lft = "P")
Goto(Upper_P_Split)
endif
Sleep( 50 )
:Lower_p_Split
$Lft_Carrage_Position = Split($Get_Lft_Carrage_P, "p",1) #1,pXXXX is returned. Get everything after the Lower case p (P is case senceitive).
Sleep(30)
print("Received:" + $Lft_Carrage_Position)
Halt()
:Upper_P_Split
$Lft_Carrage_Position = Split($Get_Lft_Carrage_P, "P",1) #1,pXXXX is returned. Get everything after the Upper case P (P is case senceitive).
Sleep(30)
print("Received:" + $Lft_Carrage_Position)
In addition I noticed that this error also seems to happen when there are over 9 or more bytes in the uart buffer. This call for information usually only returns 8 bytes but sometimes as the loop runs, more bytes then expected are reported in there. My loops keeps running until there are more then 6 bytes found in the buffer. Do you think this could be part of the cause?
Here's what the debug window shows when I get disconnected from the conputer after the above error message:
tired
Your data isn't printable. Stop printing it to the screen or use an array. Look down at your keyboard - only those characters are printable. And if you have a quote to print, it must be escaped.
Unless you are working with ascii data, you'll have to use binary commands.
Now that i'm in front of a PC, to expand on your question...
The code that is generating an error is...
So, that means the UART read is reading a " (quote) or unreadable character outside of the ascii chart.
Did you look at line #25 and see that it is a print() Statement? The print statement can only print characters that are readable by a human, or they must be escaped. if data is stored in a variable that is not human readable, there's no way to print it. The variable manager can inspect it, or printhex will give the ascii value - because you can't print something that you cannot see.
Did you comment out the print() Statement?
Thanks for the reply and suggestions. It's good to know someone cares.
It's odd that you say that my print command shouldn't be able to print anything. It's been showing me position for years now with the occasional error I mentioned. The script would just pass the error by in the loop and redo the request/print. It was not until the latest ez builder update and/or my v2 upgrade that I first started seeing this things stop and disconnect.
Yes I did disabled the first print command and it found a error with the next one so I'm sure you're right. I'll disabled the rest to see if this helps. Thanks again.
I can see that the last update would have affected it because the previous version you were running was many months old - skipping multiple other updates.
That's like updating from Windows XP to Windows 10 and finding that things are different
It's not the print statement that has changed. It's how variable are stored. The original design of EZ-Script was not to support binary operations, because it was a short sighted design. As more power users began connecting 3rd party hardware to the ez-b, there were more binary operations being attempted which resulted in errors. There are numerous threads over the last year on that subject, and a dozen ARC releases with release notes documenting the changes.
The moral of the story is that if you're a power user (Which you are), upgrading more frequently is important. It is only 4 clicks of the mouse to upgrade, the keyboard doesn't ever have to be touched to upgrade. ARC also informs you that a new version is available when loaded.
Thanks for the guidance DJ. Actually it's not that I forgot to upgrade ARC, it's that I was busy completing my robot build between the time periods you mentioned. The scripts I'm using now were written back then and seemed to work nicely. Now that I have the robot mostly ready to accept more complex moment scripts is when I'm actually "power" using ARC again. Thank goodness!
So, back to my issue; I actually went back and commented out all the print commands. Sadly however this same error message is now happening on different command in the problem script. Here's that command now:
Sounds like I may need to find a different way to write this script? I really don't know what changes I need to make to get this script to work. I'm wanting this script to send a Simple Serial command request through the Uart to the Kangaroo for position info, read that info when returned then assign a variable to it. The issues I was having before was that the returned position info looked like this:
A upper case P would mean the movement was complete followed by the position. A lower case p would mean the moment was still going on followed by the current position.
Personally I really only need to know when the movement is complete. If there is a way to write a script that will look for a change from a lower case p to an upper case P that would work also. The above script that I wrote a while back could be modified to do this but I'm now not sure it is a workable script. Do you think this will work or is there a better way to write this? confused
I assume the issue is with a new line completion.
What would probably benefit you is an actual plugin for this piece of hardware.
Where can i get one? Do i need the kangaroo or do i need additional components? I'll order one and create a plugin for you. That way you will no longer need complicated scripts to send/receive commands to this device.
It will operate similar to the ssc-32 and dynamixel by using virtual ports.