Re: with open('com1', 'r') as f:



En Thu, 02 Apr 2009 20:04:14 -0300, gert <gert.cuykens@xxxxxxxxx> escribió:
On Apr 2, 8:53 pm, Kushal Kumaran <kushal.kuma...@xxxxxxxxx> wrote:
On Thu, 2 Apr 2009 10:01:02 -0700 (PDT)
gert <gert.cuyk...@xxxxxxxxx> wrote:

> from subprocess import *
> check_call(['mode', 'COM1:9600,N,8,1,P'],shell=True)
> while True:
>     with open('com1', 'r') as f:
>         for line in f:
>              print('line')

> This works very well except for one thing. After a reboot I have to
> launch 1 time any windows serial exe application no mater with one,
> that just opens an closes the com port, before i can launch this
> script. The script keeps on working even after closing and reopening
> it, until i reboot the pc. Then again I have to launch one time a
> serial.exe and close it again. The exe does not run anything in the
> background it just does something in windows python does not do when
> it reads from the com port after a fresh reboot.

> And i really appreciate it if somebody knew what it was.

I don't know why you're getting this behaviour, but have you tried using
a python library for accessing the serial port? Seehttp://pyserial.wiki.sourceforge.net/pySerial.

I am sorry but I don't think pyserial will work on python3.x and I
also like to know whats going on before I consider it.

A real Windows program accessing the serial port is likely to use SetupComm, SetCommState, and other functions in addition to CreateFile.
See http://msdn.microsoft.com/en-us/library/aa363196(VS.85).aspx

pySerial takes care of all those details, as suggested.

Maybe its a bug in open() on windows?

open() doesn't care about the file name; it's the OS that interprets "com1" as a serial port.

--
Gabriel Genellina

.



Relevant Pages

  • Problems with my Quick Launch Toolbar
    ... I have always loved the convienience of having the Quick Launch Toolbar. ... but it always unchecks itself when I reboot. ... The only changes I have made recently was to format and reinstall Windows, ... get all the Windows Updates and then install my usual software. ...
    (microsoft.public.windowsxp.help_and_support)
  • Problem with my Quick Launch Toolbar
    ... I have always loved the convienience of having the Quick Launch Toolbar. ... but it always unchecks itself when I reboot. ... The only changes I have made recently was to format and reinstall Windows, ... get all the Windows Updates and then install my usual software. ...
    (microsoft.public.windowsxp.customize)
  • Re: Serial Port (COM1) Troubleshooting
    ... have connected to the serial port is transmitting data when Windows ... unplug the device from the serial port ... and reboot the PC. ... when the windows log on again it installs the COM1 driver by it self and the ...
    (microsoft.public.windowsxp.general)
  • Re: QUICK LAUNCH toolbar disappears whenever I reboot
    ... This behavior can occur if the Quick Launch folder has been deleted. ... reboot if the quick lanch is off then turn it back on then it will save. ... Windows Registry Editor Version 5.00 ... The Quick Launch tray is part of the Taskbar not a Toolbar. ...
    (microsoft.public.windowsxp.basics)
  • Re: firefox wont launch
    ... Until now I have to reboot ... > into Windows and I am getting tired of having to do that. ... After you launch it, the process keeps running but the window does not open or it terminates by itself right after launch? ... When I launchit from the console nothing happens at all. ...
    (Fedora)