Java API

Hi all,

I am doing a Java API to connect to BAP with my pc using a bluetooth antenna. I have all the Java part done and I have tested it properly. So far I am able to send integers and strings to the robot. Floats are a bit harder. However I am a bit stuck with the basic micro code.

So far I send a number to the robot and plot it using the next fully-working code:

number var word
serin pc_in, pc_braud, [number]
serout s_out, i9600, [dec number,13]

The number has to be received with any modifier, otherwise java is not able to send it correctly. The problem comes up when I use a for… next and it never stops. Eventually, I am into an infinite loop. How can I get the decimal value of the number and stop the loop for?

index var word
for index = 0 to number
....
next

PS: As soon as i finish with the communication protocol I will update the API into the forum

Best Regards

We are not sure to understand why you run into an infinite loop.

You are using serial communication so you need to send your floats as you would send any other string of bytes. When that are received, they should be stored in a memory location and used as floats again (if they are in the correct representation)

What representation are you using for the float? What is the for-loop used for?

Also, it might be simpler to multiply your numbers by some large enough power of 2 to remove the decimals and make it into an int, than you can process it mores easily in your embedded platform.