Go Down

Topic: Split a string into two integer values (Read 1 time) previous topic - next topic

PaulS

Code: [Select]
char* S_message::toString(void)
{
  snprintf(buffer,sizeof(buffer),"%1u",
      temp_reading >> 8//,
     // ( temp_reading & 0xFF ) * 100 / 256,
   //   voltage_reading >> 8
    //  ( voltage_reading & 0xFF ) * 100 / 256
      );
  return buffer;
 
}

Return a pointer to a global variable. Why?

Code: [Select]
char* S_message::volts(void)
{
  snprintf(buffer,sizeof(buffer),"%1u",
   //temp_reading >> 8,
     // ( temp_reading & 0xFF ) * 100 / 256,
      voltage_reading >> 8
    //  ( voltage_reading & 0xFF ) * 100 / 256
      );
  return buffer;

Ditto.

Converting the high order byte to a string, discarding the low order byte, and then converting that string back to an int makes no sense.

But, heh, it's your code.

Jimster

it's not my code, it's what I hacked from the sensornet example, I 'm still not really sure whats going on to be honest. I'm still learning

Go Up