Asked — Edited
Resolved Resolved by Steve1DH!

V4 Two Way Serial Communication - Where Do I Connect To Read?

Hi all,

I'm trying to get serial feedback from a device. Does anyone know where on the V4 I should attach to read back serial information from device? I know I send a serial command to through one of V4's digital signal pins but where do I read it back from?

I thought it would be read from the same digital pin I sent the command. However @Toymaker made a comment in another thread that it may have to be read through one of the i2c ports.

Any insight is welcomed. :)


ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

#25  

Ok, one step at a time:) I see the variable's value in the variable watch... so now need to figure out how to script with these values as a variable condition...

#27  

Thank you very much Dj! And enjoy your evening! I hope she's worth it!:D

PRO
Synthiam
#28  

Thanks! I'll write something if you're still spinning wheels later this evening

#29  

ok, if anyone else is arround, here is what I'm now facing : don't seem to be able to get ASCII strings...

here is the error message I get using this code plagiarized from ARC examples :

the code first :


UARTInit( 1, 0, 9600 )

:loop

$available = UARTAvailable( 1, 0 )

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

$read = UARTRead(1, 0,$available)

print("Received: " + $read)

sleep(1000)

goto(loop)


And now the error message I get :


Start
1: UARTInit( 1, 0, 9600 )
3: :loop
5: $available = UARTAvailable( 1, 0 )
7: print("Bytes in buffer: " + $available)
> Bytes in buffer: 0
9: $read = UARTRead(1, 0,$available)
11: print("Received: " + $read)
> Received: 
13: sleep(1000)
15: goto(loop)
3: :loop
5: $available = UARTAvailable( 1, 0 )
7: print("Bytes in buffer: " + $available)
> Bytes in buffer: 16
9: $read = UARTRead(1, 0,$available)
11: print("Received: " + $read)
> Error on line 11: Missing String Quotes or Invalid Expression at index 15: "A
Done (00:00:01.1545633)


It's supposed to read these values :

"A=" then a number between 0 and 640 "B=" then a number between 0 and 640.

It seems that it can't read ASCII string values... maybe it's the "=" ?

** update : it is not... even after changing the code in arduino to only return numbers... I get this :

Start
1: UARTInit( 1, 0, 9600 )
3: :loop
5: $available = UARTAvailable( 1, 0 )
7: print("Bytes in buffer: " + $available)
> Bytes in buffer: 0
9: $read = UARTRead(1, 0,$available)
11: print("Received: " + $read)
> Received: 
13: sleep(1000)
15: goto(loop)
3: :loop
5: $available = UARTAvailable( 1, 0 )
7: print("Bytes in buffer: " + $available)
> Bytes in buffer: 6
9: $read = UARTRead(1, 0,$available)
11: print("Received: " + $read)
> Error on line 11: Missing String Quotes or Invalid Expression at index 15: "
Done (00:00:01.5197188)
PRO
Synthiam
#30  

the question is missing some info. Is the arduino sending an unsigned 16 bit int? Signed 16 bit int? Or a string of characters?

Because it can't be an 8 bit unsigned int cause that only goes to 255.

What is the arduino sending?

#32  

it was initially sending a string of charaters AND a int (it seems int is by default signed in arduino).

Arduino int stores a 16-bit (2-byte) value by default.

I took out the string of characters but I still get this error message :

15: goto(loop) 3: :loop 5: $x = UartAvailable(1, 0) 7: print("Bytes in buffer: " + $x) > Bytes in buffer: 7 9: $y = UARTRead(1, 0, $x) 11: print("Received: " + $y) > Error on line 11: Missing String Quotes or Invalid Expression at index 15: " Done (00:00:02.4873538)