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

ESP32-CAM with ch340g needs other ser-uart signals (Ubuntu 22.04) #41

Open
ghvau opened this issue Apr 28, 2023 · 11 comments
Open

ESP32-CAM with ch340g needs other ser-uart signals (Ubuntu 22.04) #41

ghvau opened this issue Apr 28, 2023 · 11 comments
Labels
done! The answer to this issue is coded Observation Small remark that does not prevent the operation

Comments

@ghvau
Copy link

ghvau commented Apr 28, 2023

With a new ordered ESP32-CAM (with usb mb-board, ch340x !) module I can't get a connection to jama. (-> github source code v1.2.0)
Error: ... device not compatible !

After testing with some other IDEs like Thonny and ESPlorer i get generally the same situation!
But with the ESPlorer I have additionally the possibility the set/clear the interface signals.
I can use the ESPlorer when I clear the signals RTS and DTR !!!

And now: when I start inside jama the device connection function and I see the message "Attempts to connect ..." I start in a second process a small c-prog (ioctl()) and clear both signal -------> and the device was connected !!!
ioctl(fd, TIOCMBIC, &DTR); //clear DTR pin
ioctl(fd, TIOCMBIC, &RTS); //clear RTS pin

It will be nice when you try to open the jama world for the ESP32-CAM or ch340 user with an alternative device open (cleared RTS/DTR).

Addition: Thonny can also configure dtr = False rts = False in his setup file [esp32].

@jczic
Copy link
Owner

jczic commented May 2, 2023

Hello @ghvau, thank you for your feedback!

Just, what OS are you on?

Indeed, I see on pySerial that there can be sometimes particular behaviors of RTS/DSR on certain system.
Could you test by adding the following 2 lines in the file src/esp32Controller.py at line 180,
next to self._isConnected = True :

self._repl.rtscts = False
self._repl.dsrdtr = False

This could perhaps solve the problem?

@jczic jczic added Observation Small remark that does not prevent the operation lite problem This problem is not very important labels May 2, 2023
@ghvau
Copy link
Author

ghvau commented May 2, 2023 via email

@jczic
Copy link
Owner

jczic commented May 2, 2023

Hmm, it seems that the problem comes from a bad support of line support when connecting/reconnecting with the serial port on some hardware.

Actually, disabling the lines is not supposed to be a solution, but check out this discussion with people who had similar strange problems: pyserial/pyserial#124

Because Jama does not use hardware control at all and only 2 wires are used for serial exchange.

@ghvau
Copy link
Author

ghvau commented May 2, 2023

OK, there are maybe some problems with the serial interface (pyserial/pyserial#124),
but here it was a problem with the device (ESP32 with ch340):

With a dynamic trace tool (statserial) I can see the following:
1.When I connect the device, the tty port was created with signals RTS/DTR are high,
2. then I start my c-prog (ioctl()) and set RTS/DTR to low,
3. then I start jama, no change of the RTS/DTR level, still low,
4. then I start the "connect device" command, the RTS/DTR level goes to high,
5. then the error occur "... not compatible" (can overcome when I start c-prog (2.) during "Attempts to connect ...."

If I use a ESP32 with cp2102 the level RTS/DTR are unimportant !
Its for me definitive a problem with the device, which needs a low level.

I know a workaround :-)
Thanks.

@jczic
Copy link
Owner

jczic commented May 2, 2023

Yes I understand but it seems that there can be the level which passes to high by itself during the connection, not because of pySerial but from the serial driver under Linux.
Have you also tried to directly pass rtscts = False and dsrdtr = False as parameters to the creation of the Serial( ....) class next to xonxoff = False?

@ghvau
Copy link
Author

ghvau commented May 3, 2023 via email

@ghvau
Copy link
Author

ghvau commented May 3, 2023

I found a position (~ line 188) , and device will be connected !!!

try :
self.InterruptProgram()
self._repl.setRTS(False) <---------------------
self._repl.setDTR(False) <---------------------
self._switchToRawMode(timeoutSec=connectTimeoutSec)

Device: AI-Thinker ESP32-CAM (clone) + USB MB Board / CH340G, original MP 1.19.1 works now: ->
image

@jczic
Copy link
Owner

jczic commented May 3, 2023

Oh great! Good news :)

I understand then that your device may be to have to reboot after InterruptProgram(...) and set the IOs to HIGH automatically.
Can you try the Reset button in the Jama menu to see if it works well and the device stays connected after it reboot?

Also, just a point: setRTS and setDTR are indicated deprecated in pySerial and are replaced by the 'setters' directly (as I had write above):

self._repl.rtscts = False
self._repl.dsrdtr = False

Does it work the same way if you use this instead?

@jczic jczic added in progress... This problem is being resolved... and removed lite problem This problem is not very important labels May 3, 2023
@ghvau
Copy link
Author

ghvau commented May 3, 2023 via email

@jczic
Copy link
Owner

jczic commented May 3, 2023

Great, thank you @ghvau, I added that in the code and update src.
As this is especially for Linux, I won't compile new binaries for Mac&Win but that's ok.

Commit : d834cda 😉

@jczic jczic added done! The answer to this issue is coded and removed in progress... This problem is being resolved... labels May 3, 2023
@ghvau
Copy link
Author

ghvau commented May 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done! The answer to this issue is coded Observation Small remark that does not prevent the operation
Projects
None yet
Development

No branches or pull requests

2 participants