I need to concatenate multiple values, float char + int + 16 to transmit the SCI module. How can I do that?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I need to concatenate multiple values, float char + int + 16 to transmit the SCI module. How can I do that?
The SCI sends data 8 bits at a time. If you want to transmit a float (32 bits), a char (16 bits), and an int (16 bits), you could do something like this:
float f; char c; int i; SCIFFTX = (uint32_t)f >> 24; SCIFFTX = ((uint32_t)f >> 16) & 0xff; SCIFFTX = ((uint32_t)f >> 8) & 0xff; SCIFFTX = (uint32_t)f & 0xff; SCIFFTX = c >> 8; SCIFFTX = c & 0xff; SCIFFTX = i >> 8; SCIFFTX = i & 0xff;
a sensor node I have different data like: 3 voltages and 3 currents. and I need to send this data as follows: node name, data type (voltage or current 1 1), data value (current or voltage value).
but when I try to send a char something like this: char [] = { "node1", "voltaje1" voltaje1} I can not. I can do to send this information?
Hey,
maybe like this:
char buff[128]; int length; length = sprintf(buff, "node1, voltage1 %d", voltage1);
At this point buff will contain the string you want, and length will contain the length of the string.
J
Hi Natalia,
I think it's time to be more specific about things. Please answer the following questions:
BR,
J