動作環境
Ubuntu 16.04.3 LTS desktop amd64
pySerial 2.5
Python 3.5.2
関連
対処
CentOS 6.8でpySerial 2.7使用時に送信ができなくなる。
pySerial 2.5だと問題がないような記事を上記のリンク先のリンク先にて見つけた。
CentOS 6.8でpySerial 2.5をインストールするよりは、Ubuntu 16.04でpip3にてインストールが早いため、そちらで試した。
送信Pythonスクリプトを実行したところ、.write()の処理は実行されるが、RS-232Cの相手側に文字は到達しない。
dmesgで以下のようなエラー表示が発生する。
[ 8736.121755] usb 2-2.1: Product: USB 2.0 To COM Device
[ 8736.121759] usb 2-2.1: Manufacturer: Prolific Technology Inc.
[ 8736.127484] pl2303 2-2.1:1.0: pl2303 converter detected
[ 8736.147552] usb 2-2.1: pl2303 converter now attached to ttyUSB0
[ 8741.014036] pl2303 2-2.1:1.0: pl2303_vendor_write - failed to write [0008]: -110
[ 8741.355430] pl2303 2-2.1:1.0: pl2303_vendor_write - failed to write [0009]: -110
[ 8742.015031] pl2303 ttyUSB0: pl2303_get_line_request - failed: -110
[ 8742.355664] pl2303 ttyUSB0: pl2303_set_line_request - failed: -110
[ 8743.016114] pl2303 2-2.1:1.0: pl2303_vendor_write - failed to write [0000]: -110
[ 8743.355428] pl2303 ttyUSB0: pl2303_set_control_lines - failed: -110
ときどき送信できる
USBシリアルアダプタを抜き差ししていると送信できるようになった。
pySerialの問題なのか、動作が安定しない。
リンク
上記のエラー関連では下記を見つけた。
[ 160.102015] pl2303 1-1.2:1.0: pl2303_vendor_write - failed to write [0008]: -110
具体的な解決策は読み切れていない。