PySerial could not open port COM4: [Error 5] Access is denied - please help

Adam adam at no_thanks.com
Wed Jun 27 13:41:46 EDT 2012


"Paul" <nospam at needed.com> wrote in message 
news:jsfatv$djt$1 at dont-email.me...
> Adam wrote:
>> "Paul" <nospam at needed.com> wrote in message 
>> news:jseu9c$sp3$1 at dont-email.me...
>>> Adam wrote:
>>>> "John Nagle" <nagle at animats.com> wrote in message 
>>>> news:jse6041ドルcq$1 at dont-email.me...
>>>>> On 6/26/2012 9:12 PM, Adam wrote:
>>>>>> Host OS: Ubuntu 10.04 LTS
>>>>>> Guest OS: Windows XP Pro SP3
>>>>>>>>>>>>>>>>>> I am able to open port COM4 with Terminal emulator.
>>>>>>>>>>>> So, what can cause PySerial to generate the following error ...
>>>>>>>>>>>> C:\Wattcher>python wattcher.py
>>>>>> Traceback (most recent call last):
>>>>>> File "wattcher.py", line 56, in <module>
>>>>>> ser.open()
>>>>>> File "C:\Python25\Lib\site-packages\serial\serialwin32.py", line 
>>>>>> 56, in
>>>>>> open
>>>>>> raise SerialException("could not open port %s: %s" % 
>>>>>> (self.portstr,
>>>>>> ctypes.WinError()))
>>>>>> serial.serialutil.SerialException: could not open port COM4: [Error 
>>>>>> 5]
>>>>>> Access is denied.
>>>>> Are you trying to access serial ports from a virtual machine?
>>>>> Which virtual machine environment? Xen? VMware? QEmu? VirtualBox?
>>>>> I wouldn't expect that to work in most of those.
>>>>>>>>>> What is "COM4", anyway? Few machines today actually have four
>>>>> serial ports. Is some device emulating a serial port?
>>>>>>>>>> John Nagle
>>>>>>>>> Thanks, and yes, I am using VirtualBox. My laptop does not have a 
>>>> serial port so
>>>> I use a USB-to-serial converter, which is assigned COM4.
>>>>>>> Doesn't VirtualBox allow "remapping" serial ports ? I thought you
>>> could have COM 4 in the host OS, and make it COM 1 or COM 2 in
>>> the guest. Something like that.
>>>>>> http://virtuatopia.com/images/6/60/Virtualbox_serial_port_settings.jpg
>>>>>> Also, Windows (as a host), is notorious for stealing control of
>>> COM ports. Even Windows software, when you run it, would report
>>> "COM 4 is busy". Then, you have to track down *why* it's busy.
>>> Is it that FAX software you installed ? The GPS software
>>> that talks to your GPS serial interface ?
>>>>>> In theory, the "Handle" program is supposed to identify what
>>> is keeping a COM port busy, but I don't get the desired
>>> results from it very often. You need to know the naming
>>> convention for virtual COM ports (COM4 via USB to serial, is
>>> more virtual than physical). That's what makes it harder
>>> to track down.
>>>>>> These are some names for COM ports, in Windows. The last two entries,
>>> are my USB to serial adapters. VCP1 functions as COM3.
>>> VCP0 functions as COM4. The VCP part is what would be
>>> listed in "Handle" from Sysinternals. The \device\serial
>>> format, is more likely to be used with true "native"
>>> motherboard serial ports.
>>>>>> \device\serial
>>>>>> ups.exe pid: 1072 NT AUTHORITY\SYSTEM
>>> 98: File (---) \Device\VCP0
>>> hypertrm.exe pid: 3404 ComputerName\UserID (claims to use COM3)
>>> E0: File (---) \Device\VCP1
>>>>>> You can download "Handle" and play with it here.
>>>>>> http://technet.microsoft.com/en-us/sysinternals/bb896655
>>>>>> Note that, in my Handle results, at the time I was running
>>> the Windows provided ups.exe to talk to my external UPS
>>> (uninterruptible power supply). So that's what that
>>> reference is. The "hypertrm" one, is me using the
>>> built-in Windows terminal software, to talk to COM3,
>>> to keep the port artificially busy for the purposes
>>> of testing.
>>>>>> If things were working well in your case, you *might*
>>> see something of this form. If not, you'd instead
>>> see the name of the process that has "stolen" the
>>> com port.
>>>>>> virtualbox.exe pid: 1234 ComputerName\UserID
>>> E0: File (---) \Device\VCP0
>>>>>> HTH,
>>> Paul
>>>>>> Thanks (Guru Paul), I've been using the USB-to-serial converter 
>> successfully without
>> enabling/remapping via VBox Settings=>Serial Ports (which are both "not" 
>> enabled).
>> I can see the serial port COM4 under Device Manager though. So, maybe 
>> enabling is
>> necessary when the host has "native" serial ports, which my laptop does 
>> not have.
>>>> From the output generated by Handle.exe, here's the section for TeraTerm 
>> ...
>> ------------------------------------------------------------------------------
>> ttermpro.exe pid: 596 VBOX_WINXPPRO\adam (claims to use COM4)
>> C: File (RW-) D:\downloads\Tera Term Pro\ttpro313
>> 2C: Section \BaseNamedObjects\ttset_memfilemap
>> 44: File (RW-) 
>> C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
>> 54: File (RW-) 
>> C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
>> 70: Section 
>> \BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004
>> 78: File (RWD) 
>> C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
>> AC: Section 
>> \BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
>> 100: Section 
>> \BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
>> 108: File (RW-) D:\downloads\Tera Term Pro\ttpro313\httplog.log
>> 120: Section 
>> \BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004SFM.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004
>> 128: Section \BaseNamedObjects\ShimSharedMemory
>> 138: Section \BaseNamedObjects\MSCTF.Shared.SFM.IAB
>> ------------------------------------------------------------------------------
>> For Handle to give a positive result, the TeraTerm program would need to
> currently have the serial port open. If you haven't started a terminal 
> session,
> it might not be listed.
>> Handle has some kind of filter function, and you can try searching for the 
> name
> of the port that way.
>> I don't see anything in that snipping, which looks like a serial port.
>> Paul

