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

telnet.setConsole() calls UART setup & initializes but doesn't need to #1362

Closed
jgtaylor opened this issue Apr 1, 2018 · 5 comments
Closed
Labels
ESP32 This is only a problem on ESP32-based devices

Comments

@jgtaylor
Copy link

jgtaylor commented Apr 1, 2018

General Issue:

In file jsinteractive.c, line 176, the if statement will always execute for telnet. This results in de-muxing and re-muxing any UART pins that are otherwise assigned (in my case, to I2C1), due to the jshUSARTSetup() call.

It seems that telnet doesn't have DEVICE_INITALIZED_FLAGS set, or is false. It may also be that the ESP32 code isn't setting it correctly, but I'm not well versed in C.

Either way, I've worked around it by adding another if statement around the test for jshDeviceInitialised(device), with a simple:
if (device != EV_TELNET) { ... }
I expect this is a less than ideal solution, but it works (sort of) for now 😄

Random details

I posted on the forum about this, and kept digging around until I found the work-around.

The work-around is not ideal. After connecting via telnet, you can not go back to USART without a reset() (or power off). In my case, this ok because I'm running the device via a wall-wart and not USB.

Also, this may be exclusive to ESP32, but I don't have anything else to verify the issue.

I also noticed that jshardware_common.c only has InitInfo for USART, SPI & I2C. Perhaps something about telnet should go in there? Perhaps not. I assume that if there was something there, the jshIsDeviceInitialised(device) call would return true. again, I'm probably way off.

@jgtaylor
Copy link
Author

jgtaylor commented Apr 2, 2018

So after thinking I'd found a work around because connecting via telnet didn't immediately result in:

ERROR: jshI2CWrite:, Operation timeout because the bus is busy.
ERROR: jshI2CRead:, Operation timeout because the bus is busy.

they showed back up after about 2h38m. Additionally, the console started outputing socket errors (which I wasn't able to capture, unfortunately - though I will try).

This is particularly confusing because power off/on, ESP32.reboot(), nor reset(1) followed by code upload, seems to clear the issue (even temporarily). This is happening with both I2C devices I have access to (BME280 & BH1750).

Now I'm wondering if there is some kind of USART polling that happens somewhere. Also suspect is network code that may be sneaking into the USART address space. I don't know how to even begin looking for the latter, but I'll try figuring something out with the former.

@gfwilliams gfwilliams added the ESP32 This is only a problem on ESP32-based devices label Apr 3, 2018
@wilberforce
Copy link
Member

@jumjum123

This appears to be related to this line:

r = uart_set_pin(uart_num, txpin, rxpin, -1, -1); //Set UART0 pins(TX: IO16, RX: IO17, RTS: IO18, CTS: IO19)

Info form the forum post- update: fails on D17/D16, works on scl: D18, sda: D19.

When the console is on telnet - I think that serial 3 might be assumed here....

@wilberforce
Copy link
Member

@jumjum123
While you are looking at the console switching code - would you be able to review this? When switching to telnet it looks like the uart is getting re-intialised?

@gfwilliams
Copy link
Member

Just tweaked this. Hopefully that'll sort it for you?

@jgtaylor
Copy link
Author

all sorted and works like a charm!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ESP32 This is only a problem on ESP32-based devices
Projects
None yet
Development

No branches or pull requests

3 participants