This post is not describing how to run Visual Studio Code on the Pi. This post shows you how to create a network share on your Pi where your scripts reside so that you can edit them from your computer (this post is aimed at Mac users, go here to setup visual studio code for Windows).
The first thing you want to do, is ensure that you have Visual Studio Code installed on your Mac. You can install plugins you require specifically, but I recommend this Python plugin as Python is usually the goto language with Pi development.
First, update the packages that are installed on the Pi by entering the following in the terminal:
> sudo apt-get update
Creating the Network Share
To allow our Mac to see a network share on the Pi, we must first install Netatalk., To do this, we simply use the Raspbian package manager “apt-get”. Here is the command to install Netatalk
> sudo apt-get install netatalk
apt-get will start installing Netatalk upon pressing enter.
Note: You may need to press “Y” when it asks you to confirm the install.
Surprisingly, that is all there is to creating a network share on the Pi (for Mac). Some users may want to reboot their Pi at this point, although it isn’t strictly necessary. If you would like to check that you can access the Pis files, open up Finder and go to your network locations.
You should see a computer with the name “raspberrypi” (or whatever you have called your Pi, if you had changed it’s name using raspi-config).
Upon double clicking the raspberrypi computer, you will need to click “connect as” in the top right corner of the Finder window.
This will bring up a prompt for a username and password. This is basically the user you wish to log in as. Assuming default settings, this is usually “pi” and “raspberry” as the username and password respectively.
Upon logging in, you will see the home directory of the user you are logged in as.
Using Visual Studio Code
Now that we have Visual Studio Code installed on our Mac, and have access to the Pis home directory (where we save our scripts) we can start to edit our code!
Simply drag a file from the Raspberry Pi network share into Visual Studio Code. Any changes you make and save will be updated on the Pi itself.
Alternatively, you can open a folder from within Visual Studio code by clicking “file -> open folder” and navigating to the folder on the Pi that you want to open.
If you intend on using a headless OS (such as Raspbian Lite) for your Pi, setting up a Fixed IP address is a must. With this setup, you can SSH into your Pi with nothing more than an Ethernet cable and a power supply connected to your Raspberry Pi.
Setting Up a Fixed IP
Before you can go about setting up a fixed IP address, you will first need to either connect to your Pi via SSH or connect a monitor, mouse and keyboard so that you can edit the configuration files.
Once you are ready at the terminal on your pi, open up the dhcpcd.conf file with nano by entering
> sudo nano /etc/dhcpcd.conf
Some posts around the internet talk about using an “interfaces file” for setting up a fixed IP. This used to be how Raspbian managed assignment of IP addresses, but has now moved over in favour of the dhcp client.
With the config file open in nano, scroll down to the bottom using your keyboards arrow keys to the end of the file. Enter the following:
This looks like there is quite a lot involved, but broken down it is fairly straight forward.
Specifies which interface we want to assign the fixed ip address to. In this example we are assigning it to the ethernet port. If you have multiple ethernet wires plugged in (via a usb with ethernet adapter, for example) there will be more interface addresses such as eth1 etc. The same applies to WiFi, who’s interface range starts at wlan0.
The most important line of all! 192.168.1.5 is the IP address you want to be assigned to your Pi.
What is the “/24” for? You may be wondering… This number represents the subnet mask, more specifically, how many bits of the mask should be 1 and the remainder being 0. As you may know, a common subnet mask is 255.255.255.0 – as the subnet mask is a 32bit integer, this would be represented as /24 (i.e. the first 24 bits are 1’s and the remainder (8 bits) are 0).
This one is fairly straight-forward. This is basically the IP address of the router you are connected to. Of course, change the IP address here to match your routers settings.
The final piece of the puzzle, and quite a simple one, is the dns settings. This is usually the same as your routers address, so change this accordingly.
Finally, to save your settings:
ctrl + X to quit nano
Y to confirm to save
For the new settings to be applied, you will need to restart your Pi. Simply type the following:
This post is not about creating a C++ Maya plugin, it is aimed at setting up debugging in Visual Studio for the plugin.
note: If you see the word “MayaMorph” in this post, it is because the project I am building is morphing between two geometric meshes. If you are interested there is more info on my website https://nickcullen.net.
We start off in Visual Studio. Open up your Maya plugin solution.
1. Right click your plugins project properties
2. Under Configuration Properties -> Debugging set the "Debugger to launch" option to "Local Windows Debugger".
3. In the "Remote Command" entry, you want to put the full path (including extension) to the maya executable. For example my Maya is located at "C:\Program Files\Autodesk\Maya2016\bin\maya.exe" (Yours may be different!).
A handy trick to get the the full path to a file on your windows machine is to hold shift + right click on the executable, then click “Copy as Path“. You can simply paste the value into “Remote Command” removing any quotation marks.
4. Set the "Attach" value to "Yes". This option attempts to attach the debugger to an already running Maya instance. Without this, it will launch Maya every time you launch the debugger.
Your values should look similar to these:
Your debugger is all set up.
If you haven’t done so yet, set some breakpoints and open Maya. Don’t run the debugger until Maya is fully open.
Debugging Maya Plugin
Once Maya is fully open, plugin compiled and loaded you can attach the debugger.
1. Click the "Local Windows Debugger" option at the top or simply hit F5
Once you execute your plugin from within Maya, you should hit one of your break points like so.
One of the most fundamental methods with Raspberry Pi development is the ability to connect your Raspberry Pi via SSH to manipulate files and execute scripts which run on the Pi.
The following tutorial will apply for all platforms, however Windows does not have SSH built in by default. To allow SSH access to the Pi via windows, it is recommended to download a program called PuTTY.
With PuTTY, you can simply enter (and save) the IP Address of the pi, username and password (will get onto this in a moment) and click open.
For the purpose of this tutorial, I will use the ‘terminal’ way for connecting over SSH. Once you connect over SSH via PuTTY on Windows, you will be at the same point post-connection as you are connecting to the Pi via a Mac/Linux computer.
To begin, you first need to enable SSH on the Pi itself. Unfortunately, this does require you to have a keyboard (+ mouse if you are not running a headless version of Raspbian) plugged into the Pi for the time being.
Important Note: If this is the first time you have booted up the Pi, before you restart the Pi (step 5), you must enable the device to auto log-on. Without this option enabled, your Pi will wait in a state where it is prompting you to enter the username and password for the user you want to log into. While the Pi is in this state, you will not be able to SSH into the Pi! See “Enable Boot to desktop” in the raspi-config manual
Connecting To the Raspberry Pi Via SSH
Now that SSH is enabled on our Pi, we can remove our keyboard and mouse which was previously connected to it and ensure the Pi is plugged into the same network as our main computer.
Unless you have changed them, the default settings for the Pi are as follows:
Opening the Connection [Mac & Linux]
Open up the terminal and enter the following command:
> ssh email@example.com
A prompt will appear to enter the password of the user you wish to log in as. In this example, the user “Pi” is chosen.
Of course, don’t forget to change the IP address to match the address of your Pi.
Opening the Connection [Windows]
Simply open PuTTY, enter the IP address of the Pi, along with the username and password of the user you want to log in as (see default settings if you have not made any changes to the Pis user account) and click open.
Getting the IP Address of the Pi
In a future post I will describe how to set up a fixed IP address for your Pi. For now, your Pi will need to be plugged into a monitor. When you boot up your Pi, you should be able to see the following.
For those interested in understanding how SSH works and additional security measures to take, read Understanding SSH Keys