JetBrains / intellij-micropython

Plugin for MicroPython devices in PyCharm and IntelliJ
https://plugins.jetbrains.com/plugin/9777-micropython
Apache License 2.0
514 stars 107 forks source link

Exception on flushing files to Pyboard: PyboardError: failed to access COM3 #169

Open hcet14 opened 3 years ago

hcet14 commented 3 years ago

Please try to fix https://github.com/vlasovskikh/intellij-micropython/issues/120#issuecomment-872582972 it shouldn't have been closed. I started with pycharm and the micropython plugin a couple of days ago. Great stuff. Keep it up! I'm unable to solve the problem and couldn't find any information which helps. I'm not a programmer. Please see also https://forum.micropython.org/viewtopic.php?f=15&t=10771

jdjjm commented 3 years ago

That issue does not need to be reopened, it has been solved. You are doing the same thing that AstroDabb was. You are running a micropython script with regular python instead of uploading it to a microcontroller. Once you have enabled micropython support (I assume you have since you can access the REPL), you need to right click your main.py and choose Run Flash main.py. These instructions are listed in the readme file for the plugin.

Its a good idea to familiarise yourself with the IDE you are using before starting a project. This is the documentation for Run Configurations in PyCharm (How any code is run with PyCharm) Keep in mind with micropython, you are not running the code directly, instead you are running an upload script to put your code on your microcontroller.

vlasovskikh commented 3 years ago

@hcet14 The problem you have (PyboardError: failed to access COM3) is not related to the original problem of issue #120. That issue was about some confusion with which run configuration to use: Python or MicroPython.

I'll update this issue so it reflects the issue you have if you don't mind.

vlasovskikh commented 3 years ago

@hcet14 I don't have a Pyboard device and a Windows machine at hand, so I cannot reproduce your issue. The MicroPython plugin actually tells the exact command it runs to flash files to your device. It's the first line in the Run tool window:

...\python.exe ...\microupload.py [parameters...]

You might experiment with running microupload.py and try to debug the issue.

To other Pyboard users: any help on reproducing and fixing the issue is appreciated.

jdjjm commented 3 years ago

@vlasovskikh I do not believe what @hcet14 is seeing is a bug. Take a look at the micropython.com Forum post he made. It shows some pictures and you can see that he is running the script with pure python, not flashing it to the microcontroller. He just need to change his run configurations and I think he will be good to go.

vlasovskikh commented 3 years ago

@jdjjm In the comment by @hcet14 in #120 (July 2) they show a screenshot where they run a MicroPython run configuration: it's microupload.py with the corresponding parameters.

jdjjm commented 3 years ago

@vlasovskikh Woops, I missed those screenshots. Looks like this might be a bug.

Have you thought about when you create the Pyboard object setting the wait argument to something other than 0? I believe this will attempt multiple requests at connecting before throwing the error. Maybe an extra couple of attempts with a short delay (Looks like 1 second between attempts from pyboard.py) might solve a few of these connection issues people have been facing.