rjehangir / struct

C++ namespace for converting binary data in byte arrays to typed values mimicking the functionality of the Python "struct" class. The namespace was made primarily for embedded (Arduino) projects where binary data is sent through the serial port, however, the namespace can be used with any C++ code.
MIT License
13 stars 2 forks source link

How to use? #1

Open larsvlent opened 6 years ago

larsvlent commented 6 years ago

I'm using your function in the same way I used them in pyhon but I keep getting error. For your information, PcapPlusPlus made the rawpacket. I hope you can help me screenshot from 2018-10-12 13-43-17

rjehangir commented 6 years ago

Hi Lars,

The notation is a little different than in Python. Try this:

rotation = Struct::unpack<uint16_t>(&packet);

In this case, packet must be a byte array with the two bytes of the uint16_t value. You might have to turn rwpkt into an array for this.

-Rusty