ユーザ用ツール

サイト用ツール


max3xx_tips:upload_di_state_to_harvest:start

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
max3xx_tips:upload_di_state_to_harvest:start [2023/06/22 19:30]
admin
max3xx_tips:upload_di_state_to_harvest:start [2023/06/23 08:56] (現在)
admin [アプリケーションの構成]
ライン 13: ライン 13:
 このサンプルは、下記により構成されています。 このサンプルは、下記により構成されています。
  
-  * MA-X3xx 内部の MQTT Broker(Mosquitto+  * MA-X3xx 内部の MQTT Broker(mosquitto
-  * DI の状態を監視し、DI 状態変化時に MQTT Broker に DI の状態を Publish するアプリケーション(di_mqtt)+  * DI の状態を監視((libgpiod を使用しています))し、DI 状態変化時に MQTT Broker に DI の状態を Publish するアプリケーション(di_mqtt)
   * MQTT Broker を Subscibe し、DI の状態を受け取ったら SORACOM Harvest Data にアップロードするアプリケーション(mqtt_harvest)   * MQTT Broker を Subscibe し、DI の状態を受け取ったら SORACOM Harvest Data にアップロードするアプリケーション(mqtt_harvest)
  
ライン 132: ライン 132:
  
 [[max3xx_devel:​build_firmware:​start|]] でも必要なのでインストールしておきます。 [[max3xx_devel:​build_firmware:​start|]] でも必要なのでインストールしておきます。
 +
 +参照: [[max3xx_devel:​setup_crossdev:​start|]]
 +
 +\\
  
 === Nim Compiler === === Nim Compiler ===
ライン 269: ライン 273:
 \\ \\
  
 +==== ソースのビルド ====
 +
 +=== nim_gpiod のインストール ===
 +
 +di_mqtt のソースをビルドするために必要なので、nim_gpiod((libgpiod の Nim 用ラッパーライブラリ)) をインストールします。
 +
 +<​code>​
 +user1@max3xx-devel:​~$ cd src/​nim_gpiod/​
 +user1@max3xx-devel:​~/​src/​nim_gpiod$ nimble install --cpu:arm64
 +  Verifying dependencies for nim_gpiod@0.2.0
 + ​Installing nim_gpiod@0.2.0
 +   ​Building nim_gpiod/​nim_gpiod using c backend
 +   ​Success:​ nim_gpiod installed successfully.
 +user1@max3xx-devel:​~/​src/​nim_gpiod$ ​
 +</​code>​
 +
 +\\
 +
 +=== di_mqtt のビルド ===
 +
 +ビルドする準備ができたので、di_mqtt をビルドします。
 +
 +<​code>​
 +user1@max3xx-devel:​~/​src/​nim_gpiod$ cd ../di_mqtt/
 +user1@max3xx-devel:​~/​src/​di_mqtt$ nimble build -d:release --cpu:arm64
 +  Verifying dependencies for di_mqtt@0.2.0
 + ​Installing argparse@0.10.1
 +Downloading https://​github.com/​iffy/​nim-argparse using git
 +  Verifying dependencies for argparse@0.10.1
 + ​Installing argparse@0.10.1
 +   ​Success:​ argparse installed successfully.
 + ​Installing nmqtt@>= 1.0.5
 +Downloading https://​github.com/​zevv/​nmqtt using git
 +  Verifying dependencies for nmqtt@1.0.5
 + ​Installing cligen@>​= 0.9.45
 +Downloading https://​github.com/​c-blake/​cligen.git using git
 +  Verifying dependencies for cligen@1.6.6
 + ​Installing cligen@1.6.6
 +   ​Success:​ cligen installed successfully.
 + ​Installing bcrypt@>​= 0.2.1
 +Downloading https://​github.com/​ithkuil/​bcryptnim using git
 +  Verifying dependencies for bcrypt@0.2.1
 + ​Installing bcrypt@0.2.1
 +   ​Success:​ bcrypt installed successfully.
 + ​Installing nmqtt@1.0.5
 +   ​Building nmqtt/​nmqtt/​nmqtt_password using c backend
 +   ​Building nmqtt/​nmqtt/​nmqtt using c backend
 +/​tmp/​nimble_22433/​githubcom_zevvnmqtt_1.0.5/​nmqtt.nim(285,​ 54) template/​generic instantiation of `async` from here
 +/​tmp/​nimble_22433/​githubcom_zevvnmqtt_1.0.5/​nmqtt.nim(292,​ 5) Warning: The bare except clause is deprecated; use `except CatchableError:​` instead [BareExcept]
 +/​tmp/​nimble_22433/​githubcom_zevvnmqtt_1.0.5/​nmqtt.nim(285,​ 54) template/​generic instantiation of `async` from here
 +/​home/​user1/​.choosenim/​toolchains/​nim-1.6.12/​lib/​pure/​asyncmacro.nim(42,​ 5) Warning: The bare except clause is deprecated; use `except CatchableError:​` instead [BareExcept]
 +... 中略 ...
 +/​home/​user1/​.choosenim/​toolchains/​nim-1.6.12/​lib/​pure/​asyncmacro.nim(42,​ 5) Warning: The bare except clause is deprecated; use `except CatchableError:​` instead [BareExcept]
 +/​tmp/​nimble_22433/​githubcom_zevvnmqtt_1.0.5/​nmqtt/​nmqtt_sub.nim(20,​ 222) template/​generic instantiation of `async` from here
 +/​home/​user1/​.choosenim/​toolchains/​nim-1.6.12/​lib/​pure/​asyncmacro.nim(42,​ 5) Warning: The bare except clause is deprecated; use `except CatchableError:​` instead [BareExcept]
 +   ​Success:​ nmqtt installed successfully.
 +      Info: Dependency on nim_gpiod@>​= 0.2.0 already satisfied
 +  Verifying dependencies for nim_gpiod@0.2.0
 + ​Installing jsony@>= 1.1.5
 +Downloading https://​github.com/​treeform/​jsony using git
 +  Verifying dependencies for jsony@1.1.5
 + ​Installing jsony@1.1.5
 +   ​Success:​ jsony installed successfully.
 +   ​Building di_mqtt/​di_mqtt using c backend
 +   ​Building di_mqtt/​mqtt_soracom using c backend
 +user1@max3xx-devel:​~/​src/​di_mqtt$ ​
 +</​code>​
 +
 +必要なライブラリが芋づる式に追加され、di_mqtt のビルドが完了しました。
 +
 +\\
 +
 +できあがったバイナリを確認してみます。
 +
 +<​code>​
 +user1@max3xx-devel:​~/​src/​di_mqtt$ ls -l bin/
 +total 1272
 +-rwxrwxr-x 1 user1 user1 563040 Jun 22 19:33 di_mqtt
 +-rwxrwxr-x 1 user1 user1 733408 Jun 22 19:33 mqtt_soracom
 +user1@max3xx-devel:​~/​src/​di_mqtt$ ​
 +</​code>​
 +
 +strip によりシンボルを除去してバイナリを小さくすることもできます。
 +
 +<​code>​
 +user1@max3xx-devel:​~/​src/​di_mqtt$ aarch64-linux-gnu-strip bin/*
 +user1@max3xx-devel:​~/​src/​di_mqtt$ ls -l bin/
 +total 952
 +-rwxrwxr-x 1 user1 user1 423936 Jun 22 19:35 di_mqtt
 +-rwxrwxr-x 1 user1 user1 546816 Jun 22 19:35 mqtt_soracom
 +user1@max3xx-devel:​~/​src/​di_mqtt$ ​
 +</​code>​
  
max3xx_tips/upload_di_state_to_harvest/start.1687429827.txt.gz · 最終更新: 2023/06/22 19:30 by admin