Sun Microsystems V2.0 manual Overriding the Ieee address, Accessing flash memory

Page 27

-there is a possibility that another isolate has written a new value for the property since the current isolate started

-your application has overwritten the user-defined property’s value in memory but not in flash

(by executing System.setProperty).

All user-defined properties can be accessed using:

Spot.getInstance().getPersistentProperties();

Accessing properties from the host

To view all user-defined System properties stored in a SPOT do:

ant system-properties

To set a property do:

ant set-system-property –Dkey=<key>-Dvalue=<value>

To delete a property do:

ant delete-system-property –Dkey=<key>

Overriding the IEEE address

When it starts up the SPOT loads the system properties from flash memory as described above and then checks whether the property IEEE_ADDRESS has been set. If not, it sets this property to the string representation of the device's serial number. The IEEE 802.15.4 MAC layer uses this property to determine the address that should be adopted by this device. If you wish to set an address different from the serial number then use the facilities described above to set the IEEE_ADDRESS property; this entry will take precedence.

Accessing flash memory

Two mechanisms are provided for reading and writing flash memory.

Using IFlashMemoryDevice

Read and write access to the Sun SPOT's flash memory is via an object conforming to the IFlashMemoryDevice interface. To obtain that object:

IFlashMemoryDevice mem = Spot.getInstance().getFlashMemoryDevice();

The IFlashMemoryDevice interface provides low-level access to the whole of the flash memory. A safer way of accessing that part of the flash memory available to applications is to read and write using streams:

IFlashMemoryDevice mem = Spot.getInstance().getFlashMemoryDevice(); int startSector = mem.getFirstAvailableSector();

DataOutputStream dos = new DataOutputStream(mem.getOutputStream(startSector, 2)); dos.writeUTF("hello there");

dos.flush();

DataInputStream dis = new DataInputStream(mem.getInputStream(startSector, 2)); String s = dis.readUTF();

The call to open a stream takes two parameters: the first specifies the sector number of the first sector to be read or written. The second parameter specifies the number of contiguous sectors to be allocated to this stream. Opening an output stream erases the data in all the allocated sectors. In the

27

Image 27
Contents Page Page Contents Http protocol support Introduction Deploying and running a sample application Building and deploying Sun Spot applicationsBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Incorporating utility classes into your application Deploying a pre-existing jarManifest and resources Excluding files from the compilationOther user properties Using the Basestation Built-in propertiesOverview Set up Base Station configuration Remote operationIntroduction Connect a Sun Spot base station Background Using short names for SPOTsManaging keys and sharing Sun SPOTs Take suitable actions during over-the-air downloadsSharing Sun SPOTs Changing the owner of a Sun SpotLimitations What is protected?Deploying and running a host application Generating a new key-pairMesh routing Configuring network featuresYour own host application Incorporating pre-existing jars into your host applicationHardware configurations and USB power Trace routeLogging Page Overview of an application ThreadsThread priorities Sun Spot device libraries Sun Spot device libraryDevice Interface Persistent properties Overriding the Ieee address Accessing flash memoryUsart Radio communication library Program Radiogram protocol Server end Client endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Conserving power using deep sleep mode Monitoring radio activityShallow Sleep Deep Sleep Activating deep sleep modeDevice Condition to permit deep sleep USB inhibits deep sleepPreconditions for deep sleeping Deep sleep behaviour of the standard driversWriting a device driver Http protocol support Configuring the http protocolSocket Proxy GUI mode Configuring projects in an IDEClasspath configuration Javadoc/source configurationDebugging Ant selectapplication Configuring Eclipse as a debug client Configuring NetBeans as a debug clientAdvanced topics Using library suitesWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Reference Persistent system propertiesProperty name Meaning Start address Space Use Contents of the arm directoryContents of the lib directory Memory usageContents of the bin directory preverify.exe Contents of the tests directory Contents of the upgrade directory