Floating point MSComm question
Floating point MSComm question
(OP)
I'm working on a project where I have to send data from my computer to a microcontroller through a serial port. I'm using the mscomm control which comes with vb5 to send the information. Some of the data I have to send to the microcontroller is single floating point numbers and as I understand it you can't send anything other than bytes through mscomm. So my question is how can I divide up the floating point numbers into 4 bytes that can be reconstructed at the other end of the serial port?
The microcontroller program is written in c and is using the << command with the incoming bytes to put them in the correct spot in a floating point variable.
thanks for your help
The microcontroller program is written in c and is using the << command with the incoming bytes to put them in the correct spot in a floating point variable.
thanks for your help





RE: Floating point MSComm question
The problem with floating point numbers is internal storage. The easiest way is to send it in text from, if there isn't a performance hit. Convert your number to a string using cstr and then transfer the data one byte at a time, possibly using mid to get each character.
Another alternative is to scale up the number, pass it as an integer and then scale it down on the other side. eg your scale factor is 100. Watch out for big/little endian problems if you are doing this. Intel to Intel is fine but Intel to Motorola/PIC has problems.
RE: Floating point MSComm question
Read all 4 bytes into pointer to floating point in MC.
TTFN
RE: Floating point MSComm question
Dan - Owner
http://www.Hi-TecDesigns.com
RE: Floating point MSComm question