Sun Microsystems V2.0 manual SpotSerialPortException other exception in serial port comms

Models: V2.0

1 54
Download 54 pages 11.11 Kb
Page 50
Image 50

Wire objects together

At system startup, a development tool should create and wire together various objects. This code shows the general style:

String keyStorePath = "/foo/bar"; // path to user’s key store SpotManager spotManager = new SpotManager(keyStorePath); MyUIClass ui = new MyUIClass();

SerialPortTarget spt = new SerialPortTarget(); spt.initialise("COM3", ui); //port to which Spot is attached spotManager.setTarget(spt);

SpotClientCommands commandRepository = new SpotClientCommands(ui, spotManager, appPath, libFile, sysBinPath);

The SpotClientCommands object provides a repository containing one instance of SpotClientCommand objects for each of the commands available to the UI: the UI can retrieve and execute these command objects. Alternatively, the following is an optional further step.

SpotClient spotClient = new SpotClient(ui, spotManager, appPath, libFile, sysBinPath);

The SpotClient class provides the same functions as the individual SpotClientCommands but presented as methods on a single class. This alternative API is more compatible with previous releases.

Execute commands

The following code samples show how to flash an application to the Spot using the two alternative APIs:

commandRepository.getFlashAppCommand().execute("/myapp/suite/image.suite");

spotClient.flashApp("/myapp/suite/image.suite");

The execution of commands may throw various kinds of unchecked exception. Tool developers may choose to catch any or all of these:

SpotClientException: abstract superclass for these unchecked exceptions:

oSpotClientArgumentException: failure due to invalid parameters in API call

oSpotClientFailureException: other non-fatal failure during a SpotClient API call. This has these subclasses:

￿ObsoleteVersionException: the target is running the wrong version of the bootloader or config page for the spot client executing on the host. Assuming that the host is running the latest spot client, then the solution is to flash the target with the latest bootloader before continuing

￿SpotSerialPortInUseException

￿SpotSerialPortNotFoundException

￿SpotSerialPortException: other exception in serial port comms

oSpotClientFatalFailureException: fatal failure in execution of an SpotClient API

call. Callers should normally exit, or at least not reuse the instances of SpotClient,

SpotClientCommands, SpotManager and Itarget.

50

Page 50
Image 50
Sun Microsystems V2.0 manual SpotSerialPortException other exception in serial port comms