Skip to content

Latest commit

 

History

History
185 lines (127 loc) · 7.87 KB

27.01.2020.md

File metadata and controls

185 lines (127 loc) · 7.87 KB

Development Environment

27/01/2020 : 09:42:41

Use VisualStudio code to run application code on the Pi, from the PC. Using the following resources:

Use a router to connect the Pi to the mac

  1. Mac Book Pro

    1. WiFi interface connected to ISP
    2. Ethernet connected to LinkSys WRT1900 ACS out-of-the box.
  2. MacBook, Network Preferences, set service order, so Wifi is above Ethernet. This this way, the MBP retains its internet connection.

  3. Mac Book ifconfig shows I have connection to local DHCP and external.

    1. en0: inet 192.168.1.179
    2. en1: inet 10.xxx.xxx.xxx
  4. Raspberry Pi:

    1. Fresh install of Raspbian
    2. Connect Raspberry Pi to router via Ethernet
    3. Boot into PIXEL UI
    4. 'Welcome to Raspberry Pi', and helpful notice of IP address, supplied by router's DHCP.
  5. LinkSys Router

    1. Connect MBP via ethernet
    2. Find the router dashboard withbrowser at 192.168.1.1.
    3. Manually log-in, bypassing commercial cruft to set-up account.
    4. Out-of-the-box password is 'admin'.
    5. In router dashboard, find the connected devices
    6. Note the IP address of the PI. (192.168.1.163)
    7. Router gives me the option of reserving the IP address so I do. RPi will now get this address whenever it is connected.
  6. Raspberry Pi: Enable SSH

    1. See: https://www.raspberrypi.org/documentation/remote-access/ssh/
    2. Go to Preferences > Raspberry Pi Configuration
    3. Go to Interfaces Tab: Enable SSH
    4. Click OK
  7. MBP: Connect via SSH

    adanac:dev coops$ ssh pi@192.168.1.163
    
    The authenticity of host '192.168.1.163 (192.168.1.163)' can't be established.
    
    ECDSA key fingerprint is SHA256:Qam4uV0TyvfaX00pfwkan6ITjsrVxjFqOL1H5/3l3cs.
    
    Are you sure you want to continue connecting (yes/no)? yes
    
    Warning: Permanently added '192.168.1.163' (ECDSA) to the list of known hosts.
    
    pi@192.168.1.163's password: 
    
    Linux raspberrypi 4.19.93-v7+ #1290 SMP Fri Jan 10 16:39:50 GMT 2020 armv7l
    
    The programs included with the Debian GNU/Linux system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.
    
    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    Last login: Sun Jan 26 15:31:16 2020
    
    SSH is enabled and the default password for the 'pi' user has not been changed.
    This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
    
  8. Make sure we can connect MBP to RPi, passwordless

    1. See: https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md

    2. On MBP: ssh-keygen

    3. Generated public / private key pair without passphrase in the default location.

    4. Check: ls ~/.ssh Should get

      1. id_rsa
      2. id_rsa.pub
    5. Transfer the public key to the RPi:

      adanac:dev coops$ ssh-copy-id pi@192.168.1.163
      /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/coops/.ssh/id_rsa.pub"
      /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
      /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
      pi@192.168.1.163's password: 
      
      Number of key(s) added:        1
      
      Now try logging into the machine, with:   "ssh 'pi@192.168.1.163'"
      and check to make sure that only the key(s) you wanted were added.
      
      adanac:dev coops$ ssh pi@192.168.1.163
      Linux raspberrypi 4.19.93-v7+ #1290 SMP Fri Jan 10 16:39:50 GMT 2020 armv7l
      
      The programs included with the Debian GNU/Linux system are free software;
      the exact distribution terms for each program are described in the
      individual files in /usr/share/doc/*/copyright.
      
      Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
      permitted by applicable law.
      Last login: Sun Jan 26 15:45:52 2020 from 192.168.1.179
      
      SSH is enabled and the default password for the 'pi' user has not been changed.
      This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
  9. MBP install VS Code

    1. Standard VS Code installation will support remote extension to RPi
  10. MBP add extension

    1. Remote - SSH
      1. ms-vscode-remote.remote-ssh
  11. Connect to RPi

    1. https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host
    2. Use F1 key, then choose 'connect to to host'
      1. pi@192.168.1.163
  12. Enable remote desktop, on the Pi

    1. We use this in emergencies - for when it's a bit tricky connecting the Pi to WiFi for internet access (to GitHub)
    2. Pi: Preferences > Raspberry Pi configuration
      1. VNC: Enable
  13. Enable VNC Viewer on the MBP

    1. Install VNC Viewer for Google Chrome
    2. Connect to pi@192.168.1.163
    3. authenticate using default raspberry pi username and password.
  14. Prioritise internet access for WiFi, before Ethernet (VERY important!)

    1. Pi: Open /etc/dhcpcd.conf

    2. at the end of the file, add this. The lower the metric, the higher the priority.

    3. interface eth0
      metric 300
      
      interface wlan0
      metric 200
    4. restart the RPi.

  15. Git, from VS Code

    1. See: https://code.visualstudio.com/docs/editor/versioncontrol#_git-support
    2. In VS Code you can now go to View : Terminal
    3. This brings up a terminal window, pointing to the current working directory on the Pi (I am really impressed by all this, btw. It's incredible.)
    4. Use git --versionto get the current version. Should be something like 2.20.1
    5. Now use this, to clone this repo onto the RPi: https://code.visualstudio.com/docs/editor/versioncontrol#_cloning-a-repository
      1. SHIFT-CMD-P to bring up command palette
      2. Git: Clone
      3. VS Code prompts for the URL of the Repo.
        1. https://github.com/aliceliveprojects/little_blue_pi.git
      4. VSCode prompts for the location of the local repo, on the Pi
        1. /home/pi/Documents/github/little_blue_pi/little_blue_pi
      5. Can now access the local repo on the Pi from VS Code on the MBP.
    6. To check-in any mods to your repo on github, you will need to set your github user and email address. This attaches your details to any commits you do. If you don't do this, git will error when you try to commit.
      1. GitHub protects your identity, by giving you a no-reply email address you can use, if you're uncomfortable using your own. You can find it, by:
        1. use a browser to login to your GitHub account
        2. go to your profile picture in the top right of any GitHub page
        3. choose 'settings'
        4. in the 'settings' page, click on 'emails' in the left hand side-bar
        5. in the 'emails' page, there is a check-box; 'keep my emails private'. You should always keep your emails private, so make sure this is checked.
        6. underneath the option is the no-replay email address. Alice's is 32162302+AliceDigitalLabs@users.noreply.github.com
        7. copy your no-reply email to the clipboard
      2. Back in VS Code, in your terminal window (making commands to your Pi), you can use the following, to give git information which goes with each commit. The information is local to the repository. If you have another repository, you will need to do this for that one too (or alter the global settings)
        1. git config user.name "YOUR GITHUB USERNAME"
        2. git config user.email "YOUR GITHUB NO-REPLY EMAIL ADDRESS"