Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24494 > unrolled thread

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

Started by"Adam" <adam@no_thanks.com>
First post2012-06-26 21:12 -0700
Last post2012-06-27 14:53 +0000
Articles 3 on this page of 23 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-26 21:12 -0700
    Re: PySerial could not open port COM4: [Error 5] Access is denied - please help John Nagle <nagle@animats.com> - 2012-06-26 22:33 -0700
      Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 02:10 -0700
        Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Paul <nospam@needed.com> - 2012-06-27 08:28 -0400
          Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 08:26 -0700
            Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Paul <nospam@needed.com> - 2012-06-27 12:04 -0400
              Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 10:41 -0700
                Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Paul <nospam@needed.com> - 2012-06-27 14:04 -0400
                  Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 13:40 -0700
                    Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Grant Edwards <invalid@invalid.invalid> - 2012-06-27 21:18 +0000
                      Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 14:48 -0700
                        Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Grant Edwards <invalid@invalid.invalid> - 2012-06-27 22:06 +0000
                          Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Grant Edwards <invalid@invalid.invalid> - 2012-06-27 22:18 +0000
                            Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Temia Eszteri <lamialily@cleverpun.com> - 2012-06-27 15:31 -0700
                              Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 15:51 -0700
                                Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Grant Edwards <invalid@invalid.invalid> - 2012-06-27 23:24 +0000
                                  Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-27 17:14 -0700
                                    Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Grant Edwards <invalid@invalid.invalid> - 2012-06-28 14:15 +0000
                                      Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "Adam" <adam@no_thanks.com> - 2012-06-28 13:31 -0700
                              Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Roel Schroeven <roel@roelschroeven.net> - 2012-06-28 21:08 +0200
                                Re: PySerial could not open port COM4: [Error 5] Access is denied- please help "Adam" <adam@no_thanks.com> - 2012-06-28 14:48 -0700
        Re: PySerial could not open port COM4: [Error 5] Access is denied - please help "David H. Lipman" <DLipman~nospam~@Verizon.Net> - 2012-06-27 08:28 -0400
          Re: PySerial could not open port COM4: [Error 5] Access is denied - please help Grant Edwards <invalid@invalid.invalid> - 2012-06-27 14:53 +0000

Page 2 of 2 — ← Prev page 1 [2]


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

From"Adam" <adam@no_thanks.com>
Date2012-06-28 14:48 -0700
SubjectRe: PySerial could not open port COM4: [Error 5] Access is denied- please help
Message-ID<jsijer$ick$1@dont-email.me>
In reply to#24632
"Roel Schroeven" <roel@roelschroeven.net> wrote in message 
news:mailman.1618.1340910525.4697.python-list@python.org...
> Temia Eszteri schreef:
>> Actually, I believe someone in an earlier thread in the newsgroup or
>> elsewhere pointed out that serial ports automatically open under
>> Windows. I'd have to look it back up when I have the time, which I
>> don't have at the moment, unfortunately.
>
> That doesn't have anything to do with Windows, but with how pySerial 
> works. See the documentation for __init__():
>
> "The port is immediately opened on object creation, when a port is given. 
> It is not opened when port is None and a successive call to open() will be 
> needed."
>
> So if your script does something like
>
> prt = serial.Serial('COM4')
>
> then pySerial automatically opens the port, and you shouldn't call 
> prt.open() anymore.
>
> If, on the contrary, you do something like
>
> prt = serial.Serial()
> prt.port = 'COM4'
>
> then pySerial doesn't open the port, and you have to call prt.open() to do 
> it.
>
> PySerial has this same behavior on both Windows and Linux. The difference 
> might be that on Linux it is possible to open serial ports more than once, 
> while that doesn't work on Windows.
>
> Best regards,
> Roel
>


Thanks for the info.  Your explanation helps a lot.


[toc] | [prev] | [next] | [standalone]


#24507

From"David H. Lipman" <DLipman~nospam~@Verizon.Net>
Date2012-06-27 08:28 -0400
Message-ID<M6ydnb5ji7wYYXfSnZ2dnUVZ_t-dnZ2d@giganews.com>
In reply to#24498
From: "Adam" <adam@no_thanks.com>

>
> "John Nagle" <nagle@animats.com> wrote in message 
> news:jse604$1cq$1@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.
>

Then it is a Virtual COM port.  Often software will want to communicate 
directly to the COM4 port which is usually at: IRQ3 and I/O 2E8h.

-- 
Dave
Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
http://www.pctipp.ch/downloads/dl/35905.asp 

[toc] | [prev] | [next] | [standalone]


#24519

FromGrant Edwards <invalid@invalid.invalid>
Date2012-06-27 14:53 +0000
Message-ID<jsf6ph$sf9$1@reader1.panix.com>
In reply to#24507
On 2012-06-27, David H. Lipman <DLipman~nospam~@Verizon.Net> wrote:
> From: "Adam" <adam@no_thanks.com>
>> "John Nagle" <nagle@animats.com> wrote in message 
>> news:jse604$1cq$1@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.

Except he says it _does_ work with his terminal emulator.

>>> What is "COM4", anyway?   Few machines today actually have four
>>> serial ports.  Is some device emulating a serial port?

It shouldn't matter.  If other apps can open COM4, then pyserial
should be able to open COM4.

>> 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.
>
> Then it is a Virtual COM port. Often software will want to
> communicate directly to the COM4 port which is usually at: IRQ3 and
> I/O 2E8h.

Pyserial doesn't do that.  It uses the standard win32 serial API, and
it should work just fine with any Win32 serial device (what you call a
"virtual" COM port).

-- 
Grant Edwards               grant.b.edwards        Yow! World War III?
                                  at               No thanks!
                              gmail.com            

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web