PBASIC on Linux

February 18th, 2008

Programming Parallax’ PBASIC for Basic Stamps 2, 2e, 2p, 2pe, 2px, 2sx on Linux

This Site describes how you can set up a programming environment for PBASIC 2.5 for the Basic Stamp 2 family on Linux using KDE’s builtin Editor Kate. In the result, you’ll get the functionality needed for writing, testing and uploading your code for all Basic Stamp 2 models.

Contents

  1. Installation
  2. Setting Kate up

1. Installation

You will need some scripts installed on your system to be able to use your Basic Stamp 2 programming board on Linux. First, you should download the “BASIC Stamp Tools for Linux” from their sourceforge home page:

http://bstamp.sourceforge.net/download/

Download the source code and the tokenizer library. Compile and install the tools as described in the README file coming with the BASIC Stamp tools.
After that, download the highlighting file for Kate and the two scripts for compiling and writing your code from within kate to your BS 2:

http://www.gaess.ch/downloads/bs2kate.tar.gz

Unpack the files in the archive. Now, copy the file pbasic_parallax.xml to the directory (you will need root access for this) $KDEDIR/share/apps/katepart/syntax. If $KDEDIR is unset look up the folder by using kde-config –prefix.
Copy the two scripts as root to /usr/local/bin (or /usr/bin, if you prefer this folder) and make them executable:
chmod a+x BS-compile.sh
chmod a+x BS-compileload.sh

That’s all for installation, let’s set up Kate!

2. Setting Kate up

Image 1We have already added the highlighting capability for PBasic to Kate. Now we will add the possibiliy to run the scripts you’ve installed to /usr/local/bin from within Kate. For this, the path to the scripts needs to be one of your default application paths (you can set up the default paths in /etc/profile, /usr/bin is one of your default path for sure, /usr/local/bin eventually has to be added manually).
Image 2 Now, start Kate. Open an example file from the Basic Stamp Tools. The PBASIC keywords should be highlighted, if not, try to choose “PBASIC - BS2″ in the Tools:Highlighting:Sources menu. This should work if you have copied the XML-File to the correct directory.

Now choose “Settings:Configure Kate” as you can see on image 1 above. Click on any of teh pictures on this page to see a bigger view. Then go to “External Tools” and choose “New…” (Image 2 on the left). First, we will create the script “BS compile”: In the now open edit window, enter the text as shown in image 3 below this paragraph.
Image 3

You can copy the text to the “Script” field from below:

cd "%directory"; konsole -e BS-compile.sh "%filename"

When you have filled in all fields, choose OK and you’re back in the config window.

Image 4Now we will create the script “BS compile and transfer”: Choose “New…” again and enter the text as shown in Image 4 on the right. Again, you can copy the script from below:

cd "%directory"; konsole -e BS-compileload.sh "%filename"

Choose OK when finished and again OK in the configure window.
Image 5 You are now able to write your Basic Stamp code in Kate, test it with “BS 2 - compile” and compile and write it to your Basic Stamp with “BS2 - compile and transfer” (see image 5 on the left)! If you choose compile, the compiled code is saved in your source file’s folder with the ending .tok added to the full file name of your source file.

Image 6All Debug information will be shown in the Konsole window after transferring your code to the Basic Stamp using “BS2 - Compile and Transfer”, while your BS2 is executing your Code (see image 6).

PBASIC, Basic Stamp: Trademarks of Parallax Inc.(TM)

Leave a Reply

You must be logged in to post a comment.