These are chat archives for SmingHub/Sming

20th
Jul 2017
BotoX
@BotoX
Jul 20 2017 20:31
Hi, I'm wondering if there is any better way than callbacks for doing request->response UART communication with another device.
Since there is no yield() I can't really "wait" for the data, so I have to gather all the data in the StreamDataReceivedDelegate and continue there
which makes it really ugly to write APIs for devices
eg. bool loginToDevice(password) becomes void loginToDevice(password, fn *ResponseCallback)
BotoX
@BotoX
Jul 20 2017 21:30
/** @brief  Clear the serial port receive buffer
      *  @note   All received data is removed from the serial port buffer
     */
void HardwareSerial::flush()
{
    if(!uart || !uart_tx_enabled(uart)) {
        return;
    }

    uart_wait_tx_empty(uart);
}
This is certainly wrong? It says clear the receive buffer but actually waits for the tx buffer to empty...