Question
Asked July 25 2014

Community Question

I've been trying to receive data through the Uart port in EZB V4 and use it in a script. I've successfully been sending special commands to move my motor to exact points through a Kangaroo/Sabertooth combination and that's working great. I've even been able to read how many Bytes are in the buffer useing the below Script. This Script successfully moves my motor to position 113261 at Speed 10000 and returns a reading of 5000 bytes on the debug screen of the script. However I get no info at all when I look at the UARTRead line. Even is I did I don't know how to convert that info into any useful command in my script.

Kangaroo X2 Commands:
P = Postion as read from an encoder on the motor.
S = Speed the Kangaroo lets the Sabertooth move the motor at.
Getp = Command to tell the Kangaroo to send the position it us reading from the encoder at any given moment.
0x0d = Carrage return

Code:


$Getp = "Getp"
uartWrite(1, 0, "1, p113261 s10000", 0x0d)
sleep(3000)

uartWrite(1, 0, "1, Getp", 0x0d)
Sleep(3000)
$x = UartAvailable(0, 0)

print("Bytes in buffer: " + $x)

$Getp = UARTRead(0, 0, $x)

print("Received: " + $Getp)


Basically I want to move my motor to a point and be able to trigger an event or another script before the motor gets there. I know I need a loop that reads the "Getp" info returned from the Kangaroo X2 but I cant find the right code to retrieve it through the Uart port and also be able to use it.

Any help with this code is welcomed. :)
July 25 2014
Ah HA! That did it! It was just that simple. Just a stupid little mistake of not numbering the board properly. Thanks!

Now I get the proper position readout of p113261 . Here's what shows in the script console (Second line from the bottom):

Code:


Start
1: $Getp = "Getp"
2: uartWrite(1, 0, "1, p113261 s10000", 0x0d)
3: sleep(3000)
5: uartWrite(1, 0, "1, Getp", 0x0d)
6: Sleep(3000)
7: $x = UartAvailable(1, 0)
9: print("Bytes in buffer: " + $x)
> Bytes in buffer: 11
11: $Getp = UARTRead(1, 0, $x)
13: print("Received: " + $Getp)
> Received: 1,P113261
Done (00:00:06.5393740)


Thanks so much, I've been stumbling over this all evening. Couldn't have done it without you! Now I think I can finish developing the script. *cool*
July 25 2014
Resolved!
DJ Sures
Synthiam
July 25 2014
That board number is your nemesis:)

Glad to hear it's good!
July 25 2014
They sure are. I've done this same thing to myself a few times before. Sounds like you remember the last time you pointed this out to me. ;) Your like my personal Yoda.:P
July 27 2014
Yeh!