Top > 日記 > 2017-09-29

DVSP2でPi-Star

DVSP2_on_Rpi-Zero(V1.3)+OLED(128x64)にPi-Starのイメージ(v3.4.5)を一部改変して動くようにした。また以下機能追加。
・ローカルUS-TRUST系レピーターに接続できるように
・OLEDによるヘッダーとショートメッセージ情報を表示できるように
・参考:http://www.pistar.uk/downloads/
・必須事項:ショートメッセージを表示させるためには、DStarRepeater by mkagawa の
 パッケージを導入(make and install)して、いくつかの起動スクリプトの修正が必要です。

  1. serviceの停止*1
    rootの権限で
    systemctl stop dmrgateway.timer
    systemctl disable dmrgateway.timer
    systemctl stop dmrgateway.service
    systemctl disable dmrgateway.service
    systemctl stop ysfgateway.timer
    systemctl disable ysfgateway.timer
    systemctl stop ysfgateway.service
    systemctl disable ysfgateway.service
    systemctl stop pistar-upnp.timer
    systemctl disable pistar-upnp.timer
    systemctl stop pistar-upnp.service
    systemctl disable pistar-upnp.service
    systemctl stop p25gateway.timer
    systemctl disable p25gateway.timer
    systemctl stop p25gateway.service
    systemctl disable p25gateway.service
    systemctl stop p25parrot.timer
    systemctl disable p25parrot.timer
    systemctl stop p25parrot.services
    systemctl disable p25parrot.services
    systemctl stop ysfparrot.timer
    systemctl disable ysfparrot.timer
    systemctl stop ysfparrot.service
    systemctl disable ysfparrot.service
    systemctl stop mmdvmhost.timer
    systemctl disable mmdvmhost.timer
    systemctl stop mmdvmhost.service
    systemctl disable mmdvmhost.service
    systemctl stop minissdpd.service
    systemctl disable minissdpd.service
     
  2. ノードタイプの選択(Configuration画面)
    node_type.JPG
  3. ircddbgateway設定(expert→ircddbgateway画面)
    dplus_login.JPG
  4. PHP編集
    # nano /var/www/dashboard/admin/dstarrepeater/link_manager.php
    while (!feof($dplusFile)) {
            $dplusLine = fgets($dplusFile);
            if (strpos($dplusLine, 'REF') !== FALSE && strpos($dplusLine, '#') === FALSE) {
                ↓
    while (!feof($dplusFile)) {
            $dplusLine = fgets($dplusFile);
            if ((strpos($dplusLine, 'JP1') !== FALSE || strpos($dplusLine, 'REF') !== FALSE) && strpos($dplusLine, '#') === FALSE) {
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^追加 *カッコも忘れないように
    ------------------------------------------
    # nano /var/www/dashboard/admin/admin.php
    while (!feof($dplusFile)) {
            $dplusLine = fgets($dplusFile);
            if (strpos($dplusLine, 'REF') !== FALSE && strpos($dplusLine, '#') === FALSE && strpos($dplusLine, 'REF001') === FALSE)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 削除
               ↓
    while (!feof($dplusFile)) {
            $dplusLine = fgets($dplusFile);
            if ((strpos($dplusLine, '#') === FALSE) && strpos($dplusLine, 'REF001') === FALSE)
     
  5. DPlus_Local.txtを作成・追加
    # nano /usr/local/etc/DPlus_Local.txt
    JP1YJQ  jp1yjq.xxx.yy ← ドメインまたはIPアドレス、デリミタは必ずタブのみにする
    JP1YKM  jp1ykm.xxx.yy ← ドメインまたはIPアドレス、デリミタは必ずタブのみにする
    -----------------------
    # nano /root/addlocal.sh
    -----------------------
    #!/bin/bash
    FLAG=`grep JP1YJQ /usr/local/etc/DPlus_Hosts.txt`
    if test "$FLAG" = ""; then
      cat /usr/local/etc/DPlus_Local.txt >> /usr/local/etc/DPlus_Hosts.txt
      pkill ircddbgatewayd
      sleep 2
      /usr/local/bin/ircddbgatewayd -daemon
    fi
    -----------------------
    を作成して、
    # chmod 755 addlocal.sh
    と実行権を付与しておき、夜中3時過ぎに、新しい各種Hosts.txtがロードされ更新されてしまうので、
    # crontab -e
    0 4 * * * /root/addlocal.sh
    として毎日4時に、Hostsファイルを追加し、ircddbgatewaydを再起動して読み込ませる。
  6. 他のcronでの自動起動を制限(コメントアウトしておく)
    # nano /etc/crontab
    # m h dom mon dow user  command
    #*/5 * * * * root /usr/local/sbin/pistar-upnp.service start > /dev/null 2>&1
    # 17 * * * * root cd / && run-parts --report /etc/cron.hourly
  7. cronを再起動(念のため)
    # /etc/init.d/cron restart
  8. OLEDへの表示
    --- /root/lcdx.py ----
    #!/usr/bin/python
    #-*- coding:utf-8 -*-
    
    #import RPi.GPIO as GPIO
    
    import re
    import subprocess
    import json
    from datetime import datetime
    from oled import OLED
    from oled import Font
    from oled import Graphics
    import sys
    import time
    
    # Connect to the display on /dev/i2c-1
    dis = OLED(1)
    
    # Start communication
    dis.begin()
    
    # Start basic initialization
    dis.initialize()
    
    # Do additional configuration
    dis.set_memory_addressing_mode(0)
    dis.set_column_address(0, 127)
    dis.set_page_address(0, 7)
    dis.set_inverse_display(0)
    #dis.set_memory_addressing_mode(1)
    
    # Clear display
    dis.clear()
    dis.deactivate_scroll()
    # Set font scale x2
    f = Font(2)
    
    #from time import time, asctime, sleep, localtime
    #def main():
    while True:
        msg = ""
        station = ""
        cmd = "tail -500 /var/log/pi-star/dstarrepeaterd.log | grep -e 'Slow' | tail -1 | cut -c43-61"
        LastLink = subprocess.check_output(cmd, shell = True )
        LastLink = LastLink.replace("Linked to", "")
        NowDT = datetime.now().strftime("%H:%M")
        cmd = "grep R_ShortMsg  /var/log/pi-star/dstarrepeaterd.log | tail -1 | cut -c25-"
        RSM = subprocess.check_output(cmd, shell = True )
        m = json.loads(RSM)
        if m and m['R_ShortMsg']:
            match = m['R_ShortMsg']
            station = match['station'].strip()
            suffix = match['suffix'].strip()
            msg = match['msg'].strip()
            msg = msg.replace("/", " ")
            if msg == '' or msg == '_' or "Not" in msg or "It is" in msg:
                msg = NowDT + str.strip(LastLink)
                pm1 = str(station)
                pm2 = str(msg[0:5])
                if "Linked" in msg:
                    pm3 = str(msg[6:15])
                else:
                    pm3 = str(msg[5:14])
    
                dis.clear()
                f.scale = 2
                f.print_string(0,  0, pm1)
                f.print_string(0, 20, pm2)
                f.print_string(0, 36, pm3)
                dis.update()
            else:
                pm1 = str(station)
                pm2 = str(msg[0:9])
                if "Linked" in msg:
                  pm3 = str(msg[10:18])
                else:
                    pm3 = str(msg[5:14])
    
                dis.clear()
                f.scale = 2
                f.print_string(0,  0, pm1)
                f.print_string(0, 20, pm2)
                f.print_string(0, 36, pm3)
                dis.update()
            else:
                pm1 = str(station)
                pm2 = str(msg[0:9])
                if "Linked" in msg:
                  pm3 = str(msg[10:18])
                else:
                  pm3 = str(msg[9:18])
    
                dis.clear()
                f.scale = 2
                f.print_string(0,  0, pm1)
                f.print_string(0, 20, pm2)
                f.print_string(0, 36, pm3)
                dis.update()
    
        time.sleep(4.1)
    
    if __name__ == "__main__":
    
      try:
        main()
      except KeyboardInterrupt:
        pass
      finally:
         print "Goodbye!"
    -------------------------
    確認のため
    # /root/lcdx.py &
    と、常駐起動して動作確認。OKであれば、/etc/rc.local に追加しておく。
  9. 表示例
    例-1 接続なく待機中の場合              例-2 ノードが接続先へ接続した時
       ノードコール/現在の時刻/接続状態           ノードコール/接続状態/接続先
    IMG_2624.JPG  IMG_2629.JPG
     
    例-3 アクセス局にメッセージが無い場合        例-4 アクセス局にメッセージがある場合
       アクセスコール/現在時刻/接続先            アクセスコール/ショートメッセージ(2行)
    IMG_2631.JPG  IMG_2639.JPG
     
    例-5 アクセス局にメッセージがある場合        例-6 接続後誰もアクセスなしの場合
       アクセスコール/ショートメッセージ(2行)       ノードコール/現在時刻/接続先
    IMG_2641.JPG  IMG_2644.JPG
     

    URL B I U SIZE Black Maroon Green Olive Navy Purple Teal Gray Silver Red Lime Yellow Blue Fuchsia Aqua White


*1 DVSP2なのでDMR/P25/YSFは利用できないので

添付ファイル: fileIMG_2644.JPG 361件 [詳細] fileIMG_2641.JPG 346件 [詳細] fileIMG_2639.JPG 328件 [詳細] fileIMG_2631.JPG 366件 [詳細] fileIMG_2629.JPG 426件 [詳細] fileIMG_2624.JPG 323件 [詳細] filedplus_login.JPG 350件 [詳細] filenode_type.JPG 342件 [詳細]

リロード   新規 下位ページ作成 凍結解除 差分 コピー 名前変更   ホーム 一覧 検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: Tue, 02 May 2023 11:02:02 JST (360d)