Re: [Tutor] Pyserial and invalid handle

2010-12-22 Thread Cheeng Shu Chin
Hi all,
Last few days ago,
I facing the same issue with my windows 7 64bit...
it work well with windows XP 32-bit...
FYI, I’m using python 2.6 amd64 bit as my core programming tools
currently, I’m start study/learn some arduino robotic and rewrite 
Python-Arduino API
I just do a quick anatomy to the Pyserial code and diff. of the (Ctypes) Handle 
range...
found both are diff range with same Kernel32 dll function call,
for 64-bit, ctypes.wintypes.HANDLE(-1) ==> c_void_p(18446744073709551615L)
in 32 bit, give c_void_p(4294967295L)
so what I guest it cause by Platform and environments issues. 
below is what I did and modifies on 64-bit server:
  a.. win32.py (C:\Python26\Lib\site-packages\serial) 
a.. use HRESULT to replace HANDLE for kernel32 function handle return
  b.. serialwin32.py (C:\Python26\Lib\site-packages\serial) 
a.. use win32file, pywintypes, win32event to rewrite readfile and writefile 
function
it seem work now for my 64-bit server, somehow I didn’t put some effort on 
self.timeout == 0 for serial as I don’t have enough time for it
that I will leave it back to Pyserial Owner to take the honor for that

hope this will help to all open source member... (that why I’m like python most)

Regards,
Cheeng Shu Chin
#! python
# Python Serial Port Extension for Win32, Linux, BSD, Jython
# serial driver for win32
# see __init__.py
#
# (C) 2001-2009 Chris Liechti 
# this is distributed under a free software license, see license.txt
#
# Initial patch to use ctypes by Giovanni Bajo 

import ctypes
import win32
import win32file
import pywintypes
import win32event
#from ctypes.wintypes import HWND
from serialutil import *
#from pywin32_testutil import str2bytes


def device(portnum):
"""Turn a port number into a device name"""
return 'COM%d' % (portnum+1) # numbers are transformed to a string


class Win32Serial(SerialBase):
"""Serial port implementation for Win32 based on ctypes."""

BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
 9600, 19200, 38400, 57600, 115200)

def __init__(self, *args, **kwargs):
self.hComPort = None
SerialBase.__init__(self, *args, **kwargs)

def open(self):
"""Open port with current settings. This may throw a SerialException
   if the port cannot be opened."""
