This is a quick guide to getting started using Git, Atom, and PlatformIO, in the context of this module.
The basic pattern for the lab classes, and ultimately the assignment, is:
The exercises for the practical sessions and the base skeleton for the assignment will be distributed via Github. Github is a very good tool for managing and distributing source code.
Lab material will be distributed via public repositories, linked to from the module pages. While you can download a .zip file containing the source, or clone the public repository, a better option is to fork the repository (which requires a Github account).
Look for the fork button near the top right of the page. You will need to be signed into your gitub account
Creating a fork, makes a copy of the repository under your id, you can then make changes to your copy, and log them back onto github servers.
Since the original repositories are public, your initial repository will also be public.
To make a private copy see the Github help page on Duplicating a repository
Making a clone of the repository, makes a local copy of the files that you can work on. Although there are some good GUI based tools, personally I’ve found that the command shell tool the most convenient for this stage.
To clone the repository click on the green “Clone or download” button You will see a drop down box with a url and a copy icon.
You can pset the url into the command line for the git clone
command
$ git clone https://github.com/kf5011/simple-serial.git
If it clones sucessfully you’ll see something like
$ git clone https://github.com/kf5011/simple-serial.git
Cloning into 'simple-serial'...
remote: Counting objects: 17, done.
remote: Total 17 (delta 0), reused 0 (delta 0), pack-reused 17
Unpacking objects: 100% (17/17), done.
$
You can now open the folder that has just been created in Atom through the “Add Project Folder” command.
On my machine since I am already in the command shell I just type
$ atom simple-serial
or something like
$ cd simple-serial $ atom .
Atom and PlatformIO provide a good environment for writing program code.
The code can be edited and saved just as with any editor (it’s just text after all)
The build button on the toolbar, launches the build process. The status and progression of the build is seen in another smaller sub-window.
For the first run of the build, this can take time as the process may have to download and compile libraries and tools used.
Once the code is built, it will need transfering (uploading) to the K64F device. The Upload button launches this process using the USB connection to the device. Usually this automatically finds the correct device. On occasion it doesn’t, I’ve found that closing Atom, unplugging the K64F then, first reconnecting the K64F then starting Atom usually clears this up.
On linux machines sometimes there is an additional error that crops up. The user needs to be a member of the
dialout
group. You can check your group memberships with thegroups
command.if you need to add yourself to the group on the University Linux machines you can use the command.
$ sudo adduser student dialout
While the code is uploading, a green LED by the USB connection flashes.
Wait for this to stop flashing before pressing the reset button.
Once the code is uploaded, you will need to press and release the reset button, and then the code should run…
You need to check if the program is functioning correctly.
While the k64f doesn’t have a screen or keyboard, you can get some communications back to Atom/PlatformIO via the USB cable.
In the program running on the K64F you can use the standard-IO-library and printf
, puts
, and other console output. To see it in Atom, you need to open the Serial Monitor. The Port you need to select in the Dialog box will be labeled with “DAPLink CMSIS-DAP”, the exact port depends on the host machine and the host operating system.
You can also send data to the K64F from the Serial-Monitor, text entered here can be read on the K64F with scanf
, getchar
, etc
Once you have a stable set of changes and want to record this point, you can commit them into the repository.
First you have to stage the files that you want to record,
$ git add src/main.cpp
Then once all the files of interest are staged, you can make the commit,
$ git commit -m "Commit message/summary of changes"
Latest versions of Atom have a github
package to help with the stage, commit, and push operations. It can clone public repositories, but has problems with any that need an id/password.
Once you have finished working, you will want to put the local changes you have made back onto the server, using the push
operation
$ git push