Asked — Edited
Resolved Resolved by DJ Sures!

Error On Line 25: Missing String Quotes

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)


ARC Pro

Upgrade to ARC Pro

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

#25  

Ah ha! Alen your the best!

Believe it or not I was just coming back to this thread to say I just taken a look at an ASCII table and just found this info out. I'm like a blind pig. Once in awhile I can find a nut. LOL

Even so, Thanks for this info as it confirms my blind find. Tomorrow I'll modify my script to take the return of these numbers and make it do what needs to be done.

Thanks again! :D

#26  

Yes! Problem solved! Changing the UartRead Did the trick! Then knowing I will see the returned value as the number in the Acsii table that corresponds to either a uppercase P (80) for a completed move or a lower case p (112) for a move still in progress was the final answer. No more errors at all and everything is running smooth and safe.

@DJ, I'll still send you the Kangaroo X2 board and the Sabertooth 2X12 if you want them. I have them packed up with the custom papers attached, a FedEx shipment completed and their ready for me to drop off. However as of now I think I'm over the hump with any coding issues using these boards with ARC. If you still would find value in having these control boards and writing a plugin for others I'd be thrilled to still ship them to you. Please let me know and they are yours!

Thanks once more. I'll sleep good tonight.:D

PRO
Synthiam
#27  

Please use this thread for your issue and do not create a duplicate.

Use the binary uart operation for communicating to your device as demonstrated.

What else do you need to know?

#28  

OK. No problem. Sorry you had to go through the trouble of deleting my post. I thought the question was different from me asking about the String Quote error.

I'm now trying to get a read of all characters past the P in this: 1,p-8 or 1,p1600000. I've tried using several of the getbyte operations with the script you corrected above but can't seem to get it right. Any help would be appreciated.

PRO
Synthiam
#29  

Okay - i'll repeat what is happening, again. The kangaroo thingy is returning a byte (or more) that is corrupting the string.

This is an ascii chart

User-inserted image

The readable characters in the alphabet and numerical, etc that you can visually see with your eye balls are between 32 and 126. Everything else are values that have no readable representation because they're commands. You cannot display an ESC or a BEL because they do not exist in our alphabet. There are no words in any language spelt with the ESC (ascii 27) character, because they do not exist outside of the realm of a computer.

You cannot store these unreadable values in a string. A string is a sentence, like you are reading right now.

READUART(), as per the manual, reads readable ASCII. This means if you are reading data that is not ASCII then the Binary Uart Read would have to be used.

However, i'm tempted to add a filter on the ReadUart() command that removes binary characters. Doing so will be cheating for any educational value that people get from using ez-robot.

Your solutions are...

  1. use binary read function, as demonstrated in an earlier response
  2. wait for me to create a plugin

While you wait, this might be a good opportunity for you to explain what you working to accomplish with Reading from the UART so i can better understand the objective.

#30  

@DJ

Quote:

However, i'm tempted to add a filter on the ReadUart() command that removes binary characters. Doing so will be cheating for any educational value that people get from using ez-robot.
How about instead have a "verbose" error message displayed so the user will understand that their "ascii string is unreadable due to non view able ascii characters"? I get some errors still from data returned from the roomba... I am now thinking that some of this data isn't readable ascii data (binary) so it's not working properly with UARTRead...

PRO
Synthiam
#31  

The Roomba is not readable ascii and is the exact reason why binary operations exist.

Logic either works or doesn't work. There is no in-between.

I cannot display errors and continue processing because the data is not valid. Binary operations and functions are not something i magically invented, there is no reason to fear them. Binary operations merely return an array of bytes.

It's not that i have a choice of what can be stored within a string. That's like saying you have a choice of whether or your you can use your automobile as a dishwasher. The inherit design of a STRING is exactly what I previously explained - readable characters for humans.

A string is a string because it is a string.

I do have an "idea" that can escape some more characters for the UART READ but it will most likely introduce Dave into another struggle.

The Binary Read operations were created for just this though.

#32  

@DJ... ah but some UARTRead's work ok on the roomba... for example I can read the roomba's bump, IR sensors and battery voltage using UARTRead. However other sensors like reading the milliamp capacity of the battery fail using UARTRead.... So my logic was maybe some read returns are binary and some use ascii? However I do understand what you are saying here....