External Links

Creative Science Centre

 

IDE

The programming environment for ByPic is very flexible as it only relies on a standard serial connection and so any serial terminal will do. This text describes the preferred environment as it has been evolved over the years.

The IDE is contained within BvSerial (BVS) that can be downloaded from here.

When working with ByPic the ideal is to type something into an editor and then have it transferred to the device. Prior to this release of BVS the way to do that was to put the text in an editor, save the file, go to BVS and download the file form there.

With this release pressing F4 will transfer the file form the editor to the ByPic device without saving the file first. i.e the ideal 1 click.

Note: If you already have PSPad installed then this does not have the extras such as scripts and user variables. So it is important that THIS instance of PSPad is run and not the one you already have installed or see FAQ

BvSerial + PSPad

The IDE is in fact two separate programs with some operability between. BvSerial is a terminal program that will talk to the ByPic device and PSPad is a program editor will all the usual bells and whistles. The editor is invoked by typing .edit in the BvSerial terminal program. For installation see the BvSerial page; installation is simply a matter of copying the files to a directory and clicking on bvserial.exe

Any problems running BvSerial are solved by closing BvSerial (BVS) and deleting the .cfg file. This is created again at start up.

Editor Extras

The editor is a an excellent free ware programmers editor that I have used for many years. However it was chosen for ByPic because it has a built in scripting language that can interact with the editor, in other words you can control the editor and the text being edited by a script, VB Script in this case but is also supports Java and Python. The following is not a description of how to use PSPad. It covers only those elements that have been added to enable it to work smoothly with BvSerail (BVS).

Favourites (1)

This contains some useful links to reference the ByPic system. You can also add your own links by right clicking on a selected item. The MX150 Rookie files are BVS script files (not to be confused with VBS) script files that are dealt with further down the page.

Syntax Highlighter (2)

The Hello World program shown in the picture is coloured that way because it has had ByPic syntax highlighting applied. This has been pre-installed so all that is necessary is to pick the icon choose ByPic to apply the highlighting.

Another feature of this highlighting is that with it applied, pressing ALT+F1will bring up the key words page for ByPic. An internet connection is required for this of course.

There is more information about changing the highlighter settings here.

Scripts Menu

Summary

     Clip Board

  • Sends All - This will send the current screen to BVS - no need to save file (F4)
  • Sends Selected only sends the selected text, useful for individual functions (Shift+F4)
  • Sends All Script As Sends All but expects a script file (Shift_Ctrl+R)
  • Open URL in Clip - Copy URL to clip board, this will open it in an edit window

     File

  • Sends File
  • Sends script file

This is the item that really makes a difference. To follow the examples you will need to have a ByPic device connected. The scripts are easily expandable and so there may be more available than is described here, the scripts described here are the initial, important ones.

Scripts>BvSerial>1. Sends All (F4)

This script can be invoked by selecting the menu or pressing F4. The effect is to send all of the text in the current editor window to the ByPic device, via the BVS terminal. To illustrate this type in the hello world function (program) and then press F4

You will see that the function has been transferred to BVS and then on to the ByPic device, this can be verified by typing hello() at BVS to run the function.

This will send all of the functions in the editor screen not just the visible ones. Also before sending it clears out the previous functions by sending the command cold() first.

Scripts>BvSerial>2. Sends Selected (Shift+F4)

Type in or copy and past the following:

// ***********************************************
// Obligatory Hellow World function
// ***********************************************
function hello()
  print "\nHello World"
endf

// ***********************************************
//  Simple Maths functions
// ***********************************************
function add2(a,b)
    return a+b
endf

function times2(a,b)
    return a*b
endf

Now select just the function times2() thus:

Now use the mouse to select 2. Send Selected from the Scripts>BvSerial menus or press Shift+F4. This time just the times2 function has been sent and importantly the existing hello() function is still there.

This can be verified as above.It can also be observed that nothing has yet been saved to file as it is all done through the clipboard.

Scripts>BvSerial>4. Sends File

Copy the following url (CTRL+C):

http://byvac.com/mBlib/flb/Library/rookie/bv500_rookie_part1.bas

It doesn't matter if it is not correct for the ByPic device you have for this purpose as it will just error if it is the wrong file.

Select Sends File and paste (CTRL+V) into the dialog box

Press ok and the file will be sent to BVS. If you are working with lots of files and alternative is to use BVS directly, this can be done by typing .tl (dot T L) into BVS directly and you will get the following dialog.

