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