473,721 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pyserial and file open conflict?

Hi all!

I have a small but rather annoying problem with pyserial. I want to
open a file on disk for reading and then open a com-port, write lines
from the file to the port and then read something back and compare it
to the next line in the file. Should be simple. And it is, apart from
the fact that the file seems to be doubled ...? Or it loops through
the file twice.

If I exclude the "import serial" it works.

Any ideas?

thanks
Peter
Jun 27 '08 #1
7 1266
Em Thu, 15 May 2008 08:03:40 -0700, p.wallstedt escreveu:
Hi all!

I have a small but rather annoying problem with pyserial. I want to open
a file on disk for reading and then open a com-port, write lines from
the file to the port and then read something back and compare it to the
next line in the file. Should be simple. And it is, apart from the fact
that the file seems to be doubled ...? Or it loops through the file
twice.

If I exclude the "import serial" it works.

Any ideas?

thanks
Peter
Are you sure you need to reinvent the wheel ? For example, pppd has the
"chat" application:

http://www.hmug.org/man/8/chat.php

Jun 27 '08 #2
On 2008-05-15, p.*********@gma il.com <p.*********@gm ail.comwrote:
I have a small but rather annoying problem with pyserial. I want to
open a file on disk for reading and then open a com-port, write lines
from the file to the port and then read something back and compare it
to the next line in the file. Should be simple. And it is, apart from
the fact that the file seems to be doubled ...? Or it loops through
the file twice.

If I exclude the "import serial" it works.

Any ideas?
Your problem is in line 117 of your program.

--
Grant Edwards grante Yow! Hmmm ... an arrogant
at bouquet with a subtle
visi.com suggestion of POLYVINYL
CHLORIDE ...
Jun 27 '08 #3
On 15 Maj, 19:37, Grant Edwards <gra...@visi.co mwrote:
On 2008-05-15, p.wallst...@gma il.com <p.wallst...@gm ail.comwrote:
I have a small but rather annoying problem withpyserial. I want to
open a file on disk for reading and then open a com-port, write lines
from the file to the port and then read something back and compare it
to the next line in the file. Should be simple. And it is, apart from
the fact that the file seems to be doubled ...? Or it loops through
the file twice.
If I exclude the "import serial" it works.
Any ideas?

Your problem is in line 117 of your program.

--
Grant Edwards * * * * * * * * * grante * * * * * * Yow! Hmmm ... an arrogant
* * * * * * * * * * * * * * * * * at ** * * * * * bouquet with a subtle
* * * * * * * * * * * * * * * *visi.com * * * * * *suggestion of POLYVINYL
* * * * * * * * * * * * * * * * * * * * * * * * * *CHLORIDE ...
Do you have to much time?
Jun 27 '08 #4
>
Do you have to much time?
Maybe you have enough time to read this:

http://www.catb.org/~esr/faqs/smart-questions.html

Diez
Jun 27 '08 #5
On 2008-05-23, Peter <p.*********@gm ail.comwrote:
On 15 Maj, 19:37, Grant Edwards <gra...@visi.co mwrote:
>On 2008-05-15, p.wallst...@gma il.com <p.wallst...@gm ail.comwrote:
I have a small but rather annoying problem withpyserial. I want to
open a file on disk for reading and then open a com-port, write lines
from the file to the port and then read something back and compare it
to the next line in the file. Should be simple. And it is, apart from
the fact that the file seems to be doubled ...? Or it loops through
the file twice.
If I exclude the "import serial" it works.
Any ideas?

Your problem is in line 117 of your program.

Do you have to much time?
"Do you have a sense of irony?" he asked, already knowing the answer.

--
Grant

Jun 27 '08 #6
On 23 Maj, 16:13, Grant Edwards <gra...@visi.co mwrote:
On 2008-05-23, Peter <p.wallst...@gm ail.comwrote:
On 15 Maj, 19:37, Grant Edwards <gra...@visi.co mwrote:
On 2008-05-15, p.wallst...@gma il.com <p.wallst...@gm ail.comwrote:
I have a small but rather annoying problem withpyserial. I want to
open a file on disk for reading and then open a com-port, write lines
from the file to the port and then read something back and compare it
to the next line in the file. Should be simple. And it is, apart from
the fact that the file seems to be doubled ...? Or it loops through
the file twice.
If I exclude the "import serial" it works.
Any ideas?
Your problem is in line 117 of your program.
Do you have to much time?

"Do you have a sense of irony?" he asked, already knowing the answer.

