One of my usual goofy questions. But I don’t mind asking because I do not understand why Concat( ) gives the ASSERT
Using a Fez.Spider
Using >NET Micro Framework 4.1
The main reason I am asking is because I had to spend over an hour trying to recover my Spider. Upon power up or a button reset my simple code would run and immediately go into ASSERT. I finally got the right moment to do an Erase (Using MFDeploy) and saved my Spider from Brick heaven or would that be Brick hell?
Is there a way I can do/use the ’ string result = String.Concat(parts); ’ without causing the ASSERT?
In case you are wondering: All I was trying to do is make two strings of all the characters in the tiny fonts (with the control characters) and display as a string.
It is only an experiment as I wanted to display all characters received (On the T-35 display) from a bluetooth device for troubleshooting.
Partial code attached that gives the error
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
void ProgramStarted()
{
Debug.Print("Program Started");
beginhere();
}
void beginhere()
{
//Do not allow code to run until button is pressed
//This is because of *****ASSERT***** when using string result = String.Concat(parts);
//It was almost impossible to recover my Spider. The code would run upon a reset and
//MFDeploy gave exception when trying to Erase. I spent over an hour trying to catch
//the correct moment so MFDeploy could erase the app. I added the button so code will
//not run after the exception and I can erase the app. for testing
while(!button.IsPressed)
{
Debug.Print("CANNOT RUN - SAFETY CHECK");
if (button.IsPressed)
{
break; //Allow code to run
}
}
Debug.Print("RUNNING CODE - SAFETY CHECK");
Bitmap TBitmap;
TBitmap = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
Font myFont = Resources.GetFont(Resources.FontResources.NinaB);
Text text = new Text();
Text textS = new Text();
// Set Fonts
text.Font = Resources.GetFont(Resources.FontResources.NinaB);
textS.Font = Resources.GetFont(Resources.FontResources.small);
char[] NinaBfont = new char[130];
string[] parts = new string[130];
uint x = 2;
uint y = 0;
uint W = 0;
uint H = 0;
y += (uint)text.Font.Height + 3;
x = 2;
for (ushort i = 0; i <= 128; ++i)
{
char T = Convert.ToChar(i);
W = (uint) text.Font.CharWidth(T);
H = (uint)text.Font.Height;
NinaBfont[i] = T;
string part = String.Empty;
part = T.ToString();
parts[i] = part;
x += (W + 2);
if(x > 300)
{
x = 2;
y+= (H + 2);
}
}
// *****ASSERT***** here using Concat
string result = String.Concat(parts);
}
}
}
Have a GREAT day!