LoginSignup
1
0

More than 1 year has passed since last update.

LRA1 にプログラムを登録する

Last updated at Posted at 2022-09-27

「ワンライナーでウェイトをかけて表示する bash スクリプト」
https://qiita.com/nanbuwks/items/02a78c72fb22e610e6b8

で作ったワンライナーを使って、株式会社アイ・ツーの LoRa モジュール LRA1 にプログラムを登録します。

LRA1 は BASIC プログラムで動かすことができますが、プログラムを登録するにはシリアルポートから1行1行入力する必要があります。ターミナルソフトから一括コピペしようとすると、処理の取りこぼしが発生することがあるので、休み休み入力します。そのために上記ウェイトをかけて表示するワンライナーを使用します。

環境

  • Ubuntu Linux 22.04 LTS Desktop Ja
    • 基本的に Bash の動く環境ならどれでも動くはず。
  • USBシリアルモジュール で LRA1 と接続済み。
    • ポートは /dev/ttyUSB0
  • 通信ソフトとして picocom を使用
  • 改行コードが適切に処理できるなら何でもいいはず。
  • プログラムは test.bas というファイルで保管しています。
    • 改行コードは lf です。異なる改行コードで保管している場合は必要に応じ、適宜スクリプトを変更する必要があります。

予備知識

LRA1 の改行コードは CRLF です。そのために picocom やスクリプトで改行コード変換の設定を使っています。

前準備

まず、picocom でパラメータを指定してポートを開きます。


$ picocom -b 115200 -r -l --omap crcrlf /dev/ttyUSB0
port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : yes
hangup is      : no
nolock is      : yes
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : crcrlf,
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

>

プログラムが書き込めるようにし、既存のものを消去します。

>edit 1
OK
>>new
OK

Ctrl+A,Ctrl+X を押して、picocom を終了します。

>>
Terminating...
Skipping tty reset...
Thanks for using picocom


送信している状況をモニターするために、送信しているシェルとは別に /dev/ttyUSB0 をモニターします。

$ cat /dev/ttyUSB0 

別シェルを立ち上げ、上記スクリプトで test.bas を送ります。

while read line; do echo -n $line ; printf "\r\n";sleep 1;
 done < test.bas > /dev/ttyUSB0

モニター用のシェルで、送られているのが確認できます。

>>10 ' ------------------initialize----------------------
>>20 ' ------check watchdog (if $80=ctrl then error stop occored)
.
.
.
>>860 '--- ccs811 nwake up
>>870 Outp 28,0
>>880 Goto _ccs811measure
>>

送り終わったら、モニター用のシェルは Ctrl+Cで終了します。

>>^C

picocom を立ち上げて保存処理などを行います。


$ picocom -b 115200 -r -l --omap crcrlf /dev/ttyUSB0
.
.
.
Type [C-a] [C-h] to see available commands
Terminal ready

>>psave
OK
>>

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