Main Site Documentation

Storing Variables and Data for later use on Cerberus


#1

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.


#2

@ 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.


#3

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


#4

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:


#5

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


#6

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.

Example:

02/11/14
1455
11:52:25

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.

Example:

Date=02/11/14
SecurityCode=1455
Time=11:52:25

#7

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);
        file.Close();
        }
    }

But how do I read that file?


#8

@ 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.


#9

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);
            }


#10

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


#11

@ 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.