Hello All,
I have a system. An instrument attched to 'com1' is wireless connected
to many sensors at different locations. The instrument can forward
the "commands" (from pyserial's write()) to those sensors. Based on
the "commands", the sensors keep sending corresponding data back to
the instrument which wraps up those data and put into "com1" . The
readlines() of pyserial pick up those data for processing.
The data ’string' does not have "\n".
With the following pythong script, if timeout = 0.1, ser.readlines()
in thread1 failed to receive any data after approximate 20 hours. if
timeout=0.5, ser.readlines() in thread1 failed to receive any data
after approximate 60 hours. I am not sure the thread1 was dead or
not. But the whole script did not throw out any error information and
ser.write() in thread2 was ok and kept sending "commands" to com1.
I am testing "timeout = 1" right now, it will probably take more days
to fail to receive data.
Anybody knows how long I should set for "timeout"? Since the data are
from different sensors, I have no idea when they arrive at com1 via
that instrument. If the timeout is set too long, com1 (com1 has
buffer? Sorry, I don't know very much about hardwares) can not have
enough buffer to hold those coming data before ser.readlines() . Or how
does ser.readlines() work?
Should I use readline() instead of readlines()?
Thanks for your any help in advance.
The below is the script:
In thread 1:
import serial, time
ser=serial.Seri al('com1', baudrate=9600, bytesize=8, parity='N',
stopbits=1, timeout=0.1,xon xoff=0, rtscts=0)
while 1:
reading = ser.readlines()
for i in range(len(readi ng)):
if len(reading[i]) 0:
aa = map(ord, reading[i])
bb = ["%02X"%aa[k] for k in range(len(aa))]
# do something here
else:
pass
time.sleep(Read ComSleepTime)
ser.close()
In thread 2:
....
while 1:
...
ser.write("some commands here")
...
time.sleep(30)
Best Regards
ouyang 5 6255
On 2008-10-11, zxo102 <zx****@gmail.c omwrote:
I have a system. An instrument attched to 'com1' is wireless connected
to many sensors at different locations. The instrument can forward
the "commands" (from pyserial's write()) to those sensors. Based on
the "commands", the sensors keep sending corresponding data back to
the instrument which wraps up those data and put into "com1" . The
readlines() of pyserial pick up those data for processing.
The data ?string' does not have "\n".
If the data you're reading doesn't contain "\n", then you can't
use readline() or readlines().
--
Grant Edwards grante Yow! I smell a RANCID
at CORN DOG!
visi.com
On 2008-10-11, Grant Edwards <invalid@invali dwrote:
On 2008-10-11, zxo102 <zx****@gmail.c omwrote:
>I have a system. An instrument attched to 'com1' is wireless connected to many sensors at different locations. The instrument can forward the "commands" (from pyserial's write()) to those sensors. Based on the "commands", the sensors keep sending corresponding data back to the instrument which wraps up those data and put into "com1" . The readlines() of pyserial pick up those data for processing. The data ?string' does not have "\n".
If the data you're reading doesn't contain "\n", then you can't
use readline() or readlines().
P.S.
To the OP: I normally block postings from google groups (which
is where almost all Usenet spam comes from), so I only saw your
posting because I was experimenting with my spam filtering.
I'll only see additional postings if you post from a real news
server or if somebody who does so quotes one of your postings.
Yes, that sort of sucks. But, until Google shuts off the spam
spigot, you're going to get short shrift if you post from
Google.
There are plenty of free news servers for the text groups like
c.l.p, or you can post to the mailing list via gmane.org.
--
Grant Edwards grante Yow! They collapsed
at ... like nuns in the
visi.com street ... they had no
teen appeal!
Unknown wrote:
On 2008-10-11, zxo102 <zx****@gmail.c omwrote:
>I have a system. An instrument attched to 'com1' is wireless connected to many sensors at different locations. The instrument can forward the "commands" (from pyserial's write()) to those sensors. Based on the "commands", the sensors keep sending corresponding data back to the instrument which wraps up those data and put into "com1" . The readlines() of pyserial pick up those data for processing. The data ?string' does not have "\n".
Do you have the option of having the instrument insert them between
readings?
>
If the data you're reading doesn't contain "\n", then you can't
use readline() or readlines().
Use .read() instead.
On 10ÔÂ11ÈÕ, ÏÂÎç11ʱ00·Ö, Grant Edwards <invalid@invali dwrote:
On2008-10-11,zxo102<zxo.. .@gmail.comwrot e:
I have a system. An instrument attched to 'com1' is wireless connected
to many sensors at different locations. The instrument can forward
the "commands" (from pyserial's write()) to those sensors. Based on
the "commands", the sensors keep sending corresponding data back to
the instrument which wraps up those data and put into "com1" . The
readlines() of pyserial pick up those data for processing.
The data ?string' does not have "\n".
If the data you're reading doesn't contain "\n", then you can't
use readline() or readlines().
--
Grant Edwards grante Yow! I smell a RANCID
at CORN DOG!
visi.com
But readlines() can read data out of 'com1' for many hours. Maybe I
should try read().
Ouyang
On 10ÔÂ12ÈÕ, ÉÏÎç1ʱ13·Ö, Terry Reedy <tjre...@udel.. eduwrote:
Unknown wrote:
On2008-10-11,zxo102<zxo.. .@gmail.comwrot e:
I have a system. An instrument attched to 'com1' is wireless connected
to many sensors at different locations. The instrument can forward
the "commands" (from pyserial's write()) to those sensors. Based on
the "commands", the sensors keep sending corresponding data back to
the instrument which wraps up those data and put into "com1" . The
readlines() of pyserial pick up those data for processing.
The data ?string' does not have "\n".
Do you have the option of having the instrument insert them between
readings?
If the data you're reading doesn't contain "\n", then you can't
use readline() or readlines().
Use .read() instead.
I can not have the instrument insert "\n" between readings. That is
out of my control. I can try read(). Thanks.
Ouyang This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: googlinggoogler |
last post by:
Hiya,
I've got a PIC microcontroller reading me humidity data via rs232, this
is in ASCII format. I can view this data easily using hyperterminal or
pyserial and convert it to its value (relative humidty with ord(input))
But what im trying to do is plot the data in real time, ideally with
pylab - as it looks simple to use and simple is the way i want to go!
My code is below, it doesnt show a graph, I was wondering whether
|
by: Tim D |
last post by:
Hi,
I originally posted this as a reply to a rather old thread in
dotnet.framework.general and didn't get any response. I thought it might be
more relevant here; anyone got any ideas? My questions are below...
"David Good" wrote:
> We have a network running both Win2k and Win2k3 webservers and our web sites
> reside on a UNC network share that happens to be a Network Appliance NAS.
|
by: Mimi |
last post by:
Hi,
I use the pyserial to read data from a serial port.
My code is in window Xp and python 2.4. when I use Hyperteminal I can
read data without try and try again that it is not the case with
pyserial library.
anyone can help me ?
this is a part of my code:
self.ser = serial.Serial()
self.ser.baudrate = 9600
|
by: Frederic Wenzel |
last post by:
I wrote a script on Linux that uses pyserial to read status messages
from a serial line using readlines(). For now, it just displays what
it gets on stdout:
17:42 | 0005 | 02 | | 5 |Rack Abs.| - | --210
17:42 | 0008 | 02 | | 5 |Rack Abs.| - | --210
17:42 | 0001 | 02 | | 5 |Rack Abs.| - | --210
17:43 | 0008 | 02 | | 5 |Rack Abs.| - | --210
17:43 | 0001 | 02 | | 5 |Rack Abs.| - | --210
17:43 | 0005 | 02 | | 5 ...
|
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...
| |
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:
|
by: pauland80 |
last post by:
<snip>
<snip>
Late thanks for your both answers! (Please excuse me for that)
The problem was a bug in the device firmware.
But before finding this, I dugg lightly in the pyserial source and
found (to take with care!) :
|
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
|
by: __zip__ |
last post by:
Hi,
I am using pySerial for communication with modem.
Does anyone knows which values are for what in these variables?
xonxoff=0
rtscts=0
dsrdtr=0
|
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...
|
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,...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |