I need to write as uint64_t data from GNSS reciever.
From reciever i got 8 bytes (as an array of 8 bytes), i need to combine it to one 64 bit value.
For instance:
Recieving bytes: 71 65 DB 4B 01 00 00 00 must be writed in reverse sequence: 01 4B DB 65 71 00 00 00,
so the word '14BDB6571' must be stored.
After it should be converted to decimal value 5567636849.
That is not in reverse. That is some kind of magical mixing with unknown conditions.
If you need '14BDB6571', then you need: 00 00 00 01 4B DB 65 71. So it is in reverse order after all ?
Is the 0x71 the first received byte ?
To do it in reverse, you could use this:
byte buffer[8] = { 0x71, 0x65, 0xDB, 0x4B, 0x01, 0x00, 0x00, 0x00);
uint64_t result = 0;
for( int i=7; i>=0; i--)
{
result <<= 8;
result |= (uint64_t) buffer[i];
}
For which Arduino board ?
I think that the Arduino Uno can not print it. Perhaps the Arduino Due or Arduino Zero can convert the uint64_t with sprintf().
If the Serial.println() does not accept the uint64_t, then try the sprintf().
The Serial.println() is from the Arduino code. The sprintf() is from the libraries that belong to the compiler.
The sprintf() is not straightforward for 64 bit. You might have to use "%I64u" or "%llu" or even "%"PRIu64", but I don't understand what that last one is. You could start with the most common "%lld".
Koepel:
If the Serial.println() does not accept the uint64_t, then try the sprintf().
Koepel, many thanks!
Your code works perfectly!
Also my Serial.println() works correctly, and i can see a result (and it in decimal already).
But as you said, value uint64_t i can not convert to string and sent to TFT display....
Could you please give a code with sprintf() conversion?
SHTIRLITZ:
Also my Serial.println() works correctly, and i can see a result (and it in decimal already).
But as you said, value uint64_t i can not convert to string and sent to TFT display....