Hi,
It seems that the SimpliciTI can ONLY send unsigned int8 data.
I am sure there is need to send negative numbers, for example, a negatively signed ADC conversion result, how to those negative numbers using SimpliciTI?
Thanks!
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.
Hi,
It seems that the SimpliciTI can ONLY send unsigned int8 data.
I am sure there is need to send negative numbers, for example, a negatively signed ADC conversion result, how to those negative numbers using SimpliciTI?
Thanks!
It is all a matter of formatting. If you need to send anything bigger than a 8 bit value, just define consecutive bytes as a word or longword, etc. For signed vs unsigned you would just need to cast the variable properly. A signed variable is just an unsigned with the MSB as the sign bit.
Hi, thanks for the reply!
I tried to cast the ADCH before sending it over the radio, using the following code,
uint8_t uADCH = (uint8_t) ADCH;
SMPL_Send (linkID, &uADCH, 1);
But did not seem to work.
I tried the following way, y = static_cast<unsigned char>(x), IAR does not support static_cast.
So how to cast it properly? Thanks!
Basically you have to do some bit manipulation to fit larger variable sizes into the 8 bit char values sent by SimpliciTI.See my example in this topic. :
The following code is type agnostic, just put whatever data type in the structure you need. Memcpy transfers the data from type to char and back again.
VARIABLES:
typedef struct {
int Sample1;
int Sample2;
} ADC;
MyData ADC;
MsgBuf[Len] = {0}
SENDER
memcpy( MsgBuf, (char *)&ADC, sizeof(ADC));
SMPL_Send (linkID, MsgBuf, sizeof(ADC));
RECEIVER
int Len;
SMPL_Receive(LinkID, MsgBuf, &Len);
memcpy((char *)&ADC, MsgBuf, sizeof(ADC));