    uint16_t tx_len;
    uint16_t max_rx_len;
  };
  
  const int SPI_MAX_RETRIES = 5;
  const int SPI_ACK_TIMEOUT = 50; // milliseconds
  const std::string SPI_DEVICE = "/dev/spidev0.0";
  
  class LockEx {
  public:
    LockEx(int fd, std::recursive_mutex &m) : fd(fd), m(m) {
 
</s> remove   LockEx lock(spi_fd, hw_lock);
 </s> add  </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   int bulk_transfer(uint8_t endpoint, uint8_t *tx_data, uint16_t tx_len, uint8_t *rx_data, uint16_t rx_len);
 </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); </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);
const int SPI_ACK_TIMEOUT = 500; // milliseconds
    uint16_t tx_len;
    uint16_t max_rx_len;
  };
  
const int SPI_ACK_TIMEOUT = 500; // milliseconds
const int SPI_ACK_TIMEOUT = 500; // milliseconds
  const std::string SPI_DEVICE = "/dev/spidev0.0";
  
  class LockEx {
  public:
    LockEx(int fd, std::recursive_mutex &m) : fd(fd), m(m) {
keep keep keep keep replace replace keep 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/spi.cc