Storing settings in TC65 module - Best practice?

279 views
Skip to first unread message

Thomas Hermansson

unread,
Dec 6, 2009, 3:16:40 PM12/6/09
to Cinterion Java enabled chips support
Hi!

I need to create and store a few settings to a file or rms database
(or any other way?).

For example if I´d like to store the following four attributes
String a;
String b;
int c;
int d;

what would the best (=easiest with less code) way for this be?

In the normal Java world I would put all these four parameters in a
Settings class, and then create a ObjectSerializer and simply write
this to a file, but ObjectSerializer does not exists in J2ME or
Siemens classes.

Does anyone have any good ideas for a lazy guy?

br
Thomas Hermansson

ejw

unread,
Dec 7, 2009, 9:18:19 AM12/7/09
to Cinterion Java enabled chips support
Hi,

I assume you mean permanent storage so use record stores. There are
some useful articles on creating and using them such as:-

http://developers.sun.com/mobility/midp/articles/databaserms/
http://developers.sun.com/mobility/midp/articles/databasemap/
http://developers.sun.com/mobility/midp/articles/databasemapextend/
http://developers.sun.com/mobility/midp/articles/databasefilter/index.html
http://developers.sun.com/mobility/midp/articles/databaserecordstore/index.html

As a record store only has two 'columns' the index and the byte store,
you can store anything you want in each record, but you do need to
ensure you use the correct methods of 'adding' and 'reading' the data
you store. I found that just getting the code wasn't much help and I
needed to understand what was happening internally.

EJ




On 6 Dec, 20:16, Thomas Hermansson <thomas.hermans...@gmail.com>
wrote:

Florent Clairambault

unread,
Dec 12, 2009, 12:34:07 PM12/12/09
to java...@googlegroups.com
Hi,

   This is my late answer (sorry) : http://florent.clairambault.fr/tc65-settings-management
   
   This won't be very useful for people willing to store raw (bytes arrays) settings but I guess it will solve most of the settings management problems you could have. It shouldn't be very difficult to convert this little class to one being able to manage raw settings.

   I'm really glad there's always someone to answer the questions. I'm sure it will help a lot of people starting on the TC65.

Best regards,
--
Florent Clairambault


--

You received this message because you are subscribed to the Google Groups "Cinterion Java enabled chips support" group.
To post to this group, send email to java...@googlegroups.com.
To unsubscribe from this group, send email to javacint+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javacint?hl=en.



ejw

unread,
Dec 19, 2009, 5:26:08 AM12/19/09
to Cinterion Java enabled chips support
Hi Florent,

I thought that you could only use files as persistant storage if there
was an add-on memory card. I may have misunderstood this as I think it
was within a j2me book and not specific to the cinterion module.

It's nice to be in a business where you can still learn something new
every day!

This might be useful to us as we have found that the RMS can corrupt
and, if so, there is no exception to handle the error, the program
just stops dead. We have reported this to Cinterion with sample code
and corrupted database records and they are looking at the matter.

Am I right in thinking that I could create a text file on a PC and
upload to the module via the 'My Computer' interface and that the
module would then be able to read the settings?

Best wishes

ejw

On Dec 12, 5:34 pm, Florent Clairambault <supe...@gmail.com> wrote:
> Hi,
>
>    This is my late answer (sorry) :http://florent.clairambault.fr/tc65-settings-management
>
>    This won't be very useful for people willing to store raw (bytes arrays)
> settings but I guess it will solve most of the settings management problems
> you could have. It shouldn't be very difficult to convert this little class
> to one being able to manage raw settings.
>
>    I'm really glad there's always someone to answer the questions. I'm sure
> it will help a lot of people starting on the TC65.
>
> Best regards,
> --
> Florent Clairambault
>
>
>
> On Mon, Dec 7, 2009 at 15:18, ejw <supp...@virtualict.co.uk> wrote:
> > Hi,
>
> > I assume you mean permanent storage so use record stores. There are
> > some useful articles on creating and using them such as:-
>
> >http://developers.sun.com/mobility/midp/articles/databaserms/
> >http://developers.sun.com/mobility/midp/articles/databasemap/
> >http://developers.sun.com/mobility/midp/articles/databasemapextend/

> >http://developers.sun.com/mobility/midp/articles/databasefilter/index...
>
> >http://developers.sun.com/mobility/midp/articles/databaserecordstore/...

> > javacint+u...@googlegroups.com<javacint%2Bunsubscribe@googlegroups.c­om>


> > .
> > For more options, visit this group at

> >http://groups.google.com/group/javacint?hl=en.- Hide quoted text -
>
> - Show quoted text -

Florent Clairambault

unread,
Dec 19, 2009, 6:21:37 AM12/19/09
to java...@googlegroups.com
Hi ejw,

    Yes, you can store anyfile you wish on the chip. But it might not be a very good idea to do it very frequently as, if I remember correctly the TC65 flash is limited to 100 000 R/W operations. I never had any problem with this class, but it can be improved to store the data in a transactional way (first write a temporary file and then rename it to the settings file).

    Yes, people can download the file, edit it with notepad and put it back into the chip (or just create it and put it on the chip). This wasn't the goal but some people like it that way. 

Best regards,
--
Florent Clairambault
To unsubscribe from this group, send email to javacint+u...@googlegroups.com.

Ricardo Guilherme Schmidt

unread,
Dec 19, 2009, 9:18:19 AM12/19/09
to java...@googlegroups.com
Hello Florent and ejw,

Where you get the information of the tc65 flash limit? You mean that it
will just stop works when reaches this limit?

I think that the best practice to to that is when the program is
initialized, it istancies a class that read and store all the settings
in memory. I've adpted a INIClass from J2SE that uses Hashtables for
storing sections (an inner class) that uses hashtable too to store
proprietys (and inner inner class).
It first reads all the data in the file, and creates sections and
properties that will be acessed in memory.. Any read or change of the
settings are not commited, and you need to force it to save the file, so
it will write the file.

> +unsub...@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/javacint?hl=en.
>
>
>
>
>

> --
>
> You received this message because you are subscribed to the Google
> Groups "Cinterion Java enabled chips support" group.
> To post to this group, send email to java...@googlegroups.com.
> To unsubscribe from this group, send email to javacint

> +unsub...@googlegroups.com.

Florent Clairambault

unread,
Dec 19, 2009, 11:23:04 AM12/19/09
to java...@googlegroups.com
Hi Ricardo, ejw and everyone else,

I saw it on a TC65 reseller website. I don't know how the chip will behave, it might isolate the portion of dead memory (that what any modern system does) or it might just fail. I did a gps position tracking program that used to save a lot of positions on the chip as soon as there was a connection problem (no connection or no acknowledge received), and I never had any problems with it.

If you look at the class it also doesn't save the file unless you call the "Save" method (I know it should be lower case but I prefer the C# programming standards). And it reads everything in the beginning, except if you do a "freeInstance" call (added just in case you have a huge memory constraint).

Florent

PS : First messages on the mailing list are now moderated to avoid dispatching too much spam (most of you use gmail, and it filters them but that still add some garbage in the javacint group messages page).

On Sat, Dec 19, 2009 at 15:18, Ricardo Guilherme Schmidt <3es...@gmail.com> wrote:
Hello Florent and ejw,

Where you get the information of the tc65 flash limit? You mean that it
will just stop works when reaches this limit?

tI think that the best practice to to that is when the program is
To unsubscribe from this group, send email to javacint+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages