Sniff is a "Scratch-like" programming language that's designed to help Scratchers move gently from Scratch to more conventional languages. They can start writing programs, without having to learn a new language because Sniff is based on Scratch. They learn a little more about variables, compiling, syntax errors (!), and they can have fun controlling real hardware while they're doing it.

Sunday, 3 April 2016

Installing on Windows

Installing Sniff on Windows is a bit more tricky than on other platforms. This is mainly because both Mac and Linux provide a standard, more or less built in set of developer tools. While these might not be installed by default, they're pre-configured so they pretty much install automatically. On Windows we need to install a few things manually, and installing things on Windows is always a pain. There's also been some problems with these tools changing (and different version of windows), so here's an up to-date install guide:

Step One: Install MinGW

MinGW is MINimal Gcc for Windows. It provides the heavy lifting backend, to turn programs into executables. Go to their website, and click the button on the top right that say "download installer". Once its downloaded, run it and you'll get the option to configure your system. If you want you can install everything, but you simply need to select "base", and "msys". Click the Install button, and off it goes.

Once its done, you'll find you've got a folder C:\mingw (it's possible to install elsewhere, but lets not!). Inside that is C:\mingw\msys\msys.bat. This is the program we want, so drag a shortcut to the desktop/startmenu or wherever you want it. If you double click in it you'll get a bash shell - type "ls", and/or "pwd" to check its working (it's a basic Unix/Bash shell so you can pretend you're using a proper computer).

There's one more file to edit before you've got a working MinGW. Open the folder C:\mingw\msys\1.0\etc. In there you'll find a file called "ftab.sample". Copy this (or rename it) to fstab - no extension, in the same folder.

Now if you start another shell (running the msys shortcut) you'll find that the command "gcc" will say something like "no input files". That means its installed and ready to go.

Step Two: Install Sniff

Download the latest SniffW release. There's actually no difference between the Unix and Windows packages, but we just delete the un-needed bits from each version to keep the file size small. You can place the unzipped folder anywhere you like (please avoid path names with spaces in!), but its easiest to just put it in the users msys folder. To do that open an msys window and type "start .". Then drag the Sniff folder into the folder that has just opened.

Step Three: Lets Go!

In the Sniff folder there's  file called "clickMe.bat". If you do click it then you should get a working version of SniffPad, which you can use to get started writing Sniff programs. You can also create a shortcut to clickMe.bat and put it on your desktop (and rename it to something more memorable), to make things really easy.

When you run Sniffpad like this it runs in the Documents/SniffProjects folder, so you can copy any examples files from the release to that folder to run them.

At some point you'll want to do more than you can just using Sniffpad, so start an msys shell, then cd to the Sniff folder - it you've placed it in the Sniff folder as above, then "cd Sniff26WRelease" or whatever version you're using. Then type "source setup" or ". ./setup" (they both do the same thing) to initialise everything.

Now in the shell, you can run "sniffpad".  cd into the examples folders and off you go. For a more advanced user you can use any text editor you like, and compile programs from the shell, by typing "sniff myprog.sniff".

Step Four: Install Arduino

This step is optional - if you don't want arduino, then just don't install it. You can also install it any time afterwards. Download the installer from the arduino site, and do a regular/standard install. The next time you run the sniff setup, it will say that its found an arduino installation and now in sniffpad you can click the arduino button to compile and download to an Uno, or use uno-sniff to compile from the command line.

You should be able to use more or less any version of the Arduino IDE, but recent versions have a rather nasty bug where the compiler (actually the linker) crashes! This is a problem that the Arduino Forums have been struggling with for a while, as its difficult to reproduce - it only happens for certain programs on certain hardware. However it turns out that Sniff blows it up nearly every time! If you get an error message about "ld.exe", then  try downloading the Arduino 1.0 IDE, and using that. It's a very old version, but seems (at least for me) seems to work OK.

COM Port Discovery
When you initialise Sniff (either by clicking on clickme.bat, or "source setup' from the command line) it detects the first com port and tries to use that whenever it tries to talk to an Arduino, Flotilla, Picoboard, or Lego Control Centre. If you find that any of these aren't working, then try removing other serial devices, and make sure that Sniff is talking to the right piece of hardware.

And that's it... It's a bit more fiddly that Mac/Linux, but not really so hard.

No comments:

Post a Comment