Giter VIP home page Giter VIP logo

Comments (4)

fluffy avatar fluffy commented on June 25, 2024

In the above code, where you set the ser.dtr etc, when I look at the output of the DTR and RTS pins on a max connected to a CH340 USB to serial device, I still see the DTR and RTS go high for 20 ms when the port opens before they get forced low. So the problem might be bigger than just missing in the open function call.

from pyserial.

gitcnd avatar gitcnd commented on June 25, 2024

Try a second time - I notice the first call when you reboot your PC (or connect a new device) does that. From then on, it behaves.
I'm using WSL1 on Windows 10N on a RoG laptop, and CH340USB ESP32CAM - the above fix solved all my rebooting and lockup problems.

I notice the code for mpremote and pyboard on micropython already implements the same workaround when they detect windows (with a comment about ES32 and ESP8266 RTS issues), so it appears to also have solved the problem for other people on other devices as well.

On a philosophical topic instead now though: since there does exist dtr and rts state-setting "methods", it does seem to be an obvious oversight that someone forgot to allow those to be set inside the constructor. The code which opens the port has to make a decision about whether "high" or "low" should be the initial state for those pins - but without any way for us to tell it.

from pyserial.

fluffy avatar fluffy commented on June 25, 2024

I get what you are saying about constructor has to choose something. I'm looking at the posix code that is used on mac, linux, unix. I'm not how different the windows is as I don't have an easy way to test that. I could be wrong but it looks like the code has to open a socket, then it can call an ioctl on that socket to set the values of RTS / DTR. As soon as the sockets opens, the lines seem to go high. I can't see any way of setting them before the open call. The ioctl can then set them low or high. When the socket is closed, it looks like the default behavior is to set them low but it might be the case that if the "HUPCL" ( no hangup on close ) options is set correctly that they can stay high after the socket closes. This would keep them from going low again when the device gets opened again.

I know on the ESP32, most people use a two transistor circuit for this. You can see it in the thread on https://forum.micropython.org/viewtopic.php?t=4607

Anyways, just poking around on this and trying to sort it out and I hope there is some way to control the RTS and DTR when the open happens but no idea what it is.

from pyserial.

gitcnd avatar gitcnd commented on June 25, 2024

I'm in Ubuntu under WSL1 on Windows, so I wonder if my experience is different to plain linux ?

Can you explain what you mean by "socket" ? (Did you mean "Device" instead?). Here's what perplexity thinks:

https://www.perplexity.ai/search/C-code-in-4ELrwOKlQ1yLK42leua5Dw?s=c

from pyserial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.