Created
July 2, 2017 22:34
-
-
Save youtalk/3831e80dbf826e2f9399e55baf997b2b to your computer and use it in GitHub Desktop.
FreeRTPS String Serializer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t serialize_std_msgs__string(void *_msg, uint8_t *_buf, uint32_t _buf_size) | |
{ | |
struct std_msgs__string *_s = (struct std_msgs__string *)_msg; | |
uint8_t *_p = _buf; | |
if ((uintptr_t)_p & 3) | |
_p += 4 - ((uintptr_t)_p & 3); | |
uint32_t _data_len = (uint32_t)strlen(_s->data) + 1; | |
*((uint32_t *)_p) = _data_len; | |
_p += 4; | |
memcpy(_p, _s->data, _data_len); | |
_p += _data_len; | |
return _p - _buf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment