By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

Pyserial not getting response every time, input/output errors

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a


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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.