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

Page 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

Image 50
Contents Page Page Contents Http protocol support Introduction Building and deploying Sun Spot applications Deploying and running a sample applicationBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Deploying a pre-existing jar Incorporating utility classes into your applicationOther user properties Manifest and resourcesExcluding files from the compilation Overview Using the BasestationBuilt-in properties Set up Introduction Base Station configurationRemote operation Connect a Sun Spot base station Take suitable actions during over-the-air downloads Using short names for SPOTsManaging keys and sharing Sun SPOTs BackgroundChanging the owner of a Sun Spot Sharing Sun SPOTsGenerating a new key-pair What is protected?Deploying and running a host application LimitationsIncorporating pre-existing jars into your host application Configuring network featuresYour own host application Mesh routingLogging Hardware configurations and USB powerTrace route Page Thread priorities Overview of an applicationThreads Device Interface Sun Spot device librariesSun Spot device library Persistent properties Accessing flash memory Overriding the Ieee addressUsart Radio communication library Program Radiogram protocol Client end Server endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Shallow Sleep Conserving power using deep sleep modeMonitoring radio activity Activating deep sleep mode Deep SleepDeep sleep behaviour of the standard drivers USB inhibits deep sleepPreconditions for deep sleeping Device Condition to permit deep sleepWriting a device driver Configuring the http protocol Http protocol supportConfiguring projects in an IDE Socket Proxy GUI modeDebugging Classpath configurationJavadoc/source configuration Ant selectapplication Configuring NetBeans as a debug client Configuring Eclipse as a debug clientUsing library suites Advanced topicsWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Property name Meaning ReferencePersistent system properties Memory usage Contents of the arm directoryContents of the lib directory Start address Space UseContents of the bin directory preverify.exe Contents of the upgrade directory Contents of the tests directory