LoginSignup
1
2

More than 5 years have passed since last update.

RPi2 / python > USBシリアル受信 > 受信タイムアウトが起きてしまう > TeraTermの送信設定がCRだった。 CR+LFに変更した

Last updated at Posted at 2015-11-08
動作確認
受信側: RaspberryPi2 + raspbian
送信側: Windows8.1 + TeraTerm
USBシリアルケーブル VE488 x 2本
クロス用治具 (TX-RX)

RPi2側では以下のpythonスクリプトを実行。

151108b.py
import serial
import time

def main():
    print "Hello"
    con1=serial.Serial('/dev/ttyUSB1', 9600, timeout=10)

    str1=con1.readline()
    print "rcvd=", str1

if __name__ == '__main__':

以下を実行。
Windows8.1のTeraTerm側で"kkkkkkk"を送信するのだが、RPi2側は何故か10秒の受信タイムアウトが起きてからprintを実行する。

pi@raspberrypi ~/lineMonitor $ python -u 151108b.py 
Hello
rcvd= kkkkkkkk

<CR><LF>がきちんと受信できてないのだろうか?
要調査。

解決

TeraTerm側の設定の問題だった。送信設定がCRになっていて、LFを受信待ちのRPiが受信タイムアウトになっていた。

TeraTermの設定を以下のようにする。

  1. [設定]-[端末]を選択
  2. 改行コード枠にある「送信(M)」をCRからCR+LFに変更する

これで受信タイムアウトがなくなった。

1
2
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
2