I have used pyserial for a couple of days. However, a problem occurs today. I met serial write timeout. Several days before, when I used a switch, everything is OK. But today I changed for another switch. Then serial write timeout appears. I did not change any code, but the problem is actually quite severe. More seriously, the timeout not always occurs, which means that sometimes I can write in the serial successfully.
Active2 years, 5 months ago
![]() Python Pyserial Read Timeout
The magnitude and importance of such stresses is often underestimated. The build-up of corrosion products in confined spaces can also generate significant stresses and should not be overlooked. Caustic stress corrosion cracking. The residual stresses set up as a result of welding operations tend to approach the yield strength.
Mar 27, 2017 It allows you to read lines without 100% CPU. It does not contain any timeout logic. If a timeout occurs, self.s.read(i) returns an empty string and you might want to throw an exception to indicate the timeout. I just measured. The code below gives me 790 kB/sec while replacing the code with pyserial's readline method gives me just 170kB/sec.
I have ensured that the port is COM5 and the baudrate of the switch is 9600. Thanks a lot for answering my question.
foreverXZCforeverXZC
1 Answer
I ran into this problem recently. I found that setting
write_timeout=0 solved the issue (also, not really sure why a write timeout even exists..)
Another answer here suggests the same thing :)
Community♦
linzwattlinzwatt
Not the answer you're looking for? Browse other questions tagged pythonpyserial or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |