Difference between revisions of "OpenPlotter"

From wiki.bastelbude.grade.de
Jump to: navigation, search
(blackBox)
(setup Raspbian Stretch Lite)
Line 281: Line 281:
 
** ...
 
** ...
 
** reboot
 
** reboot
 +
* connect via ssh or scp
 +
<pre>
 +
sudo apt-get update
 +
sudo apt-get upgrade
 +
sudo apt-get install mc
 +
</pre>
  
 
== setup piCAN2 (as root)==
 
== setup piCAN2 (as root)==

Revision as of 13:06, 1 April 2018

general

Aim

  • fit a cheap and open source ECDIS on board of a sailing vessel
  • yacht has SeaTalkng network (/w Raymarine iTC-5 Converter)

Parts (boat specific)

  • Seatalkng extensions:
    • Spur-Kabel mit 1 offenen Ende 3m Art.-Nr: A06044 EUR 40,-
    • 5-Wege-Verbinder Art.-Nr: A06064 EUR 35,- (alternativ T-Stück Art.-Nr.: A06028 EUR 25,-)
    • Backbone-Kabel 0,40m - A06033 EUR 30,-

Mini-PC

  • Raspberry Pi 3 Model B EUR 33,50 or Raspberry Pi 3 Model B+ EUR 35,-
  • 16GB MicroSD Card EUR 10,-
  • PiCAN 2 EUR 45,- or PiCAN 2 incl. SMPS EUR 52,-

openPlotter

  • hardware
    • Raspberry Pi 3 Model B
    • PiCAN 2
  • eth0 IP set to static (192.168.1.112)

Setup Pi:

  • see also
  • connect to openplotter-UI (eg. VNC)
    • update openCPN
    • upgrade Raspbian
    • upgrade to openPlotter 0.17.1
    • Preferences > Raspberry Configuration > Interfaces > SSH:enable (Remote-access via WinSCP and Putty defaults pi:raspberry)
  • (sudo apt-get install tightvncserver (make RDP working))
  • sudo apt-get install can-utils
  • sudo apt-get install mc
  • update node
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt install nodejs
  • update signalk to latest
    • kill running signalk-server process
cd /home/pi/.config
rm -rf signalk-server-node_tmp
git clone https://github.com/SignalK/signalk-server-node.git signalk-server-node_tmp
cd signalk-server-node_tmp
npm install && npm run prepublishOnly
npm install mdns
cd /home/pi/.config
rm -rf signalk-server-node
mv signalk-server-node_tmp signalk-server-node
  • restart signalk @ openplotter-UI

Setup Android:

  • RDC from playStore (working)
  • aRDP free from playStore (suits my needs best)

Setup piCAN2:

  • (in case you want to play with virtual-can-interfaces) add to /etc/modules
