1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

(未解決) pySerial 3.* + Ubuntu 16.04 LTS > OSError: [Errno 5] Input/output error | RPi + Python 2.7.9 + pySerial 2.6-1.1では問題ない

Last updated at Posted at 2018-01-19
動作環境
Ubuntu 16.04 LTS desktop amd64
Python 3.5.2
Python 2.7.12

前回: pySerial + CentOS 6.8 > Python 2.6は対応しない (ValueError: zero length field name in format) | Python 2.7は対応してそう > Python 2.7と3.6ではConnection timed out

CentOS6.8ではpySerialの動作がうまくいかなかった。
Ubuntu 16.04ではどうか。

概要

pySerialでのテキスト送信時に以下のエラーが出る。

OSError: [Errno 5] Input/output error

code

write_test_180119.py
import serial
import time


def main():
    print("Hello")
    con1 = serial.Serial('/dev/ttyUSB0', 9600, timeout=10)
    str1 = b'from0\n'
    con1.write(str1)
    con1.close()

if __name__ == '__main__':
    main()

発生

上記のスクリプトを何回か実行していると発生する。
一度エラーが出ると、それ以降の送信はすべて失敗する。

USBを抜き差しすることで送信可能状態に戻るが、送信を繰り返すうちに同じ症状に陥る。

Raspberry Pi

Raspberry Piで使っていたpySerialを確認してみた。

python-serial 2.6-1.1

Python 2.7.9からループバックテストコードを実行すると問題なく動作した。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?