ビーグルボーン ブラック ワイヤレス: Ubuntu 16.04、
コンピューター: Ubuntu 16.04、
パイソン 3.5.2
Beaglebone Black を使用して Modbus 経由でデバイスと通信しようとしています。を使用して USB/RS485 ドングルでこれと同じことをしている人を読んだことがありますminimalmodbus
。設定を変更してみました。考えられるすべてのボーレート、短いケーブルなど。このタイプの作業のために設定する必要がある/設定が間違っている何かが Beagle 内にあるに違いありません。
コード
#!/usr/bin/env python
# -*- coding; utf-8 -*-
import minimalmodbus
import serial
import time
i = minimalmodbus.Instrument(port='/dev/ttyUSB0', slaveaddress=1, mode='rtu')
i.serial.baudrate = 115200
i.serial.bytesize = 8
i.serial.parity = serial.PARITY_EVEN
i.serial.stopbits = 1
i.serial.timeout = 1
i.handle_local_echo = None
while True:
try:
print(i.read_registers(2008, 2, 3))
except serial.serialutil.SerialException as error:
print(error)
except FileNotFoundError as error2:
print(error2)
except IOError as error3:
print(error3)
time.sleep(1)
... USB/RS485ドングルを使用。このドングルとコードの組み合わせを使用すると、私のコンピューターでは (過去 4 か月間) 完璧な結果が得られますが、今日の Beagle ではそうではありません。
コンピューター: 受信したメッセージ:
[0, 0]
Beagle : エラーを受け取りました:
IOError: No communication with instrument (no answer)
トラブルシューティングの可能な手段を探しています。ケーブルが長すぎず、USB ドングルも問題ないことを確認しました。コードの問題も除外しました。
lsusb
編集 1: を含めるのを忘れたls /dev/ttyUSB*
:
Bus 002 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 002 Device 003: ID 04d9:0024 Holtek Semiconductor, Inc.
Bus 002 Device 002: ID 0409:0059 NEC Corp. HighSpeed Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
と
/dev/ttyUSB0
編集2:
pyserial
Rxd と Txd の + 端子と - 端子を使用して短絡することで、ループバック セットアップを実現できます。
編集3:
考えられるすべての配線構成を試しました。コンピューター上で機能する構成は 1 つだけです (Tx+ -> A および Tx- -> B)。デバッグ機能を使用しているminimalmodbus
ときに、Beagle とコンピューターのデバイスに同じメッセージが送信されていることがわかります ( '\x01\x03\x07Ø\x00\x02ED' (01 03 07 D8 00 02 45 44)
)。コンピュータは応答を受信しますが、ビーグルは受信しません。
ビーグルはアダプターを に問題なく取り付け/dev/ttyUSB0
ます。
編集4:
@Carlo Zanocco は次の出力を要求しましたls /dev/ | grep tty
tty
tty0
tty1
tty10
tty11
tty12
tty13
tty14
tty15
tty16
tty17
tty18
tty19
tty2
tty20
tty21
tty22
tty23
tty24
tty25
tty26
tty27
tty28
tty29
tty3
tty30
tty31
tty32
tty33
tty34
tty35
tty36
tty37
tty38
tty39
tty4
tty40
tty41
tty42
tty43
tty44
tty45
tty46
tty47
tty48
tty49
tty5
tty50
tty51
tty52
tty53
tty54
tty55
tty56
tty57
tty58
tty59
tty6
tty60
tty61
tty62
tty63
tty7
tty8
tty9
ttyGS0
ttyS0
ttyS1
ttyS2
ttyS3
ttyS4
ttyS5
ttyUSB0
編集5:
の出力stty -F /dev/ttyUSB0 -a
:
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 0; time = 0;
parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany
-imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl
-echoke -flusho -extproc