We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi! In my project i sent to serial port a int :
unsigned int X; putchar(X); putcahr(X>>8);
and everything to work OK!!
but if i want change my data type and use float, i cant do
putchar(X>>8)
. I trying it:
float X _at_ xxxxx;
and with a function i read all adress of my data but it no work.
Any idea to do it?? thanks
Either send the floating point number as ASCII, i.e. the result of printf(), sprintf(), ...
Or make an experiment if you can transfer the four raw bytes (possibly with a byte swap) and have the PC pick up the result.
If the numbers are following the IEEE standard, then they should be stored in a compatible way so it should be possible to set a byte pointer to the address of the float and then send four bytes.
This gives the smallest code and maximum precision in the transfer but you need to define in which order the bytes arrive so the PC program knows what to do.
Thanks Per!!