On 5/31/20 11:13 AM, Hassam Mughal wrote:
> Thanks a lot, fixed the issue by changing the size instead of changing
> the whole code as others did. However, is it ok to use i.WriteHtonU64
> instead of :
You are trying to write a floating-point double value into the header,
which is mainly set up to handle integers because that is what is
usually used in real protocols.
You could consider to maintain your variable as an integer, and use the
integer-based methods.
You could also use these methods in class Buffer to serialize a double
into the buffer:
/**
* \param buffer a byte buffer to copy in the internal buffer.
* \param size number of bytes to copy.
*
* Write the data in buffer and advance the iterator position
* by size bytes.
*/
void Write (uint8_t const*buffer, uint32_t size);
/**
* \param buffer buffer to copy data into
* \param size number of bytes to copy
*
* Copy size bytes of data from the internal buffer to the
* input buffer and advance the Iterator by the number of
* bytes read.
*/
void Read (uint8_t *buffer, uint32_t size);
using 'sizeof (double)' as the size. You would need to pass a pointer
to your member variable; something like this:
i.Write (&m_currProSpeed, sizeof (double));