10 years, 2 months ago.

Serial Port flow control

The compiler thinks the identifiers RTSCTS etc. are undefined in the following code but they are defined in "SerialBase.h" which is included. Advice ?? :

  1. include "mbed.h"
  2. include "SerialBase.h"

Serial pc(USBTX, USBRX);

int main() {

setup serial port pc.baud(115200); set baud rate pc.set_flow_control(RTSCTS,RTS,CTS);

while(1) { pc.putc(pc.getc()); wait for any character }

}

2 Answers

10 years, 2 months ago.

Insert <<code>> and <</code>> tags around your code (each on its own separate line) to get proper formatted code on the wiki site. Your problem can be fixed by using the Class name for the defined values. Use Serial::RTSCTS. The other parameters are pinnames and need a valid pin. Note however that you cant use this function on the original mbeds since the pins neeeded for rts and cts are not externally accessible.

Accepted Answer

True about the hardware pins, however it should automatically use software flow control if other pins are used, or an UART without hardware flow control.

Also it is implemented on the LPC1768, but on many others it isn't yet implemented.

posted by Erik - 20 Mar 2014
John Brydon
poster
10 years, 2 months ago.

NB the code didn't paste properly into my previous question - the hash-includes do start with a hash sign and not a number !