Hi all...
I'm messing about with the btserial, (serial across a bluetooth dongle) library
and it has putc and getc and they work just fine.
I want to send a float,.. 1 hour of googling and playing later... I have this. (lots people saying it can be done like this, and it appears to work on an arduino?)
float f = pot1.read();
printf("Value: %f", pot1.read()); //displays 0.9
char * b = (char *) &f;
//split it up and send the 4 bytes.
outgoing->putc(b[0]);
outgoing->putc(b[1]);
outgoing->putc(b[2]);
outgoing->putc(b[3]);
//surely this should just reconstitute a float into z?
//if it works, I'll sort out the receive on the other mbed
float * z = (float *) &b;
printf("Recon: %f", z);
I basically.. split it into 4 bytes, send them across, and see them arrive the other side, but it doesn't reconstitute into a float. I just get 0.0000
So.. I thought I'd just reconstitute and print out on the sending side. That doesn't work though. So it's nowt to do with the transmission, it's to do with the reconstitution.
any help gratefully received, as I thought it'd be simple.
Hi all...
I'm messing about with the btserial, (serial across a bluetooth dongle) library
and it has putc and getc and they work just fine.
I want to send a float,.. 1 hour of googling and playing later... I have this. (lots people saying it can be done like this, and it appears to work on an arduino?)
I basically.. split it into 4 bytes, send them across, and see them arrive the other side, but it doesn't reconstitute into a float. I just get 0.0000
So.. I thought I'd just reconstitute and print out on the sending side. That doesn't work though. So it's nowt to do with the transmission, it's to do with the reconstitution.
any help gratefully received, as I thought it'd be simple.