This is a case of odd looking casts to take advantage of some C++ function overloading
and how the C standard deals with different 8 bit declarations.
The function println() can take different type of arguments. Depending on the type of argument
it behaves differently.
In this case, the code appears to be wanting to print a C string.
In C, strings are characters terminated by a Null.
The way to get the println() function to print a C string is to pass it a pointer to a char
(char *) which is the first character of the string to be printed.
The tricky part in this case is that buf is declared as a uint8_t and not a char
Had the buffer been declared as a char, i.e:
Then to pass a pointer to a C string that starts at offset 5 you would have simply done:
Which means pass the address of the elemenat at index 5
note: buf is the character
&buf is the address of that character at buf
But since buf is a uint8_t if we passed &buf
that it would end up passing a pointer to a uint8_t (BTW uint8_t is really a typecast an unsigned char)
also note: chars are different from "unsigned chars" and "signed chars".
The C standard defines the 3 as being distinctly unique.
Since the print class wants to see a pointer to char and not a pointer to a uint8_t/"unsigned char" you must do a cast
to override the definition of buf to get the println function to print a C string.
So Serial.println((char*) &buf) means "I know buf is not an array of "char" and but I'm telling you that the
resulting pointer &buf shall be (char *) or a pointer to a char instead of a pointer to a "uint8_t" which is actually
an unsigned char.
hope that helps.