Reconfiguring UART during Runtime

#1

I’m having an issue with reconfiguring the UART.

const BAUD = 115200;
uart <- hardware.uartBCAW;
uart.configure(BAUD, 8, PARITY_EVEN, 1, NO_CTSRTS);

I’m currently trying to reconfigure this later with PARITY_NONE.

From research I see that it’s important to call uart.disable() prior to configuring it again. So I’m using a mix of solutions that I’ve found via the Imp forums. I’ve tried another supposedly working solution for reconfiguring with NO_RX and/or NO_TX and it’s not properly working.

function configureEncoder() {
    uart.disable();
    uart.configure(BAUD, 8, PARITY_NONE, 1, NO_RX | NO_TX);
    uart.disable();
    uart.configure(BAUD, 8, PARITY_NONE, 1, NO_CTSRTS);
    server.log("Encoder ready.");
}
#2

Can you say what exactly isn’t properly working here? You shouldn’t have to call configure twice - the configuration should take effect immediately when you call configure.

#3

I reconfigure UARTs on the fly all the time and I haven’t encountered any problem with doing so.
I reconfigure in the following order:

  1. uart.disable()
  2. uart.settxfifosize() and/or uart.setrxfifosize()
  3. uart.configure(…)
  4. uart.flags() // to clear them