[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Beginner Pyserial Question

JAMoore84

1/24/2008 4:45:00 PM

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!
6 Answers

Grant Edwards

1/24/2008 4:56:00 PM

0

On 2008-01-24, JAMoore84@gmail.com <JAMoore84@gmail.com> 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!!

JAMoore84

1/24/2008 5:14:00 PM

0


> 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.

JAMoore84

1/24/2008 5:45:00 PM

0

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

Rod Speed

6/21/2013 7:41:00 PM

0

Bill <blackusenet@gmail.com> wrote
> Rod Speed <rod.speed.aaa@gmail.com> wrote
>>Bill <blackusenet@gmail.com> wrote
>>> Rod Speed <rod.speed.aaa@gmail.com> wrote
>>>> Bill <blackusenet@gmail.com> wrote
>>>>> Rod Speed <rod.speed.aaa@gmail.com> wrote
>>>>>> Bill <blackusenet@gmail.com> wrote
>>>>>>> Colin <email@email.com> wrote

>>>>>>>> The U.S. would be working on the bomb even faster than it worked in
>>>>>>>> OTL.

>>>>>>> Why?

>>>>>>> They needed British information to even know it was possible.

>>>>>> Bullshit.

>>>>> So tell us all how they manage to get the Manhattan Programme
>>>>> started without the Frisch-Peierls memorandum...

>>>> It was just the first calculation of the amount of fissionable
>>>> material needed to go critical. Nothing even remotely like
>>>> the only source of the most basic information that a bomb
>>>> was possible.

>>>> The letter Einstein signed to FDR preceded that, so it should
>>>> be obvious that he knew that it was possible before that.

>>> So why didn't they start then?

>> Because Einstein thought it might need more fissionable material
>> than could be delivered by plane, that it might well need a ship.

> Exactly.

But that was only MIGHT, and if Oliphant etc had not done
that calculation, it would have been done by someone else.

>>> They didn't start until after they'd received the MAUD Report,
>>> and even then someone had to fly across the Atlantic four
>>> months later and explain to them exactly why it was important.

>>> http://en.wikipedia.org/wiki/MAUD_Committee#Telli...

>> That's an entirely separate matter to your original comment about
>> POSSIBLE.

> You're grasping at straws.

You're trying to bullshit your way out of your predicament just
like you always do when your nose is rubbed in the basics.

>> Clearly Einstein realised it was POSSIBLE
>> well before the Maud Committee report.

> The point is that they didn't even start until the British told
> them it was possible to build a device that was air portable..

That is a bare faced lie.

> The original claim was that they'd start earlier.

Everyone can see for themselves that you are lying
thru your teeth as you ALWAYS do when you have
got done like a fucking dinner, as you ALWAYS are.

Get a clue and realise that when you nose has been
rubbed in the basics, like it was with a DUKW equivalent
that could carry containers, that the only viable thing
to do is shut up and hope everyone forgets your
terminal stupidity as quickly as possible.

Rod Speed

6/21/2013 10:35:00 PM

0

Bill <blackusenet@gmail.com> wrote
> Rod Speed <rod.speed.aaa@gmail.com> wrote
>> Bill <blackusenet@gmail.com> wrote

>>>> Because Einstein thought it might need more fissionable material
>>>> than could be delivered by plane, that it might well need a ship.

>>> Exactly.

>> But that was only MIGHT, and if Oliphant etc had not done
>> that calculation, it would have been done by someone else.

> But the claim was that the Manhattan Project would have started earlier.

Irrelevant to your stupid claim that you have now deleted from the quoting
where you claimed that no one else realised that nuclear weapons were
POSSIBLE, before that. That always was a pig ignorant lie.

> As they didn't know a bomb was practical

That's just plain wrong. That's why Einstein signed
the letter, well before Oliphant did the calculation.

> that was obviously not going to happen.

It did anyway.

>> You're trying to bullshit your way out of your predicament just
>> like you always do when your nose is rubbed in the basics.

> No, I made a true statement.

Like hell you did on the stupid POSSIBLE claim.

<reams of your obscene deviate little
fantasys flushed where they belong>

>>>> Clearly Einstein realised it was POSSIBLE
>>>> well before the Maud Committee report.

>>> The point is that they didn't even start until the British told
>>> them it was possible to build a device that was air portable..

>>That is a bare faced lie.

> Well, no.

Yep.

> What's more I even posted a source

> Which you seem to have deleted.

I didn't delete a fucking thing you silly little pathological liar.

You're the one that has now deleted your original stupid POSSIBLE claim.

Rod Speed

6/22/2013 3:44:00 AM

0

Bill <blackusenet@gmail.com> wrote
> Rod Speed <rod.speed.aaa@gmail.com> wrote
>> Bill <blackusenet@gmail.com> wrote

<reams of you desperately attempting to bullshit
and lie your way out of your predicament and fooling
absolutely no one at all, flushed where it belongs>

>>> What's more I even posted a source

>>> Which you seem to have deleted.

>> I didn't delete a fucking thing you silly little pathological liar.

> Oh yes you did my child.

Oh no I didn't, you silly little pathological liar.

> Here it is again.

> http://en.wikipedia.org/wiki/MAUD_Committee#Telli...

> Now, read it, say sorry, then piss off...

Go and fuck yourself, again.