rogerclarkmelbourne / Arduino_STM32

Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards
Other
2.52k stars 1.26k forks source link

RTS only updates when DTR changes state #893

Open dalbert2 opened 1 year ago

dalbert2 commented 1 year ago

I wrote a simple sketch to show the state of RTS and it doesn't work as expected. The RTS state is only updated when DTR changes state. Tested on windows 11 using TeraTerm and RealTerm (RealTerm is easier for this)

#include <Arduino.h>

USBSerial serial;

void setup() {
  delay(5000);
  serial.begin();
}

void loop() {
  if (serial.getRTS()) {
      serial.write('R');
  } else {
      serial.write('r');
  }
  delay(1000);
}

Details: In usb_cdcacm.c the state variable line_dtr_rts is updated in usbNoDataSetup() and the line control state, but it doesn't look like that callback is being called when RTS changes state. Any ideas?

If this is unavoidable, USBSerial::getRTS() should probably have a comment to the effect of "Note: RTS only update when DTR changes state"