if self._port is None:
raise SerialException("Port must be configured before it can be 
used.")
# the "\\.\COMx" format is required for devices other than COM1-COM8
# not all versions of windows seem to support this properly
# so that the first few ports are used with the DOS device name
port = self.portstr
try:
if port.upper().startswith('COM') and int(port[3:]) > 8:
port = '.\\' + port
except ValueError:
# for like COMnotanumber
pass
self.hComPort = win32.CreateFile(port,
   win32.GENERIC_READ | win32.GENERIC_WRITE,
   0, # exclusive access
   None, # no security
   win32.OPEN_EXISTING,
   win32.FILE_ATTRIBUTE_NORMAL | win32.FILE_FLAG_OVERLAPPED,
   0)
#self.pComPort=pywintypes.HANDLE(self.hComPort)
#self.cComPort=HWND(self.hComPort)
#print ctypes.sizeof(self.pComPort)
#print ctypes.sizeof(self.hComPort)
if self.hComPort == win32.INVALID_HANDLE_VALUE:
self.hComPort = None# 'cause __del__ is called anyway
raise SerialException("could not open port %s: %s" % (self.portstr, 
ctypes.WinError()))

# Setup a 4k buffer
win32.SetupComm(self.hComPort, 4096, 4096)

# Save original timeout values:
self._orgTimeouts = win32.COMMTIMEOUTS()
win32.GetCommTimeouts(self.hComPort, ctypes.byref(self._orgTimeouts))

self._rtsState = win32.RTS_CONTROL_ENABLE
self._dtrState = win32.DTR_CONTROL_ENABLE

self._reconfigurePort()

# Clear buffers:
# Remove anything that was there
win32.PurgeComm(self.hComPort,
win32.PURGE_TXCLEAR | win32.PURGE_TXABORT |
win32.PURGE_RXCLEAR | win32.PURGE_RXABORT)

self._overlappedRead = win32.OVERLAPPED()
self._overlappedRead.hEvent = win32.CreateEvent(None, 1, 0, None)
self._overlappedWrite = win32.OVERLAPPED()
#~ self._overlappedWrite.hEvent = win32.CreateEvent(None, 1, 0, None)
self._overlappedWrite.hEvent = win32.CreateEvent(None, 0, 0, None)
self._isOpen = True

def _reconfigurePort(self):
"""Set communication parameters on opened port."""
if not self.hComPort:
raise SerialException("Can only operate on a valid port handle")

# Set Windows timeout values
# timeouts is a tuple with the following items:
# (ReadIntervalTimeout,ReadTotalTimeoutMultiplier,
#  ReadTotalTimeoutConst

Re: [Tutor] Pyserial and invalid handle

2010-12-02 Thread Terry Carroll

On Wed, 1 Dec 2010, Walter Prins wrote:


But whatever the case may be, suffice it to say I've reproduced your issue
on my Win7 64bit box, and then resolved it by installing the PyWin32
modules.


I'd like to put in a plug for Activestate Python here.  Activestate has a 
free distribution of Python for Windows that not only includes the basic 
Python program and libraries, but also commonly used extras including the 
Win32 modules.


I've always used Activestate Python from the start, and recommend it.

They have distributions for both Python 2 and 3, each both in 32-bit and 
64-bit.


http://www.activestate.com/activepython/downloads

I have no association with Activestate, I'm just a satisfied customer. 
Well, not even a customer.  I'm a satisfied freeloader.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread John Smith

On 11/30/2010 7:27 PM, Adam Bark wrote:

On 01/12/10 01:00, John Smith wrote:


Hi, Walter -

I got pywin32-214.win32-py2.7.exe because I have the Intel i7 (I'm
guessing that the AMD versions are for the AMD processor). However,
all of the exe offerings have the same "Python not found in registry"
problem that started this whole thing.

So, since the only source module available is pywin32-214.zip, I got
it and installed it. It does not work, maybe because I'm using Python
2.7 and the zip is for 3.2.

I really appreciate all the time you have put into my problems,
Walter. Thank you.

Cheers,
John



Actually, AMD 64 is now the standard x86-64. It was originally designed
by AMD because intel were making their Itanium thing but that didn't go
so well. Anyway if you're running 64 bit windows that's probably why the
32-bit python install is having a problem. Download the version Walter
suggested and you should be good to go.




Yes!

I have gone no farther than to say ser.read() knowing that nothing is 
attached to the port and expected a delay of 5 seconds. It now does 
that, so I have a clue that it is working.


I had no idea that the AMD thing was now standard. Thanks for that. I 
also found that the file Walter recommended did install from the exe 
while the non-AMD file did not due to the registry thing.


Wow! All I can say is thanks to everybody for the help. Now I need to 
start trying to get a modem to talk to me.


By the way, the whole purpose of doing this is to communicate with some 
test instruments via GPIB/HPIB to automate some testing that is time 
consuming. The last time I did this (using a BASIC program), it took 
about 45 minutes (not due to BASIC, but due to instrument response 
time). I was able to start the test, go to lunch, then analyze the data 
when I returned.


Thanks again for the help.

Cheers,
John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread Adam Bark

On 01/12/10 01:00, John Smith wrote:


Hi, Walter -

I got pywin32-214.win32-py2.7.exe because I have the Intel i7 (I'm 
guessing that the AMD versions are for the AMD processor). However, 
all of the exe offerings have the same "Python not found in registry" 
problem that started this whole thing.


So, since the only source module available is pywin32-214.zip, I got 
it and installed it. It does not work, maybe because I'm using Python 
2.7 and the zip is for 3.2.


I really appreciate all the time you have put into my problems, 
Walter. Thank you.


Cheers,
John



Actually, AMD 64 is now the standard x86-64. It was originally designed 
by AMD because intel were making their Itanium thing but that didn't go 
so well. Anyway if you're running 64 bit windows that's probably why the 
32-bit python install is having a problem. Download the version Walter 
suggested and you should be good to go.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread John Smith

On 11/30/2010 6:23 PM, Walter Prins wrote:

Hello John,

(snip)

Apparently so.  Well, win32file is part of the PyWin32 package, which
are a set of modules that wrap many Windows API's.   I'm not sure why it
was't/isn't required for PySerial 2.5 or whether as you say perhaps this
module is included in PySerial2.5 and isn't in 2.4.

But whatever the case may be, suffice it to say I've reproduced your
issue on my Win7 64bit box, and then resolved it by installing the
PyWin32 modules.   It's probably a good idea to install this package
anyway -- if you're working on Windows the PyWin32 modules are very
useful - they basically wrap and makes available a shedload of Windows
specific API's to Python. (Many people working with Python on Windows
almost automatically would install this, it's also why i didn't run into
this issue in the first place as I already had PyWin32 installed prior
to testing my suggestion. Sorry.)

