Good SPOT Programming Practice

Since I've just been bitten by this one, I thought I would post a quick note on what I consider a good practice in SPOT Programming: Adding a bootloader listener thread. It's extremely easy to do, and (trust me on this one) it can save you a lot of time. The line you want is:


   new BootloaderListener().start(); // monitor the USB (if connected) and recognize commands from host

Add that as the first line in your MIDlet's StartApp() method. Now, why would you want/need to do such a thing? And how can it save your bacon? Well, (as I have just experienced) some things -- in my case I2C -- can get into a tight loop. Such a tight loop that it can be difficult to reset the SPOT with a button press. I spent quite a bit of time trying to time the plugging-in of the SPOT with an upgrade command to get past this tight loop I was in.

The bootloader listener thread running will 'hear' the bootloader command request when it is sent (at least after a small delay) and respond, automatically resetting the SPOT and dropping into the bootloader so that you can upgrade your SPOT, re-depoly an application, etc. Or just fix whatever got you into that tight loop in the first place. It's a life-saver when you need it, and takes very little overhead when you don't so it is definitely worth it.


[ Food for thought is no substitute for the real thing.


-- Walt Kelly, "Putluck Pogo" ]

Comments:

Great post David, very nice, that help me to debug a little problem into my SunSpot app :)

Posted by Luca Morettoni on January 09, 2009 at 12:53 AM EST #

Post a Comment:
Comments are closed for this entry.
About

user9157252

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today