How to convert a byte vector into to a 32bit word vector

How do you convert a vector of 8bit values (bytes) to a vector of 32bit values (words)? Why would you want to do such a thing? Well maybe you have a bytes stream that needs to be sent over a 32bit bus? You could use the std::vector constructor to construct a new vector on the…

Read the full article

Setting up a tap device for QEMU using Yocto in Docker container

Typically it should just work but there are some catches when using a docker container environment. NOTE: You don't need to create a bridge between the host NIC and the TAP device. When you run runqemu the tap device is automatically created to match the subnet of the network interface in the guest OS. See…

Read the full article

C++ Iterating Scoped Enumerations

requirements Map non-integer values to scoped enum literals Use switch statements to catch missing enum cases in value lookup ( -Wswitch-enum allows default case) Use class template to iterate the enum mapped values Limitations Iterator needs to be given begin/end points, so you have to sync this end limit with the last entry in EncapsulatedEnum::Key…

Read the full article

C++ Singleton Enumerated Map

Features Maps enum type literals to strings (or any type) Singleton pattern ensure only single instance Encapsulation checks if key exists to prevent lookup errors/exceptions. C++17 version --std=c++17 -Wall -Wextra…

Read the full article

C++ Serialize Function

Convert an unsigned integer to a vector of bytes (char) The use of function template and argument deduction means you don't need to specialize the function template, you just call it with the unsigned int type and the compiler will deduce the width of the type. The function uses sizeof() to calculate the bitwise shift…

Read the full article