Pages: [1]   Go Down
Author Topic: UDP send/receive problems...  (Read 1037 times)
0 Members and 1 Guest are viewing this topic.
SE
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

__________________________________________
Daniel Andersson
Developer

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5833
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: