473,769 Members | 7,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pyserial problem: script stops reading

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 |Rack Abs.| - | --210
17

After a few hours, or sometimes days, of listening, the script stops
in the middle of the line and does not display any further output (as
you can see with the "17" in the last line above). That happens, even
though I set a timeout of 10s when opening the line, and on timeout it
displays the lines and reopens the port:

ser = serial.Serial(p ort=1,
baudrate=1200,
rtscts=1,
timeout=10)

while 1:
lines = sh.readLines()
for line in lines:
print line
ser.close()
ser.open()

If the script does not time out there, I am not sure what else it is
doing. It seems to be in a wait state it does not get out of.

So even if the line received turned out to have some sort of error, I
think it should time out after a while? Maybe there is some sort of
buffer overrunning (even though the traffic is quite low: a line every
few minutes on average)?

Does anyone see any obvious error? Any hint how I can further debug the problem?

Thanks
Fred
Sep 9 '06 #1
0 1596

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

Similar topics

8
15910
by: engsol | last post by:
Has anyone done a script that will rspond to the serial com port(s) receive buffer interrupt, as opposed to polling and timeouts? Win2000 is the main interest right now. Thanks Norm B
6
17694
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
20
2890
by: luca72 | last post by:
Hello I have solve the problem of configuration with pyserial but i have another question. The serial port close every time i make the read and re-open when i do i new write. In my script there is not write close , why it close ? Thaks Luca
0
1028
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 ...
15
16872
by: Lone Wolf | last post by:
I'm trying to get data through my serial port from a CMUcam. This gizmo tracks a color and returns a packet of data. The packet has nine data points (well, really eight since the first point is just a packet header) separated by spaces as follows: M xxx xxx xxx xxx xxx xxx xxx xxx Here is the code I am using (python v24): import serial
3
3213
by: Lone Wolf | last post by:
I want to thank everybody who tried to help me, and also to post my solution, even though I don’t think it is a very good one. Many of you correctly guessed that there was an “\r” included with the packet from the CUMcam, and you were correct. The actual format of the packet is: M xxx xxx xxx xxx xxx xxx xxx xxx\r. Unfortunately, splitting the packet using \r wouldn’t help because the format of the data stream that I get with the...
0
596
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!) :
3
6223
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...
5
6257
by: zxo102 | last post by:
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...
0
9423
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
10216
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...
0
9865
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...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5309
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.