Main Site Documentation

Storing Variables and Data for later use on Cerberus


I need to store these values for use when program starts.
A //0-255 one byte "site"
B //0-255 one byte "family"
C //a number 4 bytes "factor"
D // a telephone number or site address "IDB"
What is the best lightest method in programming to do this,

I also need to store set of values:
1234, 04/05/2014 12:13:54, AA AB CE FF 12 0F EF 32, 6789, 5678, 4567
Then these need to be uploaded via Cellular to Database
What is the best lightest method to do this? Flat file, or SqlLite?

For both answers please keep in mind that the Cerberus is limited.


@ mPatterson557 - SQLite is not available on the Cerberus. However, the flat file will be the lightest transport. Remember that with SQL, it contains your data, and its relation in the schema including data on tables and entries, which will inflate the size.


Thanks. Should I use XML or is there a different method for storing config details?


XML increases complexity in your code as well as the stored data size. What is your goal, to be simple or to be easy to read ? :slight_smile:


Since I am on a cerb, I need it to be light code wise.


Well then you have two options in my opinion to be easy as well as light to process and store. You could either

A) Statically write your configuration files. Each line would represent a configuration parameter. Just read it in the same order you write it. This method will be easy to mess up if you have a lot of parameters to set values to.



B) You could use simple tokenization. It would go: . This method will be easier to keep track of regardless of how many parameters must be set, but you will need to split the string.




Can you point me in a direction. I think I have and idea how to write this to a file:

path = "Site=1234\r\n Depl=6789"
private static void WriteToFile(string path, string record){
    using (var file = File.Open(path, FileMode.Append)){
        var bytes = Encoding.UTF8.GetBytes(record);
        file.Write(bytes, 0, bytes.Length);

But how do I read that file?


@ mPatterson557 - its way easier to use a StremReader and StreamWriter. They do tje utf8encoding for you and have methods to write strings and read srings or single lines.
I am nut fully sure about the class names. Might be subclasses of them.


This is 4.1 but should be similar in 4.2.
This one is reading a simple line stored in a text file.

            using (StreamReader sr = new StreamReader(@ "\SD\mode.txt"))
                string profiles = sr.ReadToEnd();
                SendData("profiles:" + profiles);


Thanks will work on it. Using Stream reader got some good google responses. :slight_smile:


@ mPatterson557 - but be carefull with ReadLine. The netmf implementation has a bug if a new line character falls on a multipe of the internal read buffer length, which is 512 if I remember right. For shorter files it’s never a problem.