Serial programming Tcl library
[LPC2xxx related tools running on the host]

An other programming library to be used from Tcl scripts. More...

An other programming library to be used from Tcl scripts.

Based on the Serial programming C library an other shared library is created, which you can load into a Tcl interpreter and have access to the functions provided by the C library from your Tcl or Tk script. That allows you to put together a programmer (even a GUI one) probably faster than if you had to write it in C. In fact the programming tool lpc-prg, a serial programmer (needs Tcl/Tk) supplied with the package is actually a Tk application using this library. Note that the library is created only if you have Tcl 8.4 or newer on your system.

To use the library, you have to have the bin directory under the installation directory in your library path, for example by adding the line:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/armlib/bin

to your shell init script; alternatively you can copy the library files from that directory to your system library directory or you can add the location to /etc/ld.so.conf.

Then you can load the library by putting the following line at the beginning of your Tcl or Tk script:

load liblpctcl.so

The library defines a single Tcl command lpcprg which represents the entry point for all library procedures. Most procedures return nothing. For the ones that do, the return value is described in the individual procedure description.

In case of any error all of the procedures return with an error code of 1 (i.e. error). Note that this is not the return value but a success code. See the man page for return(n) for details. Normally the Tcl interpreter will exit if it receives an error, so if you want graceful error handling you have to invoke the procedures through the catch command. When a procedure fails, it sets ist return value to the error message, which you can obtain through catch. Furthermore, if the error occured in the underlying C library, you can obtain an other error message by calling the lpclib errormsg procedure (which never fails). That error message might contain a more detailed description of the reason for the error (although not necessarily).

The following procedures are defined:

Logging commands

Serial port related commands

Target commands

These commands, with the exception of connect itself can only be issued when the target is connected. The serial port must be open, the baud rate(s) must be set up and the signal control must be assigned.

FLASH buffer commands

When a chip is connected, it gets associated with a buffer of the same size as its FLASH. That buffer is used for various file and FLASH operations. With each byte in the buffer a state is associated. This qualifies the data in the buffer. The following states are recognised:

Using the status information the various functions can often avoid unnecessary FLASH operations. The following operations are defined: