vendredi 28 août 2020

How to serialize a buffer

I am given with a buffer of bytes like {0x01, 0x02, 0x02, 0x02, 0x12, 0x01, 0x02, 0x06, 0x01, 0x02, 0x03, 0x04, 0x02, 0x02, 0x12, 0x07, 0x08, 0x06, 0x09, 0x0A, 0x0B, 0x0C} here first byte stands for data type in this case 0x01 which stands for an array next byte is 0x02 means number of elements in the array, i. e. Here it is 2 means this array contains 2 elements, from next byte elements of array start in which first byte represent the datatypes followed by data in this case it is 0x02 which means a structure, next byte 0x02 means number of elements are 2 in this structure after that first element of the structure starts, 0x12 means unsigned int that has 2 bytes 0x01, 0x02, after that second element of the structure that is 0x06 which means unsigned long and has 4 bytes after that 2nd element of the array start that is again a structure same as first element of array.

In short, this buffer is a collection of different data types along with their data. Can some one help me to serialize this buffer.

Aucun commentaire:

Enregistrer un commentaire