Based on your specification, 0b0000001x
most likely means "this is a binary number, i.e. a sequence of bits", and x
is the bit you should set or clear according to the current state of the line. Builtin binary literals are only supported in C++14 or above, in C++11 they can be implemented as user-defined literals, in C and older versions of C++ you need to compute the value manually (or you can use a compiler that implements this as a non-standard extension, both gcc and clang do so).
If I'm reading this correctly and the endianness is correct, the resulting byte value should be:
payload[0] = 2 + (is_line_available ? 1 : 0);
Also, you are not allocating any space for payload
and so you'll write into random memory. You need to allocate some memory:
Static allocation, works in both C and C++:
unsigned char payload[24]; // or whatever your message's length is
C-style dynamic allocation (make sure to free it after you're done):
unsigned char *payload = malloc(24);
...;
free(payload);
C++ recommended approach:
#include <vector>
std::vector<unsigned char> payload;
payload.reserve(24);
...;