Anyway.  To download and install PyWin32, go here: http://ur.ly/vLwv

Presumably you want the AMD64 (64 bit) Py2.7 version.   Install it then
try your test again.

Fingers crossed. ;)

Walter


Hi, Walter -

I got pywin32-214.win32-py2.7.exe because I have the Intel i7 (I'm 
guessing that the AMD versions are for the AMD processor). However, all 
of the exe offerings have the same "Python not found in registry" 
problem that started this whole thing.


So, since the only source module available is pywin32-214.zip, I got it 
and installed it. It does not work, maybe because I'm using Python 2.7 
and the zip is for 3.2.


I really appreciate all the time you have put into my problems, Walter. 
Thank you.


Cheers,
John


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread Walter Prins
Hello John,

On 30 November 2010 16:57, John Smith  wrote:

> Hi, Walter -
>
> I did the above and then got this:
>
> >>> import serial
>
>
> Traceback (most recent call last):
>  File "", line 1, in 
>import serial
>  File "E:\Python27\lib\site-packages\serial\__init__.py", line 18, in
> 
>from serialwin32 import *
>  File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 9, in
> 
>import win32file  # The base COM port and file IO functions.
> ImportError: No module named win32file
> >>>
>
> I guess that file was included in 2.5 but not in 2.4?
>

Apparently so.  Well, win32file is part of the PyWin32 package, which are a
set of modules that wrap many Windows API's.   I'm not sure why it
was't/isn't required for PySerial 2.5 or whether as you say perhaps this
module is included in PySerial2.5 and isn't in 2.4.

But whatever the case may be, suffice it to say I've reproduced your issue
on my Win7 64bit box, and then resolved it by installing the PyWin32
modules.   It's probably a good idea to install this package anyway -- if
you're working on Windows the PyWin32 modules are very useful - they
basically wrap and makes available a shedload of Windows specific API's to
Python. (Many people working with Python on Windows almost automatically
would install this, it's also why i didn't run into this issue in the first
place as I already had PyWin32 installed prior to testing my suggestion.
Sorry.)

Anyway.  To download and install PyWin32, go here: http://ur.ly/vLwv

Presumably you want the AMD64 (64 bit) Py2.7 version.   Install it then try
your test again.

Fingers crossed. ;)

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread John Smith

On 11/30/2010 10:37 AM, Walter Prins wrote:

Hello John

(snip)

In any case, to fix it let's delete all instances of pySerial and then
install it again, as follows:

1.) Open up your Python "site-packages" folder in Windows Explorer, e.g.
open up:
E:\Python27\lib\site-packages

