Hello all,
I am trying to build a system wich:
-manages a motor with a native code PID : OK
-displays bitmaps on fez touch screen from SD card: OK
-Manage a small webserver : OK
Every part is working in standalone mode, and even when I put bo combination of both features, but when I put all together, I see at the startup application a ‘System.OutOfMemoryException’ in mscorlib.dll
Am I trying to do too much with the panda or I missed something?
Did someone already made something similar?
Any workaround/ideas?
using System;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Native; //code natif RLP
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.NetworkInformation;
using GHIElectronics.NETMF.IO; //pour carte SD
using GHIElectronics.NETMF.System; //pour carte SD
namespace OutOfMem00
{
public class Program
{
public static void Main()
{
///////////////////////////////////////////////////////////////////////
//RLP
/*RLP.Procedure TestMethod_c;
RLP.Procedure debugProcedure_c;
RLP.Procedure SetConsigne_c;*/
RLP.Enable();
RLP.Unlock("C.............................."});
//the line below causes : 'System.OutOfMemoryException' in mscorlib.dll
byte[] elf_file = Resources.GetBytes(Resources.BinaryResources.RLP_PID);
if (elf_file == null)
{
Debug.Print("Echec de chargement du fichier binaire");
return;
}
RLP.LoadELF(elf_file);
RLP.InitializeBSSRegion(elf_file);
///////////////////////////////////////////////////////////////////////
//FEZ TOUCH SCREEN
// Montage microSD
PersistentStorage sdPS;
sdPS = new PersistentStorage("SD");
sdPS.MountFileSystem();
//Sequence d'init de l'ecran FEZ TOUCH
// This is for FEZ Panda II
FEZ_Components.FEZTouch.LCDConfiguration lcdConfig = new FEZ_Components.FEZTouch.LCDConfiguration(
FEZ_Pin.Digital.Di28,
FEZ_Pin.Digital.Di20,
FEZ_Pin.Digital.Di22,
FEZ_Pin.Digital.Di23,
new FEZ_Pin.Digital[8] { FEZ_Pin.Digital.Di51, FEZ_Pin.Digital.Di50, FEZ_Pin.Digital.Di49, FEZ_Pin.Digital.Di48, FEZ_Pin.Digital.Di47, FEZ_Pin.Digital.Di46, FEZ_Pin.Digital.Di45, FEZ_Pin.Digital.Di44 },
FEZ_Pin.Digital.Di24,
FEZ_Pin.Digital.Di26
);
FEZ_Components.FEZTouch lcdFEZ = new FEZ_Components.FEZTouch(lcdConfig);
string path = @ "\SD\picts\menuStart320x240.bin";
lcdFEZ.printLCDPictFromSD(path, 0, 0);
///////////////////////////////////////////////////////////////////////
//ETH SERVER
byte[] ip = { 172, 16, 120, 42 };
byte[] subnet = { 255, 255, 224, 0 };
byte[] gateway = { 172, 16, 120, 1 };
byte[] mac = { 0x00, 0x88, 0x98, 0x90, 0xD4, 0xE0 };
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
(Cpu.Pin)FEZ_Pin.Digital.Di7, true);
NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
NetworkInterface.EnableStaticDns(gateway);
// start server
HttpListener listener = new HttpListener("http", 80);
listener.Start();
while (true)
{
HttpListenerResponse response = null;
HttpListenerContext context = null;
try
{
context = listener.GetContext();
response = context.Response;
// The button is pressed
if (context.Request.HttpMethod == "POST")
{
;
}
// Sends response
response.StatusCode = (int)HttpStatusCode.OK;
byte[] HTML = Encoding.UTF8.GetBytes(
"<html><body>" +
"<h1>Hosted on FEZ Panda II</h1>" +
"<p>Let's scare some people!</p>" +
"<form action=\"\" method=\"post\">" +
"<input type=\"submit\" value=\"Activate!\">" +
"</form>" +
"</body></html>");
response.ContentType = "text/html";
response.OutputStream.Write(HTML, 0, HTML.Length);
response.Close();
}
catch
{
if (context != null)
{
context.Close();
}
}
}
}//main
}//program
}//namespace
Edit : I guess that the issue is related to RAM usage, but could I have also reached the max amount of assemblies that I add in the project? (82.6Kbytes if I sum the .pe files in /le directory)?