Archive

Archive for September, 2011

String maximum length on Seeeduino Stalker v2

September 21, 2011 Leave a comment

Since I had some problems with String variables into another application I wanted to test which is the maximum possible length of a String variable for a simple application where no other important variables are declared. I had to mention that the ATmega328P microprocessor of the Seeeduino Stalker v2 device has 32 kbytes of Flash memory.

The code of the first test application is as below:

void setup()
{
Serial.begin(9600);
}

void loop()
{
String message = “0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789”
“012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345”;

Serial.println(message);
Serial.println(message.length(), DEC);
}

In this case I was able to create a String variable with maximum 896 characters in length. If I want to store more characters into the variable it just get an empty string.

A second test have been done using the next code, inspired from the Rob Faludi test (Arduino String Memory):

int length = 1719;
char* message;

void setup()
{
Serial.begin(9600);
}

void loop()
{
message = (char*) malloc(length);

if(message == NULL)
{
Serial.print(“memory allocation FAILED at string length: “);
Serial.println(length, DEC);
}
else
{
Serial.print(“memory allocated successfully at string length: “);
Serial.println(length, DEC);

free(message);
}
}

The maximum size of the char array was 1719. After this value the application is not able to allocate memory. It’s easily observable that the second application permit us to store more characters into a single variable (version which I recommend for this reason and because it will be easier to verify if the string was created correctly or not). Also, do not forgot that these are the simplest applications possible and usually we have more variables declared into an Arduino application: the maximum possible length for a char array /string will decrease even more…

Five Rules to Remember in Life

September 7, 2011 Leave a comment

FIVE RULES TO REMEMBER IN LIFE:
1. Money cannot buy happiness but its more comfortable to cry in a Mercedes than on a bicycle…
2. Forgive your enemy but remember the bastards name…
3. Help someone when they are in trouble and they will remember you when they’re in trouble again…
4. Many people are alive only because its illegal to shoot them…
5. Alcohol does not solve any problems, but then again, neither does milk.

Categories: interesting

Using log4net with .Net Window Form Application

September 5, 2011 Leave a comment

If you want to use log4net package into a .Net Windows Application it is a simple trick to be done after adding the library to the References. If it is only added to References a lot of error message will appear at compiling, specifying that the library could not be found. To resolve the problem just change the Target framework of the project from .Net Framework x Client Profile to .Net Framework x (in my case x was 4) ;), and this should solve all the errors.

Net Framework x Client Profile