vcan
  • add to /boot/config.txt
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
source /etc/network/interfaces.d/*
  • add to /etc/network/interfaces/interfaces.d/can0
#physical can interfaces
allow-hotplug can0
iface can0 can static
bitrate 250000
down /sbin/ip link set $IFACE down
up /sbin/ifconfig $IFACE txqueuelen 10000
  • (in case you want to play with virtual-can-interfaces) add to /etc/network/interfaces/interfaces.d/vcan0
#virtual can interfaces
auto vcan0
iface vcan0 inet manual
pre-up /sbin/ip link add dev $IFACE type vcan
up /sbin/ifconfig $IFACE up
  • restart interfaces
service networking restart
  • check interfaces (can0 and vcan0)
ifconfig
  • install canboat
mkdir ~/canboat
cd ~/canboat
sudo apt-get install xsltproc
git clone git://github.com/canboat/canboat
cd canboat
sudo make
sudo make install
  • working admin-ui generated canboat sample
    {
      "id": "canboat",
      "pipeElements": [
        {
          "type": "providers/simple",
          "options": {
            "logging": false,
            "type": "NMEA2000",
            "subOptions": {
              "type": "canbus",
              "interface": "vcan0"
            }
          }
        }
      ],
      "enabled": false
    }
  • not working admin-ui generated canboatjs sample
    {
      "id": "canboatjs",
      "pipeElements": [
        {
          "type": "providers/simple",
          "options": {
            "logging": false,
            "type": "NMEA2000",
            "subOptions": {
              "type": "canbus-canboatjs",
              "interface": "vcan0"
            }
          }
        }
      ],
      "enabled": true
    }
  • working canboatjs sample
    {                                                                           
      "id": "canbus-canboatjs",                                          
      "enabled": true,                                                          
      "pipeElements": [                                                         
        {                                                                       
          "type": "providers/canbus",                                           
          "options": {
            "canDevice": "vcan0"
          }                                                                     
        },                                                                      
        {                                                                       
          "type": "providers/canboatjs"                                         
        },                                                                      
        {                                                                       
          "type": "providers/n2k-signalk"                                       
        }                                                                       
      ]                                                                         
    }


  • old working canboat sample
{
  "id": "n2k-vcan0",
  "pipeElements": [
    {
      "type": "providers/execute",
      "options": {
        "command": "candump vcan0 | candump2analyzer "
      }
    },
    {
      "type": "providers/liner",
      "options": {
        "rawlogging": true,
        "logdir": "logs",
        "discriminator": "2"
      }
    },
    {
      "type": "providers/n2kAnalyzer"
    },
    {
      "type": "providers/n2k-signalk"
    }
  ]
}

configure kplex and signalk

  • 'Signal K Server Plugin Configuration' > activate 'Convert Signal K to NMEA0183'
    • select sentences you are interested in
  • NMEA0183 (this is kplex) > Advanced >
    • add input channel tcp:localhost:10110
    • remove filter at opencpn out channel
[tcp]
name=signalk_in
direction=in
address=localhost
port=10110

[tcp]
name=opencpn
direction=out
mode=server
port=10109

experimental

    {"pipeElements": [
      {"type": "providers/execute", "options": {"command": "candump can0 | candump2analyzer | analyzer -json -si -nv"}},
      {"type": "providers/liner"},
      {"type": "providers/from_json"},
      {"type": "signalk-socketcan-device", "options": {"n2kAddress": 110, "canDevice": "can0"}},
      {"type": "providers/n2k-signalk"}
      ],"id": "n2k-can0"
    }

blackBox

  • hardware
    • Raspberry Pi 3 Model B+
    • PiCAN 2 incl. SMPS
  • eth0 IP set to static (here 192.168.1.111)

setup Raspbian Stretch Lite

  • download Raspbian Stretch Lite and copy image to SD-card (Etcher or win32diskimager)
  • log in (hdmi) as pi:raspberry (us-keboard-layout!)
  • start sudo raspi-config
    • enable ssh
    • resize SD-card
    • set wifi locale
    • ...
    • reboot
  • connect via ssh or scp
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mc

setup piCAN2 (as root)

  • install can-utils
apt-get install can-utils
  • add to /boot/config.txt
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
  • add to /etc/modules
vcan
  • add to /etc/network/interfaces
source /etc/network/interfaces.d/*
  • add to /etc/network/interfaces/interfaces.d/can0
#physical can interfaces
allow-hotplug can0
iface can0 can static
bitrate 250000
down /sbin/ip link set $IFACE down
up /sbin/ifconfig $IFACE txqueuelen 10000
  • add to /etc/network/interfaces/interfaces.d/vcan0
#virtual can interfaces
auto vcan0
iface vcan0 inet manual
pre-up /sbin/ip link add dev $IFACE type vcan
up /sbin/ifconfig $IFACE up
  • install canboat
apt-get install xsltproc
apt-get install gcc
apt-get install make
apt-get install git
mkdir ~/canboat
cd ~/canboat
git clone git://github.com/canboat/canboat
cd canboat
make
make install

install signalK (as root)

apt-get update
apt-get install -y curl git build-essential dialog
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install nodejs
apt-get install libnss-mdns avahi-utils libavahi-compat-libdnssd-dev
npm install -g --unsafe-perm signalk-server

setup signalK (as pi)

sudo signalk-server-setup
reboot
  • in your browser, start signalk-web-interface (eg. http://192.168.1.111:3000)
  • add admin-user via admin-ui and log-in
  • add canboat Data-Provider via Admin-UI (stored in home/pi/.signalk/settings.json )
    {
      "id": "canboat",
      "pipeElements": [
        {
          "type": "providers/simple",
          "options": {
            "logging": false,
            "type": "NMEA2000",
            "subOptions": {
              "type": "canbus",
              "interface": "vcan0"
            }
          }
        }
      ],
      "enabled": true
    }
  • alternative add canboatjs Data-Provider via Admin-UI (stored in home/pi/.signalk/settings.json )
    {
      "id": "canboatjs",
      "pipeElements": [
        {
          "type": "providers/simple",
          "options": {
            "logging": false,
            "type": "NMEA2000",
            "subOptions": {
              "type": "canbus-canboatjs",
              "interface": "vcan0"
            }
          }
        }
      ],
      "enabled": true
    }

aisdispatcher

    {
      "id": "AIS-udp",
      "pipeElements": [
        {
          "type": "providers/simple",
          "options": {
            "logging": false,
            "type": "NMEA0183",
            "subOptions": {
              "type": "udp",
              "port": "77777"
            }
          }
        }
      ],
      "enabled": true
    }

raymarine autopilot

samba

wifi client and access-point

  • install firmware
apt-get install firmware-brcm80211
  • install iw, wireless-tools
apt-get install iw wireless-tools
  • add to /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug uap0
auto uap0
iface uap0 inet static
    address 10.3.141.1
    netmask 255.255.255.0
  • set up /etc/udev/rules.d/90-wireless.rules
ACTION=="add", SUBSYSTEM=="ieee80211", KERNEL=="phy0", \
    RUN+="/sbin/iw phy %k interface add uap0 type __ap"
  • run iw
/sbin/iw phy phy0 interface add uap0 type __ap

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
country=DE

network={
    ssid="noD***"
    scan_ssid=1
    psk="psL***"
    key_mgmt=WPA-PSK
}
  • run
ifdown wlan0
ifup wlan0
wpa_cli reconfigure
iw dev wlan0 scan