--
Grant
Grant - "Do you have a sence of appropriateness "? he asked, already
knowing the answer. I had no idea this is a comedy club. I might argue
that my reply was also some sort of humor, but you clearly didn't see
it that way. Maybe you should try living according to the rules you
make for others?

Diez - Did you mean the section which covers Asperger's Syndrome?

I'm just being a hacker here guys ... according to the guidelines.

It's amazing how such a simple question gets derailed immediately.
Without any light on the subject whatsoever.
Jun 27 '08 #7
On May 26, 6:54*pm, Peter <p.wallst...@gm ail.comwrote:
On 23 Maj, 16:13, Grant Edwards <gra...@visi.co mwrote:
On 2008-05-23, Peter <p.wallst...@gm ail.comwrote:
On 15 Maj, 19:37, Grant Edwards <gra...@visi.co mwrote:
>On 2008-05-15, p.wallst...@gma il.com <p.wallst...@gm ail.comwrote:
I have a small but rather annoying problem withpyserial. I want to
open a file on disk for reading and then open a com-port, write lines
from the file to the port and then read something back and compare it
to the next line in the file. Should be simple. And it is, apart from
the fact that the file seems to be doubled ...? Or it loops through
the file twice.
If I exclude the "import serial" it works.
Any ideas?
>Your problem is in line 117 of your program.
Do you have to much time?
"Do you have a sense of irony?" he asked, already knowing the answer.
--
Grant

Grant - "Do you have a sence of appropriateness "? he asked, already
knowing the answer. I had no idea this is a comedy club. I might argue
that my reply was also some sort of humor, but you clearly didn't see
it that way. Maybe you should try living according to the rules you
make for others?

Diez - Did you mean the section which covers Asperger's Syndrome?

I'm just being a hacker here guys ... according to the guidelines.

It's amazing how such a simple question gets derailed immediately.
Without any light on the subject * whatsoever.
Try asking about your problem again. Think before writing. Read your
text after you write it. Tell what you are trying to do, how you are
trying to do and what's the buggy behaviour. Copy the relevant part of
your source code here.
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4129
by: kamarudin samsudin | last post by:
Hi all, I try to invoke python serial script via my browser using PHP (exec function). For the serial communication, i used pySerial module. It fine when it run it as root but when i try to run it from browser, i got this error in my httpd/error_log File "weather1.py", line 9, in ? ser=serial.Serial('/dev/ttyS0',9600,timeout=1) File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line
13
11028
by: Bob Greschke | last post by:
We have some equipment that communicates at 57600 baud RS232. The path from the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial converter. The driver for the 3410 chip creates a "normal" comm port (like COM3). There is a C++ program that has no problem talking to the equipment, but two Python programs have trouble. One is a big, scary, controller program, and the other, since that is the one I'm having trouble...
3
4657
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. Is it possible to go straight from a byte array to document in word instead of a temp file? Also is there a way to change the save behaviour to notify my app to pickup a binary copy of the file or stream to save back to the sql db. Thanks in...
2
3739
by: Jon | last post by:
Hi, I wrote some code to read in info from a port using pyserial. the code reads info sent by a box that is connected to my computer by an rs232-to usb adapter. When I was writing the code and testing it on my computer it worked fine. I ran py2exe on the program (which uses wxpython for its gui) and sent the output from the py2exe to another computer. now when I try to run it on this other computer it fails to open the port. it gives...
3
8151
by: Ron Jackson | last post by:
I am using Python 2.5 on Windows XP. I have installed Pyserial and win32all extensions. When I try to run the example program scan.py (included below), or any other program using pyserial, as soon as it hits the statement: s = serial.Serial(i) I get the error:
3
11622
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to be working fine when I test it with Hyperterminal . I am using the example program that comes with pyserial, as below. --------------- import serial
1
1708
by: JAMoore84 | last post by:
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:
3
6216
by: Rainy | last post by:
Hello! I'm having some trouble with pyserial package, I'm sending commands and reading responses from a custom pcb, and sometimes I get a proper response, at other times I get nothing, and sometimes I get about half of the response string with beginning cut off. About half the time an empty string is returned, the other ~half time good response, and more rarely I get partial response. When I try to use the same Serial instance to...
6
10646
by: Joe G \(Home\) | last post by:
Hi All, Background =================== I have installed Python for windows today from the python web site .I also installed pySerial using the Windows installer from the sourceforge web site..... Both installs use the default directories. Phyton version : Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) on win32
0
8851
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9143
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5992
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2588
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.