ハード
- OpenBlocks BX1
- BSUSRC0610BS
- とあるコンサルの計測装置の親機
接続すると下記のように出力される.
obsiot kernel: [ 505.416133] usb 1-1.2: new full-speed USB device number 5 using dwc3-host obsiot kernel: [ 505.444863] usb 1-1.2: New USB device found, idVendor=0403, idProduct=6001 obsiot kernel: [ 505.444894] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 obsiot kernel: [ 505.444916] usb 1-1.2: Product: USB HS SERIAL CONVERTER obsiot kernel: [ 505.444934] usb 1-1.2: Manufacturer: FTDI obsiot kernel: [ 505.444952] usb 1-1.2: SerialNumber: FT0D05UV obsiot kernel: [ 505.521675] usbcore: registered new interface driver usbserial obsiot kernel: [ 505.521807] usbcore: registered new interface driver usbserial_generic obsiot kernel: [ 505.521908] usbserial: USB Serial support registered for generic obsiot kernel: [ 505.530989] usbcore: registered new interface driver ftdi_sio obsiot kernel: [ 505.531116] usbserial: USB Serial support registered for FTDI USB Serial Device obsiot kernel: [ 505.532207] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected obsiot kernel: [ 505.532420] usb 1-1.2: Detected FT232BM obsiot kernel: [ 505.532442] usb 1-1.2: Number of endpoints 2 obsiot kernel: [ 505.532463] usb 1-1.2: Endpoint 1 MaxPacketSize 64 obsiot kernel: [ 505.532482] usb 1-1.2: Endpoint 2 MaxPacketSize 64 obsiot kernel: [ 505.532500] usb 1-1.2: Setting MaxPacketSize 64 obsiot kernel: [ 505.539764] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
通信設定 と コマンドフォーマット
対応関係をみてみようと思った.でもあまり意味ないような.
項目 | 仕様 | 設定 |
---|---|---|
インターフェース規格 | EIA-232C 準拠 | |
通信方式 | 全二重通信 | |
データ伝送方式 | 調歩同期方式 | |
通信速度 | 9600bps | 9600 |
データ長 | 8 ビット | cs8 |
ストップビット | 1 ビット | -cstopb |
パリティビット | なし | -parenb |
フロー制御 | なし | -ixon |
コマンド形式 | ASCII 形式 | |
デリミタ・ |
“CR”または”CR+LF” |
最終的に・・・.
昔の設定をひっぱりだしてきたら,よかったみたい.
root@obsiot:/dev# stty -F /dev/ttyUSB0 sane root@obsiot:/dev# stty -F /dev/ttyUSB0 0:5:8bd:8a30:3:1c:7f:15:4:2:64:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 root@obsiot:/dev# stty -a -F /dev/ttyUSB0 speed 9600 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 = 100; time = 2; -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
確認は
自分はいつも iTerm2 でタブを並べて,片方は cat /dev/ttyUSB0 でつなげておいて,もう片方から echo '2' > /dev/ttyUSB0 とかしてます. それで確認して大丈夫なら,そのあと perl のスクリプトとか動かしていきます.
debian なので libdevice-serialport-perl を入れて,下記を最初に書いてます. 括弧の中身は,参考の通りにしているけど,それでいいのかな?
use Device::SerialPort qw( :PARAM :STAT 0.07 );