Okay, this time I am sure that serial port COM4 is open and
receiving data via telnet.exe (also listed below).
>From the output generated by Handle.exe, here's the sections for TeraTerm & 
Telnet ..
------------------------------------------------------------------------------
ttermpro.exe pid: 3808 VBOX_WINXPPRO\adam (claims to use COM4)
 C: File (RW-) D:\downloads\Tera Term Pro\ttpro313
 2C: Section \BaseNamedObjects\ttset_memfilemap
 44: File (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
 54: File (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
 70: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004
 78: File (RWD) C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
 AC: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
 100: Section 
\BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
 108: File (RW-) D:\downloads\Tera Term Pro\ttpro313\httplog.log
 120: Section 
\BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004SFM.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004
 128: Section \BaseNamedObjects\ShimSharedMemory
 138: Section \BaseNamedObjects\MSCTF.Shared.SFM.IN
 150: Section \BaseNamedObjects\MSCTF.Shared.SFM.IIM
------------------------------------------------------------------------------
telnet.exe pid: 2408 VBOX_WINXPPRO\adam
 D8: File (RW-) D:\Handle
 6EC: Section \BaseNamedObjects\ShimSharedMemory
 6F4: Section 
\BaseNamedObjects\CTF.TimListCache.FMPDefaultS-1-5-21-1801674531-1078145449-1957994488-1004SFM.DefaultS-1-5-21-1801674531-1078145449-1957994488-1004
 710: Section 
\BaseNamedObjects\CiceroSharedMemDefaultS-1-5-21-1801674531-1078145449-1957994488-1004
 740: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_A32_0_1c98aa70f70ec00_77dd_S-1-5-21-1801674531-1078145449-1957994488-1004
 774: File (RWD) C:\DOCUME~1\adam\LOCALS~1\Temp\IswTmp\Logs\ISWSHEX.swl
 77C: Section 
\BaseNamedObjects\_ISWINTERNAL_EPT32_SHEX_K32_0_1c9aa25ea688500_7c80_S-1-5-21-1801674531-1078145449-1957994488-1004
 798: File (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86
 79C: File (RW-) 
C:\WINDOWS.0\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
------------------------------------------------------------------------------
usage: handle [[-a [-l]] [-u] | [-c <handle> [-y]] | [-s]] [-p 
<process>|<pid>] [name]
 -a Dump all handle information.
 -l Just show pagefile-backed section handles.
 -c Closes the specified handle (interpreted as a hexadecimal number).
 You must specify the process by its PID.
 WARNING: Closing handles can cause application or system 
instability.
 -y Don't prompt for close handle confirmation.
 -s Print count of each type of handle open.
 -u Show the owning user name when searching for handles.
 -p Dump handles belonging to process (partial name accepted).
 name Search for handles to objects with <name> (fragment accepted).
No arguments will dump all file references.
Handle type summary:
 Desktop : 56
 Directory : 165
 Event : 3470
 File : 1463
 IoCompletion : 142
 Job : 1
 Key : 1540
 KeyedEvent : 49
 Mutant : 632
 Port : 566
 Process : 221
 Section : 373
 Semaphore : 1327
 SymbolicLink : 2
 Thread : 1009
 Timer : 46
 Token : 93
 WaitablePort : 3
 WindowStation : 99
 WmiGuid : 98
Total handles: 11355
This is a tough one.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /