LoginSignup
0
0

More than 5 years have passed since last update.

line monitor > コア部分 (v0.3, v0.4) > シリアルリレー (+UDP送信) + UDPコマンド受信 + com baud変更

Last updated at Posted at 2015-11-16
端末
a. line monitor本体実行 : RaspberryPi2 + raspbian (IP: 192.168.10.3)
b. COM送信 : Windows 8.1pro + TeraTerm
c. UDPコマンド送信 : CentOS 6.5 (IP: 192.168.10.8)
d. UDPモニタ出力先 : CentOS 6.5 (IP: 192.168.10.8)
治具
A. Win8.1 : SRC06-USB (USBシアリルケーブル)
B-1. RPi2 : VE488 (USBシリアルケーブル)
B-2. RPi2 : VE488 (USBシリアルケーブル)
X : TX-RX変換用治具 (`AとB-1` または `AとB-2`を接続に使用)

http://qiita.com/7of9/items/028556c5a819a6a8de96
で記載したRPi2動作のコア部分

プログラム

ソフト設計 @ mindmup

v0.3 @ github

プログラムの構成は現状、以下となっている。

  • dummySerial.py : CentOS上で開発するためのダミー
  • linemonitor.py : プログラム本体
  • utilComRelay.py : COM通信関連
  • utilSetting.py : 設定のget/set用
  • utilUdpCmd.py : UDPコマンド通信用

使用手順

  1. RPi2 において、linemonitor.pyを起動する ($python linemonitor.py).
  2. CentOSにおいて、echo "set,combaud,2400" | nc -w 1 -u 192.168.10.3 7000 を実行して、combaudを2400bpsにしておく (しない場合は9600bps)
  3. CentOSにおいて、UDPの出力を受けるため root権限で # tcpdump -A -n udp portrange 9000を実行しておく
  4. Win8.1のTeraTermを起動する。[端末]->[CRLF送信]の設定をしておく
  5. Win8.1のTeraTermの通信速度を2400bpsにする
  6. Win8.1のTeraTermからfrom winという文字を入力 (文字列は任意)してEnterを押す

以上でそれぞれの端末は以下の状態になっている。

RPi2
$ python linemonitor.py 
cmdport= 7000
rcvd:[ set,combaud,2400 ]
set combaud
2400
rcvd= from win
CentOSでtcpdumpによるUDP出力の受け
# tcpdump -A -n udp portrange 9000
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
22:46:50.861640 IP 192.168.10.3.53357 > 192.168.10.8.cslistener: UDP, length 12
E..(..@.@..g..
...
..m#(....2:from win
......

現状

とりあえず<CR><LF>終端のCOM通信に対しては、当初の予定通りの実装ができたと思う。

もう1本のUSBシリアルおよび、TX-RX変換治具を用意することで、実際の動作検証ができるようになると思う。

RPi2のプログラムとしては以下の課題があるが、当面、Unity(UI)側の実装を優先的に行っていく。

  • バイナリ文字列通信の対応 > 低優先度で実装予定
  • フロー制御 > 多分実装しない
  • reboot処理 > 必要なのだろうか...

未消化

linemonitor.pyにおいて comReopen()をコールしたらエラーが出た。
結局、動作優先として、comReopen()の中身をlinemonitor.pyに書くことで対応した。

v0.4

v0.4 @ github

  • monport関連でTypeError: an integer is requiredが出てしまうバグを修正した。
0
0
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
0
0