This has the advantage that it will remember the last file entered, either way both have the same effect.

BvSerial Scrips

Not to be confused with the scripts menu.

A BV script file is a set of simple instructions that are sent to BVS for it to carry out. The purpose is to automate some common tasks. Installing rookie for example takes a few file selections and key strokes. This can be automated to just one button press.

The BVS script can have the following commands:

send,
waitfor,
sendfile,
end, end

The syntax must be checked carefully as there is no syntax checking by BVS, each command is entered on a separate line in the form:

<command><,><'><command contents><'>

Example:

send, 'cold'

Any command using send will be entered just as if it were being done at the keyboard less the single quotes.

The waitfor will hold up the script until certain text is received for the ByPic device, what text to use is done by observation.

The sendfile command is different in that it will invoke the normal send file operation, tload should be used prior to this.

The script must terminate with the two end words separated by a comma.

As a simple example copy the following text into a new editor window:

#script ALWAYS FIRST LINE
# this is an example BVS script
send, 'cold'
waitfor, 'start'
send, 'function x()'
waitfor, '()'
send, 'print "\nHello"
waitfor, 'Hello'
send, 'endf'
waitfor, 'ok'
end,end

Make sure there is a blank line after the end,end

Press SHIFT+CTRL+R (or use the mouse Scripts>BvSerial>3. Send BV Script)

Test by entering x().

The above uses the clipboard to send a script, as an alternative a scrip file could be sent using:

Scripts>BvSerial>5. Send Script File

Depending on the system in use the path names may not match your system. These can be changed by using Settings>User variables... and then selecting the user tab.

There are two paths, one for the editor as it checks to see if the file exists and one for BVS so it can find the file sent to it. As it is set up both can see the file in the ByPic directory.

Internals

There are a few options for building an IDE and one of them was to use a standard editor control within say wxPython and do everything from there. The solution would be neater but building a complete program editor from scratch would be too big a task. Also the program editors that are available do a very good job, this one and Notepad++ is also very good.

The main problem is that serial communication as well as editing is required and BVS does a very good job of that particularly with the history (last commands repeat) and also the . commands (thanks Wordstar) that means the mouse is used less.

So how does F4 move the contents of the editor screen to the ByPci device? This is how.

  1. The contents of the edit screen are sent to the clipboard
  2. PSPad sends a message to BVS that the clipboard has a program
  3. BVS processes it.

In more detail.

1) The reason that PSPad is used is that it has a scripting (VBS, Java ro Python) interface that is able to work with the editor. In other words it can do things like capture the screen to the editor. Notepad++ is a more up to date editor but scripting relies on a plug in and I was unable to get one to work very well.

2) Now the contents of the clipboard have the required information a message needs to be sent to BVS to do something with it. The messaging is via a named pipe. This is similar to a file but isn't, quite frankly its a very poor method of communication but it is the only inter-program communication that VBS supports and then only one way. But it works. BVS is listening on this pipe all of the time and it treats any incoming message as if it were typed on the keyboard, so PSPad fills the clipboard and then sends the .clip command to BVS

3) BVS does all the real work. It will take the contents of the clipboard and sent it to the ByPic device in the correct format. The .clip command can also be used form the keyboard, make sure that it is in the correct format, type .h clip into BVS for more information.

It should be noted that in all of the exchanges only a small amount of information is sent via the named pipe, the bulk of the data being sent via other methods. The communication is only one way and so error messages cannot be reported back. so far this has not proved to be such a limitation.

Other applications could also use the pipe, it is called 'bvserial_pipe'. If you have a program that is able to open a pipe then try it!!

FAQ

1) There is no script menu on my copy of PsPAD?

This is because you are using an existing version of PSPad you have previously installed. The easiest solution is to not use it. Simply run BvSerial first then type .edit in the black terminal window. See also  question 3.

2) Is it possible to use the editor without BvSerial?

Yes: in the install directory, go inside the edit directory and double click on PSPad.exe

3) I already have PSPad installed can I use that instead of the one that comes with BvSerial?

Yes: You will need to copy some files form the BvSerial copy of PSPad to your own installed copy:

Variable.INI
\Script\VBScript\bypic.vbs
\Syntax\ByPic.INI

Then you will need to enable scripts in PSPad

Settings>Program Settings>System integration>Integrated scripting support (WSH)

4) The script menu looks different?

There are updates within the same BVS version so the version may be out of date, simply download again. The uploaded date is in on the download table.