-
Notifications
You must be signed in to change notification settings - Fork 161
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
ampy can't open Windows COM port numbers above 10 #6
Comments
Ah thanks for digging into it further, yeah that's annoying that Windows seems to treat COM ports above 9 so differently with path names. I just added a similar workaround function to the latest 1.0 version of ampy, and it should be up on PyPi in ~10 minutes too. I haven't fully tested it yet since I don't have a COM10 device handy, can you install the latest ampy and see if it repros? You can force an update with:
Thanks again and apologies it took a while to look at this issue! |
Hi tdicola, I am still having the same trouble with ampy. I have version 1.07. Can you help.
C:\Users\mikel>ampy --port COM16 put main.py |
I saw the code you have implemented. def windows_full_port_name(portname): The format seems to be correct. Maybe this is a problem when my Putty is also connected to the device C:\Users\mikel>ampy --port COM16 put main.py |
Ampy was able to flash the device with my main.py one time today. For that time, it did not generate any error. The main.py program runs good because it prints the message. Since then, I cannot duplicate the same success again. I am going to reboot my PC and see if it helps. |
Same error "could not enter raw repl.' |
I have found the solution in this recent post. dhylands/rshell#27 The solution works consistently. I was confused with COM1x issue. It turns out to be the reset problem. --------------------------------------hyper99 commented on Oct 4, 2018------------------------------------- |
I have multiple USB hubs on my Windows PC and a fair number of USB devices. For some reason Python needs to see Windows port names with numbers above 10 in a non-obvious format or they will not be opened. For example, COM24 needs to be depicted as \.\COM24 or the open attempt will fail. The ampy utility doesn't take this into account, and it would not open the USB port my esp8266 is attached to.
I did a little looking around and found a function that can return a correctly formatted COM name;
import re
import serial
def full_port_name(portname):
""" Given a port-name (of the form COM7,
COM12, CNCA0, etc.) returns a full
name suitable for opening with the
Serial class.
"""
m = re.match('^COM(\d+)$', portname)
if m and int(m.group(1)) > 10:
portname = '\\.\' + portname
return portname
pn = full_port_name('COM24')
print pn
So I put that in cli.py and modified the cli() function as follows;
`def cli(port, baud):
"""ampy - Adafruit MicroPython Tool
The text was updated successfully, but these errors were encountered: