Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UART Loopback doesn't work on 2.0.2 #6126

Closed
1 task done
SuGlider opened this issue Jan 11, 2022 · 5 comments · Fixed by #6133
Closed
1 task done

UART Loopback doesn't work on 2.0.2 #6126

SuGlider opened this issue Jan 11, 2022 · 5 comments · Fixed by #6133
Assignees
Labels
Milestone

Comments

@SuGlider
Copy link
Collaborator

SuGlider commented Jan 11, 2022

Related Information

#5549 (comment)

Board

ESP32, ESP32-S2 and ESP32-C3

Hardware Configuration

ESP32 - loopback on UART2 : TX2 <--> RX2
ESP32-S2 and ESP32-C3 - loopback on UART1 : TX1 <--> RX1

Description

When trying to send data in a UART loopback configuration, it fails and nothing is read.
Using Arduino Core 2.0.0 and 2.0.1 - it works fine. The issue is with v2.0.2
Most problably something related to last change on support to MODBUS #6026

Sketch

HardwareSerial LOOPBACK_UART(2);  // UART2 on ESP32 and UART1 on S2/C3

void setup() {
  Serial.begin(115200);
  LOOPBACK_UART.begin(115200);

  Serial.println("Serial Port 0 - Testing");
}


void loop() {
  static uint8_t count = 0;

  //Shorted Pins TX<->RX using ESP32/UART2 or S2/C3/UART1
  LOOPBACK_UART.write('0' + count);
  if (LOOPBACK_UART.available()) {
    Serial.write(LOOPBACK_UART.read());
  }
  count++;
  if ('0' + count > 'Z') {
    count = 0;
    LOOPBACK_UART.println();
  }
  delay(100);
}

Debug Message

Correct Output should be:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1420
ho 0 tail 12 room 4
load:0x40078000,len:13540
load:0x40080400,len:3604
entry 0x400805f0
Serial Port 0 - Testing
0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ

but with v2.0.2 there is no output after the message Serial Port 0 - Testing

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@SuGlider
Copy link
Collaborator Author

https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-uart.c#L157

Yes, This was removed in #6133.
This change, along, with MODBUS issue, is solved also in #6133

@chegewara
Copy link
Contributor

Yes, i found the PR right after posting the link.

@collin80
Copy link
Contributor

I'd like to also complain about hitting this issue. Manually applying #6133 does fix it. My problem was a Tesla Model S module sketch. The modules speak serial at 612.5k and you send on TX to the bank of modules which send from one to the other then loop all the way back to RX. I would not call this loopback. Loopback tends to suggest that TX is directly connected to RX by a wire with nothing in between or the hardware is directly doing this. No, this is more like token ring where the signal flows from device to device and ends up back where it started. But, really, the issue is one of full duplex. No matter what anyone says, the offending code in V2.02 most certainly puts the hardware into half duplex and this doesn't work if you have both wires active at once whether that's because the signal from TX is looping back or whether it is because you otherwise have full duplex for some other reason. So, the issue is fixed but that doesn't do normal users any good since there has not been another release. So, hopefully my verbose complaint helps anyone else searching for answers.

@SuGlider
Copy link
Collaborator Author

Thank you for the comment.

We will release 2.0.3 in a week or two and it will have the fix #6133 and others more new features.

Please stay tuned!
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

4 participants