473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pyserial not getting response every time, input/output errors

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 send/receive a few
times, I end up getting an input/output error.

Here are some examples:
>>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
ser.write(chr(2) + chr(1) + chr(6) + chr(12) + chr(34) + chr(0) + chr(0))
ser.read(60)
''
>>ser.close()
ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
ser.write(chr(2) + chr(1) + chr(6) + chr(12) + chr(34) + chr(0) + chr(0))
ser.read(60)
'\x02\x00\'\x0c"\x00My Thermostat R1.0B'
>>ser.write(chr(2) + chr(1) + chr(6) + chr(12) + chr(34) + chr(0) + chr(0))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line
372, in write
n = os.write(self.fd, d)
OSError: [Errno 5] Input/output error
I tried timeout values from 0.1 to 3sec. Doesn't make a difference.

Aside from the possibility of hw issue (I'm investigating this now),
what else could it be? We tested this from a different computer from a
Ferret terminal program using a different cable, and it worked without
problem. I tried many different things, using miniterm.py provided
with pyserial, getting newest version of pyserial, sending one char at
a time, etc etc. I get same intermittent problems..

If anyone have an idea on what else I can try, please help! thanks!
Aug 12 '08 #1
3 6157
Rainy wrote:
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 send/receive a few
times, I end up getting an input/output error.

Here are some examples:
>>>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)
One possible point of failure is that you're not supplying any
parameters for the data format (byte size, parity, stop bits) and flow
control. The Serial object will assume defaults, and those defaults may
or may not be correct.

Try to find out what data format and flow control you should be using
and set explicit Serial parameters accordingly.

Hope this helps,

--
Carsten Haese
http://informixdb.sourceforge.net
Aug 12 '08 #2


Carsten Haese wrote:
Rainy wrote:
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 send/receive a few
times, I end up getting an input/output error.

Here are some examples:
>>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)

One possible point of failure is that you're not supplying any
parameters for the data format (byte size, parity, stop bits) and flow
control. The Serial object will assume defaults, and those defaults may
or may not be correct.

Try to find out what data format and flow control you should be using
and set explicit Serial parameters accordingly.

Hope this helps,

--
Carsten Haese
http://informixdb.sourceforge.net
Thanks for the reply, Carsten, I should have mentioned.. yes, I did
confirm
that defaults pyserial's providing are correct with pcb maker.
Aug 12 '08 #3
On 2008-08-12, Carsten Haese <ca***********@gmail.comwrote:
Rainy wrote:
>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 send/receive a few
times, I end up getting an input/output error.

Here are some examples:
>>>>ser = serial.Serial('/dev/ttyAM1', 115200, timeout=0.1)

One possible point of failure is that you're not supplying any
parameters for the data format (byte size, parity, stop bits) and flow
control. The Serial object will assume defaults, and those defaults may
or may not be correct.
None of those things are capable of creating an input/output
error -- you'll just get goofy data values (or no answer from
the device at the other end of cable). An input/output error
usually means that there are issues with the underlying bus or
there are hardware failures.
Try to find out what data format and flow control you should
be using and set explicit Serial parameters accordingly.
--
Grant Edwards grante Yow! ... If I had heart
at failure right now,
visi.com I couldn't be a more
fortunate man!!
Aug 12 '08 #4

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

Similar topics

13
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
0
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...
2
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...
15
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...
0
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...
0
by: Kineta | last post by:
Hello all, I am attempting to send commands to the firmware on my PIC18F4550 (usb port) microcontroller using Pyserial. If I open Hyperterminal, I can send the following commands and it works...
6
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...
2
by: bryanleo | last post by:
We are trying to read data from a microcontroller and interface it through serial port. The output is then displayed in Python using Pyserial or the hyperterminal, the former is more important ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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...
0
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...
0
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...

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.