EDGEPLANT CAN-USB I/Fへデータを出力する

リアルタイムでダウンストリームしたCANデータを、device-connector-intdashを使用してEDGEPLANT CAN-USB Interfaceに書き込むための設定例です。

../../_images/can-usb-downstream-sample.svg

図 33 ダウンストリームしたCANデータをEDGEPLANT CAN-USB Interfaceに書き込むための設定例

ダウンストリームの設定

以下のコマンドを実行して、 down というIDを持つダウンストリームを作成します。

送信元が 03ace3b1-d208-4fc3-9763-a502923ca6ab で、データ名称が can のデータのみを受信するようダウンストリームフィルターが設定してあります。

$ intdash-agentctl config downstream --create '
    id: down
    enabled: true
    dest_ids:
     - down-can
    filters:
     - src_edge_uuid: 03ace3b1-d208-4fc3-9763-a502923ca6ab
       data_filters:
       - type: can_frame
         name: can
  '

サーバーからダウンストリームされたデータは、デバイスコネクターIPC down-hello に送られます。デバイスコネクターIPC down-hello はこのあとの手順で設定します。

デバイスコネクターIPCの設定

デバイスコネクターにデータを渡すためにデバイスコネクターIPCを追加します。以下のコマンドを実行してください。

$ intdash-agentctl config device-connector down --create '
    id: down-can
    format: iscp-v2-compat
    ipc:
      type: fifo
      path: /var/run/intdash/down-can.fifo
    launch:
      cmd: device-connector-intdash
      args:
      - --config
      - /etc/dc_conf/apt_cantrx-down.yml
      environment:
      - DC_APT_CANTRX_SINK_CONF_PATH=/dev/apt-usb/by-id/usb-xxx
      - DC_APT_CANTRX_SINK_CONF_LISTENONLY=1
      - DC_APT_CANTRX_SINK_CONF_BAUDRATE=500
      - DC_APT_CANTRX_SINK_CONF_TIMESTAMP_MODE=device
      - DC_FILE_SRC_CONF_PATH=/var/run/intdash/down-can.fifo
'
  • launch で、device-connector-intdashを起動するように設定しています。

  • device-connector-intdashを実行するための設定は、パイプライン設定ファイル /etc/dc_conf/apt_cantrx-down.yml として与えています(このファイルは次の手順で作成します)。 また、パイプライン設定ファイルで使用するための環境変数を与えています( environment ) 。

  • ダウンストリームから /var/run/intdash/down-can.fifo を介してデバイスコネクターに送られます。

device-connector-intdashのパイプライン設定

device-connector-intdash用のパイプライン設定ファイルを以下の内容で作成し、 /etc/dc_conf/apt_cantrx-down.yml として保存します。

before_task:
  # sync timestamp
  - mkdir -p /var/lock/intdash
  - |
    BASETIME_CLOCK_ID=$DC_CLOCK_ID
    meas-hook --lockfile /var/lock/intdash/dc_apt_usbtrx.lock --command "
      if command -v apt_usbtrx_timesync.sh     > /dev/null 2>&1 ; then apt_usbtrx_timesync.sh;     exit 0; fi;
      if command -v apt_usbtrx_timesync_all.sh > /dev/null 2>&1 ; then apt_usbtrx_timesync_all.sh; exit 0; fi;
      echo \"ERROR: timestamp script not found\";
      exit 1;
    "

after_task:
  - rm -f /var/lock/intdash/dc_apt_usbtrx.lock

tasks:
  - id: 10
    element: file-src
    conf:
      path: $(DC_FILE_SRC_CONF_PATH)

  - id: 11
    element: apt-cantrx-sink
    from: [[10]]
    conf:
      clock_id: CLOCK_MONOTONIC
      path: $(DC_APT_CANTRX_SINK_CONF_PATH)
      listenonly: $(DC_APT_CANTRX_SINK_CONF_LISTENONLY)
      baudrate: $(DC_APT_CANTRX_SINK_CONF_BAUDRATE)
      timestamp_mode: $(DC_APT_CANTRX_SINK_CONF_TIMESTAMP_MODE)
  • file-srcでは、intdash Edge Agent 2によって書き出されたデータを$(DC_FILE_SINK_CONF_PATH)から読みます。(参考: file-src

  • apt-cantrx-sinkエレメントでは、環境変数として与えられた値を使ってEDGEPLANT CAN-USB Interfaceにデータを渡します。(参考: apt-cantrx-src

ストリーマーの起動

以上の設定ができたらストリーマーを起動します。

$ intdash-agentctl run