src/app/host-serial/libftdi/ftdi.c
int ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)
{
    if (ftdi == NULL || ftdi->usb_dev == NULL)
        ftdi_error_return(-2, "USB device unavailable");

    if (libusb_control_transfer(ftdi->usb_dev, FTDI_DEVICE_OUT_REQTYPE,
                                SIO_RESET_REQUEST, SIO_RESET_PURGE_RX,
                                ftdi->index, NULL, 0, ftdi->usb_write_timeout) < 0)
        ftdi_error_return(-1, "FTDI purge of RX buffer failed");

    // Invalidate data in the readbuffer
    ftdi->readbuffer_offset = 0;
    ftdi->readbuffer_remaining = 0;

    return 0;
}
/**
    Clears the read buffer on the chip and the internal read buffer.

    \param ftdi pointer to ftdi_context

    \retval  0: all fine
    \retval -1: read buffer purge failed
    \retval -2: USB device unavailable
*/
Clears the read buffer on the chip and the internal read buffer.
\param ftdi pointer to ftdi_context

\retval  0: all fine
\retval -1: read buffer purge failed
\retval -2: USB device unavailable
Clears the read buffer on the chip and the internal read buffer . \ param ftdi pointer to ftdi_context \ retval 0 : all fine \ retval - 1 : read buffer purge failed \ retval - 2 : USB device unavailable
int ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)
{
    if (ftdi == NULL || ftdi->usb_dev == NULL)
        ftdi_error_return(-2, "USB device unavailable");
    if (libusb_control_transfer(ftdi->usb_dev, FTDI_DEVICE_OUT_REQTYPE,
                                SIO_RESET_REQUEST, SIO_RESET_PURGE_RX,
                                ftdi->index, NULL, 0, ftdi->usb_write_timeout) < 0)
        ftdi_error_return(-1, "FTDI purge of RX buffer failed");
    ftdi->readbuffer_offset = 0;
    ftdi->readbuffer_remaining = 0;
    return 0;
}
int ftdi_usb_purge_rx_buffer ( struct ftdi_context * ftdi ) { if ( ftdi == NULL || ftdi -> usb_dev == NULL ) ftdi_error_return ( -2 , " " ) ; if ( libusb_control_transfer ( ftdi -> usb_dev , FTDI_DEVICE_OUT_REQTYPE , SIO_RESET_REQUEST , SIO_RESET_PURGE_RX , ftdi -> index , NULL , 0 , ftdi -> usb_write_timeout ) < 0 ) ftdi_error_return ( -1 , " " ) ; ftdi -> readbuffer_offset = 0 ; ftdi -> readbuffer_remaining = 0 ; return 0 ; }
Clears the read buffer on the chip and the internal read buffer.
Clears the read buffer on the chip and the internal read buffer .
// Invalidate data in the readbuffer