    uint8_t rx_buf[SPI_BUF_SIZE];
    inline static std::recursive_mutex hw_lock;
  
    int wait_for_ack(spi_ioc_transfer &transfer, uint8_t ack);
    int bulk_transfer(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t rx_len);
    int spi_transfer(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t max_rx_len);
    int spi_transfer_retry(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t max_rx_len);
  };
  #endif
 
</s> remove   int spi_transfer_retry(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t max_rx_len);
 </s> add   int spi_transfer_retry(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t max_rx_len, unsigned int timeout); </s> remove const int SPI_MAX_RETRIES = 5;
const int SPI_ACK_TIMEOUT = 50; // milliseconds
 </s> add const int SPI_ACK_TIMEOUT = 500; // milliseconds </s> remove   return spi_transfer_retry(0, (uint8_t *) &packet, sizeof(packet), NULL, 0);
 </s> add   return spi_transfer_retry(0, (uint8_t *) &packet, sizeof(packet), NULL, 0, timeout); </s> remove   LockEx lock(spi_fd, hw_lock);
 </s> add 
  int bulk_transfer(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t rx_len, unsigned int timeout);
    uint8_t rx_buf[SPI_BUF_SIZE];
    inline static std::recursive_mutex hw_lock;
  
    int wait_for_ack(spi_ioc_transfer &transfer, uint8_t ack);
  int bulk_transfer(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t rx_len, unsigned int timeout);
    int spi_transfer(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t max_rx_len);
    int spi_transfer_retry(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t max_rx_len);
  };
  #endif
keep keep keep keep replace keep keep keep keep
 boardd: handle nack on tx buffer full (#28241)

* boardd: handle nack on tx buffer full

* print pandaStates

* rx buffer too small

* connect timeout

---------

Co-authored-by: Comma Device <device@comma.ai> 
selfdrive/boardd/panda_comms.h