Beginner Pyserial Question

Discussion in 'Python' started by JAMoore84@gmail.com, Jan 24, 2008.

  1. Guest

    Hi Guys,

    I have a project where I'd like to save GPS data that is streamed to a
    Sony Vaio over bluetooth. I can monitor the data stream over Hyper
    Terminal, but I'd like to use python to capture it as well. I've
    installed Python 2.5, pyserial 2.2 and the appropriate pywin program
    (pywin32-210.win32-py2.5.exe).

    My problem comes when I try to open a serial port. After importing
    "serial", I issue the following statement:

    >>> GPS = serial.Serial(0)


    Traceback (most recent call last):
    File "<pyshell#3>", line 1, in <module>
    GPS = serial.Serial(0)
    File "C:\Python25\lib\site-packages\serial\serialutil.py", line 156,
    in __init__
    self.open()
    File "C:\Python25\lib\site-packages\serial\serialwin32.py", line 55,
    in open
    raise SerialException("could not open port: %s" % msg)
    SerialException: could not open port: (2, 'CreateFile', 'The system
    cannot find the file specified.')

    I'm not sure where the source of the problem is. I was wondering if
    someone could recognize what might be be. the Vaio is running XP
    SP2. Thanks!
     
    , Jan 24, 2008
    #1
    1. Advertising

  2. On 2008-01-24, <> wrote:
    > Hi Guys,
    >
    > I have a project where I'd like to save GPS data that is streamed to a
    > Sony Vaio over bluetooth. I can monitor the data stream over Hyper
    > Terminal, but I'd like to use python to capture it as well. I've
    > installed Python 2.5, pyserial 2.2 and the appropriate pywin program
    > (pywin32-210.win32-py2.5.exe).
    >
    > My problem comes when I try to open a serial port. After importing
    > "serial", I issue the following statement:
    >
    >>>> GPS = serial.Serial(0)

    >
    > Traceback (most recent call last):
    > File "<pyshell#3>", line 1, in <module>
    > GPS = serial.Serial(0)
    > File "C:\Python25\lib\site-packages\serial\serialutil.py", line 156,
    > in __init__
    > self.open()
    > File "C:\Python25\lib\site-packages\serial\serialwin32.py", line 55,
    > in open
    > raise SerialException("could not open port: %s" % msg)
    > SerialException: could not open port: (2, 'CreateFile', 'The system
    > cannot find the file specified.')
    >
    > I'm not sure where the source of the problem is. I was
    > wondering if someone could recognize what might be be.


    It's Windows... it's not expected to work. ;)

    My guess is that for whatever reason the 'first' serial port
    (which is what you're asking for by specifying a 0 when
    instantiating the Serial class) doesn't actually exist. Serial
    device names under Windows are broken. Just because you have
    only one serial port, it doesn't mean that serial port is the
    first serial port.

    Try using the actual name of the com port (e.g. 'COM3' or
    'COM5') instead of 0.

    Oh, if you end up having to use a com port higher than COM9,
    that's broken in Windows as well, and you've got to sprinkle a
    bunch of backslashes into the device name (I don't remember the
    exact syntax).

    --
    Grant Edwards grante Yow! ... this must be what
    at it's like to be a COLLEGE
    visi.com GRADUATE!!
     
    Grant Edwards, Jan 24, 2008
    #2
    1. Advertising

  3. Guest


    > My guess is that for whatever reason the 'first' serial port
    > (which is what you're asking for by specifying a 0 when
    > instantiating the Serial class) doesn't actually exist. Serial
    > device names under Windows are broken.


    I realize this. I tried connecting to different port "numbers", but I
    have not tried the serial.Serial(COM1). I wasn't sure if that worked,
    but I know a quick way to find out.


    > Try using the actual name of the com port (e.g. 'COM3' or
    > 'COM5') instead of 0.


    The com port used in Hyper Terminal is COM40. I have tried connecting
    to 39/40/41 to no avail.

    > Oh, if you end up having to use a com port higher than COM9,
    > that's broken in Windows as well, and you've got to sprinkle a
    > bunch of backslashes into the device name (I don't remember the
    > exact syntax).


    That might become an issue when I try to read COM40 for the GPS
    bluetooth transmission. This issue does not relate to why I cannot
    open smaller com ports, though.
     
    , Jan 24, 2008
    #3
  4. Guest

    I've solved the problem- Thanks for steering me in the right
    direction.

    The problem is that your traditional "COM1" does not exist on this
    computer (Thanks Grant). A trip to the Device manager listed all the
    COM ports on the computer. After successfully connecting to COM7 (port
    = serial.Serial(6)), I realized the reason I couldn't connect to COM40
    was because it was tied up with hyper terminal. after closing
    everything, I was able to issue a readline and collect data. Thanks
    for the help!

    jimmy
     
    , Jan 24, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    No Class at ALL!!! beginner/beginner question

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, Feb 2, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    591
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    Feb 3, 2005
  2. Diez B. Roggisch

    Pyserial question

    Diez B. Roggisch, Jan 5, 2004, in forum: Python
    Replies:
    1
    Views:
    403
    Kelia Nichols
    Jan 5, 2004
  3. David Goodger

    Re: Pyserial question

    David Goodger, Jan 5, 2004, in forum: Python
    Replies:
    0
    Views:
    445
    David Goodger
    Jan 5, 2004
  4. Dennis Lee Bieber

    Re: pyserial question

    Dennis Lee Bieber, Jun 19, 2009, in forum: Python
    Replies:
    0
    Views:
    659
    Dennis Lee Bieber
    Jun 19, 2009
  5. Jean Dupont
    Replies:
    2
    Views:
    334
    Peter
    Feb 8, 2012
Loading...

Share This Page