2.) Delete any folder named "serial" that you may see.

3.) Delete any *file* name pyserial*.* that you may see, probably you'll
see "pyserial-2.4-py2.7.egg", there may also be an info file.

4.) Open up a Python shell and confirm that you can't import pyserial
anymore (e.g. "import serial" fails with e.g. "ImportError: No module
named serial".  If it still imports then you still have some vestiges of
the existing pyserial installation left over.

5.) After confirming the previous versions are gone, please try
reinstalling it again from scratch.  (E.g. extract source to some
suitable place and run "python setup.py install" from there, which
copies the required files into site-packages etc.)

6.) After installing, confirm "import serial" works again, then try your
test again.

Apologies again for adding to the confusion, and hopefully we're getting
closer. :-(

Walter



Hi, Walter -

I did the above and then got this:

>>> import serial

Traceback (most recent call last):
  File "", line 1, in 
import serial
  File "E:\Python27\lib\site-packages\serial\__init__.py", line 18, in 


from serialwin32 import *
  File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 9, 
in 

import win32file  # The base COM port and file IO functions.
ImportError: No module named win32file
>>>

I guess that file was included in 2.5 but not in 2.4?

Thanks,
John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread Walter Prins
Hello John



On 29 November 2010 21:44, John Smith  wrote:

> Hi, Walter -
>
> Thanks for all the research. This was my second attempt at installing the
> 2.4 version. I did it thus:
>
> E:\Python27\pyserial-2.4>..\python setup.py install
> standart distutils
> running install
> running build
> running build_py
> creating build
> creating build\lib
> creating build\lib\serial
> copying serial\serialcli.py -> build\lib\serial
> copying serial\serialjava.py -> build\lib\serial
> copying serial\serialposix.py -> build\lib\serial
> copying serial\serialutil.py -> build\lib\serial
> copying serial\serialwin32.py -> build\lib\serial
> copying serial\sermsdos.py -> build\lib\serial
> copying serial\__init__.py -> build\lib\serial
> running install_lib
> running install_egg_info
> Removing E:\Python27\Lib\site-packages\pyserial-2.4-py2.7.egg-info
> Writing E:\Python27\Lib\site-packages\pyserial-2.4-py2.7.egg-info
>
> E:\Python27\pyserial-2.4>
>
>
> But, when I tried it in Python, I got the same as before:
>
>
> >>> import serial
> >>> ser = serial.Serial(0, timeout = 1)
> >>> ser
> Serial(port='COM1', baudrate=9600, bytesize=8,
> parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False,
> dsrdtr=False)
>
> >>> ser.read()
>
> Traceback (most recent call last):
>  File "", line 1, in 
>
>ser.read()
>  File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 236, in
> read
>raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
> SerialException: ReadFile failed ([Error 6] The handle is invalid.)
> >>>
>
>
I've checked and I think it was a mistake to suggest installing pyserial 2.4
on top of 2.5 without first removing 2.5 explicitly.  It appears that doing
so actually still retains the previous version of serialwin32.py in use,
based on the fact that I've manually had a look at serialwin32.py from both
pyserial2.4 and pyserial2.5 and that fact that line 236 in pyserial2.5 is
where the error is raised, and pySerial2.4 by contrast has "if err: #will be
ERROR_IO_PENDING:" on line 236.  Consequently this implies that you're still
using pyserial2.5 above.   (Aside: I originally tested my suggestion for
installing pyserial2.4 and tested it by importing the module (e.g. "import
serial") and then did a "help(serial)" which gave me the impression of it
having done the right thing and using pyserial2.4, but apparently that's not
definitve, or I made a mistake somewhere along the line and got the wrong
end of the stick.)

So. My apologies, but I think that suggestion has added to the confusion.

In any case, to fix it let's delete all instances of pySerial and then
install it again, as follows:

1.) Open up your Python "site-packages" folder in Windows Explorer, e.g.
open up:
E:\Python27\lib\site-packages

2.) Delete any folder named "serial" that you may see.

3.) Delete any *file* name pyserial*.* that you may see, probably you'll see
"pyserial-2.4-py2.7.egg", there may also be an info file.

4.) Open up a Python shell and confirm that you can't import pyserial
anymore (e.g. "import serial" fails with e.g. "ImportError: No module named
serial".  If it still imports then you still have some vestiges of the
existing pyserial installation left over.

5.) After confirming the previous versions are gone, please try reinstalling
it again from scratch.  (E.g. extract source to some suitable place and run
"python setup.py install" from there, which copies the required files into
site-packages etc.)

6.) After installing, confirm "import serial" works again, then try your
test again.

Apologies again for adding to the confusion, and hopefully we're getting
closer. :-(

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith

On 11/29/2010 9:41 PM, Rance Hall wrote:

On Mon, Nov 29, 2010 at 8:21 PM, John Smith  wrote:


On 11/29/2010 5:56 PM, Emile van Sebille wrote:
(snip)


Hmmm... any chance you don't have administrative rights on the account
performing this? I never got to Win7 (having stopped at XP) but I know
it's got a reputation for excessive permission asking.


You're right about that. It's like Win7 is paranoid. But, it tells me when I
need to supply administrative permission. Some day I'll find the button that
tells the system that nobody else uses this computer and to shut up and get
on with it.



Just so you know, Its called User Account Control or UAC.  Google for
"disabling UAC on Windows 7" and you can find a tutorial or two on how
to make your computer "shut up and get on with it."



Hey, thanks Rance. The info is appreciated.

Cheers,
John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread Rance Hall
On Mon, Nov 29, 2010 at 8:21 PM, John Smith  wrote:
>
> On 11/29/2010 5:56 PM, Emile van Sebille wrote:
> (snip)
>>
>> Hmmm... any chance you don't have administrative rights on the account
>> performing this? I never got to Win7 (having stopped at XP) but I know
>> it's got a reputation for excessive permission asking.
>
> You're right about that. It's like Win7 is paranoid. But, it tells me when I
> need to supply administrative permission. Some day I'll find the button that
> tells the system that nobody else uses this computer and to shut up and get
> on with it.
>

Just so you know, Its called User Account Control or UAC.  Google for
"disabling UAC on Windows 7" and you can find a tutorial or two on how
to make your computer "shut up and get on with it."
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith


On 11/29/2010 5:56 PM, Emile van Sebille wrote:
(snip)

Hmmm... any chance you don't have administrative rights on the account
performing this? I never got to Win7 (having stopped at XP) but I know
it's got a reputation for excessive permission asking.


You're right about that. It's like Win7 is paranoid. But, it tells me 
when I need to supply administrative permission. Some day I'll find the 
button that tells the system that nobody else uses this computer and to 
shut up and get on with it.



Otherwise, I'd take this up on the main list. Chris Liechti, the
[author|current maintainer|significant contributor] of pyserial monitors
that list and would probably be interested in diagnosing what you're
describing. You could also ask him as per the 'send me a message' link
on his sourceforge page at

http://sourceforge.net/sendmessage.php?touser=403744

Emile


I'll consider that, Emile. First, though, I would like to hear from 
Walter again after my last post.


Thanks for your suggestions.

Cheers,
John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread Emile van Sebille

On 11/29/2010 3:25 PM John Smith said...


On 11/29/2010 4:20 PM, Emile van Sebille wrote:

On 11/29/2010 1:44 PM John Smith said...

But, when I tried it in Python, I got the same as before:


>>> import serial
>>> ser = serial.Serial(0, timeout = 1)


out of curiosity, if you change the timeout above to 5


>>> ser
Serial(port='COM1', baudrate=9600, bytesize=8,
parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False,
dsrdtr=False)
>>> ser.read()


... does the delay before printing the traceback below take about 5
seconds?




No. There is no delay regardless of the timeout setting.


>>
>> Traceback (most recent call last):
>> File "", line 1, in 
>> ser.read()
>> File "E:\Python27\lib\site-packages\serial\serialwin32.py", line
>> 236, in read
>> raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
>> SerialException: ReadFile failed ([Error 6] The handle is invalid.)
>>  >>>

Hmmm... any chance you don't have administrative rights on the account 
performing this?  I never got to Win7 (having stopped at XP) but I know 
it's got a reputation for excessive permission asking.


Otherwise, I'd take this up on the main list.  Chris Liechti, the 
[author|current maintainer|significant contributor] of pyserial monitors 
that list and would probably be interested in diagnosing what you're 
describing.  You could also ask him as per the 'send me a message' link 
on his sourceforge page at


http://sourceforge.net/sendmessage.php?touser=403744

Emile

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith


On 11/29/2010 4:20 PM, Emile van Sebille wrote:

On 11/29/2010 1:44 PM John Smith said...

But, when I tried it in Python, I got the same as before:


>>> import serial
>>> ser = serial.Serial(0, timeout = 1)


out of curiosity, if you change the timeout above to 5


>>> ser
Serial(port='COM1', baudrate=9600, bytesize=8,
parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False,
dsrdtr=False)
>>> ser.read()


... does the delay before printing the traceback below take about 5
seconds?




No. There is no delay regardless of the timeout setting.

John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread Emile van Sebille

On 11/29/2010 1:44 PM John Smith said...

But, when I tried it in Python, I got the same as before:


 >>> import serial
 >>> ser = serial.Serial(0, timeout = 1)


out of curiosity, if you change the timeout above to 5


 >>> ser
Serial(port='COM1', baudrate=9600, bytesize=8,
parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False,
dsrdtr=False)
 >>> ser.read()


... does the delay before printing the traceback below take about 5 seconds?



Traceback (most recent call last):
File "", line 1, in 
ser.read()
File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 236, in
read
raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
SerialException: ReadFile failed ([Error 6] The handle is invalid.)
 >>>



Emile

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith

On 11/28/2010 8:06 PM, Walter Prins wrote:

John,

(snip stuff)

Ugh, you're probably not going to like this.  I've done some googling
and it appears this may be a 64-bit issue with the "ctypes" module...
apparently "64-bit ctypes can only import 64-bit libraries".  See here:
http://ur.ly/vSMQ

Then again, it also seems to be an open issue on the PySerial bug
tracker: http://ur.ly/vZNL

Note, the above ticket suggests that PySerial 2.4 works ok (impliedly
even on 64-bit XP, so I imagine also on Windows 7.)  You should be able
to try this out by downloading the 2.4 version instead and installing it
in the same way you did the 2.5 version.  In any case, it might be an
idea to post a report/add a comment to that bug report as well to maybe
help get this issue resolved.

Cheers,

Walter



Hi, Walter -

Thanks for all the research. This was my second attempt at installing 
the 2.4 version. I did it thus:


E:\Python27\pyserial-2.4>..\python setup.py install
standart distutils
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\serial
copying serial\serialcli.py -> build\lib\serial
copying serial\serialjava.py -> build\lib\serial
copying serial\serialposix.py -> build\lib\serial
copying serial\serialutil.py -> build\lib\serial
copying serial\serialwin32.py -> build\lib\serial
copying serial\sermsdos.py -> build\lib\serial
copying serial\__init__.py -> build\lib\serial
running install_lib
running install_egg_info
Removing E:\Python27\Lib\site-packages\pyserial-2.4-py2.7.egg-info
Writing E:\Python27\Lib\site-packages\pyserial-2.4-py2.7.egg-info

E:\Python27\pyserial-2.4>


But, when I tried it in Python, I got the same as before:


>>> import serial
>>> ser = serial.Serial(0, timeout = 1)
>>> ser
Serial(port='COM1', baudrate=9600, bytesize=8, 
parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False, 
dsrdtr=False)

>>> ser.read()

Traceback (most recent call last):
  File "", line 1, in 
ser.read()
  File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 236, 
in read

raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
SerialException: ReadFile failed ([Error 6] The handle is invalid.)
>>>


Cheers,
John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-28 Thread Walter Prins
Also note this link: http://ur.ly/vVU9

It confirms that PySerial 2.4 works fine on Windows 7 64 bit.  (I've also
just downloaded and checked that installing pyserial 2.4 replaces the
existing pyserial and it does on my Python installation.)

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-28 Thread Walter Prins
John,

On 28 November 2010 15:55, John Smith  wrote:

> Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
> on win32
> Type "copyright", "credits" or "license()" for more information.
>
> >>> import serial
> >>> ser = serial.Serial('com1', timeout = 5)
> >>> x = ser.read()
>
> Traceback (most recent call last):
>  File "", line 1, in 
>x = ser.read()
>  File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 236, in
> read
>raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
> SerialException: ReadFile failed ([Error 6] The handle is invalid.)
> >>>
>

Ugh, you're probably not going to like this.  I've done some googling and it
appears this may be a 64-bit issue with the "ctypes" module... apparently
"64-bit ctypes can only import 64-bit libraries".  See here:
http://ur.ly/vSMQ

Then again, it also seems to be an open issue on the PySerial bug tracker:
http://ur.ly/vZNL

Note, the above ticket suggests that PySerial 2.4 works ok (impliedly even
on 64-bit XP, so I imagine also on Windows 7.)  You should be able to try
this out by downloading the 2.4 version instead and installing it in the
same way you did the 2.5 version.  In any case, it might be an idea to post
a report/add a comment to that bug report as well to maybe help get this
issue resolved.

Cheers,

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-28 Thread John Smith


On 11/28/2010 10:57 AM, Emile van Sebille wrote:

On 11/28/2010 7:55 AM John Smith said...


Can anybody tell me why the handle below is invalid? I'm running Win7.

TIA,
John


Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
on win32
Type "copyright", "credits" or "license()" for more information.

>>> import serial
>>> ser = serial.Serial('com1', timeout = 5)


What do you get when you add 'print ser' here? The docs at
http://pyserial.sourceforge.net/shortintro.html show you should get
something like

Serial(port='COM1', baudrate=19200, bytesize=8,
parity='N', stopbits=1, timeout=None, xonxoff=0, rtscts=0)

So if you're getting an invalid handle error I'd expect you'd get
something different.

Emile


Hi, Emile -

Okay. Here it is:

>>> print ser
Serial(port='COM1', baudrate=9600, bytesize=8, 
parity='N', stopbits=1, timeout=5, xonxoff=False, rtscts=False, 
dsrdtr=False)

>>>

Thanks.
John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pyserial and invalid handle

2010-11-28 Thread Emile van Sebille

On 11/28/2010 7:55 AM John Smith said...


Can anybody tell me why the handle below is invalid? I'm running Win7.

TIA,
John


Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
on win32
Type "copyright", "credits" or "license()" for more information.

 >>> import serial
 >>> ser = serial.Serial('com1', timeout = 5)


What do you get when you add 'print ser' here?  The docs at 
http://pyserial.sourceforge.net/shortintro.html show you should get 
something like


Serial(port='COM1', baudrate=19200, bytesize=8, 
parity='N', stopbits=1, timeout=None, xonxoff=0, rtscts=0)


So if you're getting an invalid handle error I'd expect you'd get 
something different.


Emile



 >>> x = ser.read()

Traceback (most recent call last):
File "", line 1, in 
x = ser.read()
File "E:\Python27\lib\site-packages\serial\serialwin32.py", line 236, in
read
raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
SerialException: ReadFile failed ([Error 6] The handle is invalid.)
 >>>
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor