How to read bits of spi connection by arduino?

Hello, I'm working on code that sends information by SPI from Raspberry Pi to Arduino. This code sends characters to Arduino and everything works very well but I need to read the binary code of SPI connection and show on a serial port before it converts to characters.

Raspberry Pi/code

Arduino /code.

How can I change the Arduino code to read bits of spi connection (before convert)? In fact, in the new project, I need to send the binary code by Raspberry Pi and Arduino to show by LEDs.

Thanks.

Not sure if this is what your looking for. You will need to loop through buf and print each individual byte.

Something like below

void loop (void)
{
  if (process_it)
    {
    buf [pos] = 0;
    for(uint8_t cnt=0;cnt<pos;cnt++)
    {
      Serial.print(buf[cnt], BIN);
      Serial.print(" ");
    }  
    Serial.println();
    pos = 0;
    process_it = false;
    }  // end of flag set
    
} // end of loop

Please be aware that leading zeroes are omitted.

PS
Note that any data is binary.

Also posted at:
https://arduino.stackexchange.com/questions/56206
If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.