Go Down

Topic: UDP send/receive problems... (Read 1 time) previous topic - next topic

Problem issues,

I have some trouble to communicate information using UDP

[UDPSendReceiveString,pde]
..
..
char  ReplyBuffer[] = "acknowledged";       // a string to send back
...
...
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
...
...

I would like to send float() to a PC program written in Processing over my LAN/WLAN and i have problems to send or convert my float variable in ReplyBuffer[] when I
try to convert data to string i get this errors

float tmp102temp = 22.34;
char ReplyBuffer[] = {tmp102temp};

The receiving end I get the following result "Vc" and if I try and mix something I get very strange result but i like to get a float or string, maybe a int or something that I can
use in my processing application.

Any tips and tricks are welcome to solve this problem
__________________________________________
Daniel Andersson
Developer

SurferTim

The Arduino compiler does not support float types in functions like sprintf() etc. But there is a solution. This topic covers it near the end of the posts.
http://arduino.cc/forum/index.php/topic,72682.0.html

PaulS

Quote
I would like to send float() to a PC program

You want to send a function to a PC? You'll need a different name for the function, since float is a reserved keyword.

Quote
when I
try to convert data to string i get this errors

float tmp102temp = 22.34;
char ReplyBuffer[] = {tmp102temp};

I'm not surprised that you get errors. You are trying to stuff a 4-byte float into an 1 byte character.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy